Skip to content

Commit

Permalink
Merge branch 'incubation' into jira/dps_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zdtsw authored Oct 24, 2024
2 parents 91d5480 + bde4b4e commit 1dfe150
Show file tree
Hide file tree
Showing 51 changed files with 1,028 additions and 386 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/check-file-updates.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Check config and readme updates
on:
pull_request:
pull_request_target:
jobs:
file-updates:
permissions:
Expand All @@ -9,6 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Generate files
id: generate-files
run: |
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ on:
pull_request:
jobs:
unit-test:
name: Run tests and collect coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Run Unit Tests
run: make unit-test

- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Issues are tracked using [Jira](https://issues.redhat.com/secure/RapidBoard.jspa
1. **Fork the Repository:** Create your own fork of the repository to work on your changes.
2. **Create a Branch:** Create your own branch to include changes for the feature or a bug fix off of `incubation` branch.
3. **Work on Your Changes:** Commit often, and ensure your code adheres to these [Code Style Guidelines](#code-style-guidelines) and passes all the [quality gates](#quality-gates) for the operator.
4. **Testing:** Make sure your code passes all the tests, including any new tests you've added.
4. **Testing:** Make sure your code passes all the tests, including any new tests you've added. And that your changes do not decrease the test coverage as shown on report. Every new feature should come with unit tests that cover that new part of the code.

### Open a Pull Request:

Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 2.18.2
VERSION ?= 2.19.0
# IMAGE_TAG_BASE defines the opendatahub.io namespace and part of the image name for remote images.
# This variable is used to construct full image tags for bundle and catalog images.
#
Expand Down Expand Up @@ -180,9 +180,15 @@ api-docs: crd-ref-docs ## Creates API docs using https://github.com/elastic/crd-
build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go

RUN_ARGS = --log-mode=devel
GO_RUN_MAIN = OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) DEFAULT_MANIFESTS_PATH=$(DEFAULT_MANIFESTS_PATH) go run $(GO_RUN_ARGS) ./main.go $(RUN_ARGS)
.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) DEFAULT_MANIFESTS_PATH=${DEFAULT_MANIFESTS_PATH} go run ./main.go --log-mode=devel
$(GO_RUN_MAIN)

.PHONY: run-nowebhook
run-nowebhook: GO_RUN_ARGS += -tags nowebhook
run-nowebhook: run ## Run a controller from your host without webhook enabled

.PHONY: image-build
image-build: # unit-test ## Build image with the manager.
Expand Down Expand Up @@ -373,6 +379,7 @@ CLEANFILES += cover.out
e2e-test: ## Run e2e tests for the controller
go test ./tests/e2e/ -run ^TestOdhOperator -v --operator-namespace=${OPERATOR_NAMESPACE} ${E2E_TEST_FLAGS}

.PHONY: clean
clean: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) cache clean
chmod u+w -R $(LOCALBIN) # envtest makes its dir RO
Expand Down
45 changes: 16 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,26 +222,16 @@ This will ensure that the doc for the apis are updated accordingly.

### Enabled logging

#### Controller level
Global logger configuration can be changed with a command line switch `--log-mode <mode>`
for example from CSV. Valid values for `<mode>`: "" (as default) || prod || production || devel || development.

Logger on all controllers can only be changed from CSV with parameters: --log-mode devel
valid value: "" (as default) || prod || production || devel || development
Verbosity level is INFO.
To fine tune zap backend [standard operator sdk zap switches](https://sdk.operatorframework.io/docs/building-operators/golang/references/logging/)
can be used.

This mainly impacts logging for operator pod startup, generating common resource, monitoring deployment.

| --log-mode value | mapping Log level | Comments |
| ---------------- | ------------------- | -------------- |
| devel | debug / 0 | lowest level |
| "" | info / 1 | default option |
| default | info / 1 | default option |
| prod | error / 2 | highest level |

#### Component level

Logger on components can be changed by DSCI devFlags during runtime.
By default, if not set .spec.devFlags.logmode, it uses INFO level
Modification applies to all components, not only these "Managed" ones.
Update DSCI CR with .spec.devFlags.logmode, see example :
Log level can be changed by DSCI devFlags during runtime by setting
.spec.devFlags.logLevel. It accepts the same values as `--zap-log-level`
command line switch. See example :

```console
apiVersion: dscinitialization.opendatahub.io/v1
Expand All @@ -250,20 +240,17 @@ metadata:
name: default-dsci
spec:
devFlags:
logmode: development
logLevel: debug
...
```

Avaiable value for logmode is "devel", "development", "prod", "production".
The first two work the same set to DEBUG level; the later two work the same as using ERROR level.

| .spec.devFlags.logmode | stacktrace level | verbosity | Output | Comments |
| ---------------------- | ---------------- | --------- | -------- | -------------- |
| devel | WARN | INFO | Console | lowest level, using epoch time |
| development | WARN | INFO | Console | same as devel |
| "" | ERROR | INFO | JSON | default option |
| prod | ERROR | INFO | JSON | highest level, using human readable timestamp |
| production | ERROR | INFO | JSON | same as prod |
| logmode | stacktrace level | verbosity | Output | Comments |
|-------------|------------------|-----------|---------|-----------------------------------------------|
| devel | WARN | INFO | Console | lowest level, using epoch time |
| development | WARN | INFO | Console | same as devel |
| "" | ERROR | INFO | JSON | default option |
| prod | ERROR | INFO | JSON | highest level, using human readable timestamp |
| production | ERROR | INFO | JSON | same as prod |

### Example DSCInitialization

Expand Down
4 changes: 4 additions & 0 deletions apis/dscinitialization/v1/dscinitialization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ type DevFlags struct {
// Custom manifests uri for odh-manifests
// +optional
ManifestsUri string `json:"manifestsUri,omitempty"`
// ## DEPRECATED ##: Ignored, use LogLevel instead
// +kubebuilder:validation:Enum=devel;development;prod;production;default
// +kubebuilder:default="production"
LogMode string `json:"logmode,omitempty"`
// Override Zap log level. Can be "debug", "info", "error" or a number (more verbose).
// +optional
LogLevel string `json:"logLevel,omitempty"`
}

type TrustedCABundleSpec struct {
Expand Down
13 changes: 8 additions & 5 deletions bundle/manifests/opendatahub-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ metadata:
capabilities: Full Lifecycle
categories: AI/Machine Learning, Big Data
certified: "False"
containerImage: quay.io/opendatahub/opendatahub-operator:v2.18.2
createdAt: "2024-09-24T15:16:50Z"
olm.skipRange: '>=1.0.0 <2.18.2'
containerImage: quay.io/opendatahub/opendatahub-operator:v2.19.0
createdAt: "2024-10-09T14:46:54Z"
olm.skipRange: '>=1.0.0 <2.19.0'
operators.operatorframework.io/builder: operator-sdk-v1.31.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/opendatahub-io/opendatahub-operator
name: opendatahub-operator.v2.18.2
name: opendatahub-operator.v2.19.0
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -357,6 +357,7 @@ spec:
- apiGroups:
- config.openshift.io
resources:
- authentications
- clusterversions
verbs:
- get
Expand Down Expand Up @@ -1079,6 +1080,8 @@ spec:
fieldPath: metadata.namespace
- name: DEFAULT_MANIFESTS_PATH
value: /opt/manifests
- name: ODH_PLATFORM_TYPE
value: OpenDataHub
image: REPLACE_IMAGE:latest
imagePullPolicy: Always
livenessProbe:
Expand Down Expand Up @@ -1164,7 +1167,7 @@ spec:
selector:
matchLabels:
component: opendatahub-operator
version: 2.18.2
version: 2.19.0
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
5 changes: 2 additions & 3 deletions components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"path/filepath"

"github.com/go-logr/logr"
operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -74,11 +73,11 @@ func (c *CodeFlare) GetComponentName() string {

func (c *CodeFlare) ReconcileComponent(ctx context.Context,
cli client.Client,
l logr.Logger,
owner metav1.Object,
dscispec *dsciv1.DSCInitializationSpec,
platform cluster.Platform,
_ bool) error {
l := logf.FromContext(ctx)
enabled := c.GetManagementState() == operatorv1.Managed
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed

Expand Down Expand Up @@ -122,7 +121,7 @@ func (c *CodeFlare) ReconcileComponent(ctx context.Context,
}

// CloudServiceMonitoring handling
if platform == cluster.ManagedRhods {
if platform == cluster.ManagedRhoai {
// inject prometheus codeflare*.rules in to /opt/manifests/monitoring/prometheus/prometheus-configs.yaml
if err := c.UpdatePrometheusConfig(cli, l, enabled && monitoringEnabled, ComponentName); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type ManifestsConfig struct {

type ComponentInterface interface {
Init(ctx context.Context, platform cluster.Platform) error
ReconcileComponent(ctx context.Context, cli client.Client, logger logr.Logger,
ReconcileComponent(ctx context.Context, cli client.Client,
owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, platform cluster.Platform, currentComponentStatus bool) error
Cleanup(ctx context.Context, cli client.Client, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec) error
GetComponentName() string
Expand Down
22 changes: 11 additions & 11 deletions components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (d *Dashboard) Init(ctx context.Context, platform cluster.Platform) error {
"odh-dashboard-image": "RELATED_IMAGE_ODH_DASHBOARD_IMAGE",
}
DefaultPath = map[cluster.Platform]string{
cluster.SelfManagedRhods: PathDownstream + "/onprem",
cluster.ManagedRhods: PathDownstream + "/addon",
cluster.SelfManagedRhoai: PathDownstream + "/onprem",
cluster.ManagedRhoai: PathDownstream + "/addon",
cluster.OpenDataHub: PathUpstream,
cluster.Unknown: PathUpstream,
}[platform]
Expand Down Expand Up @@ -84,13 +84,13 @@ func (d *Dashboard) GetComponentName() string {

func (d *Dashboard) ReconcileComponent(ctx context.Context,
cli client.Client,
l logr.Logger,
owner metav1.Object,
dscispec *dsciv1.DSCInitializationSpec,
platform cluster.Platform,
currentComponentExist bool,
) error {
entryPath := DefaultPath
l := logf.FromContext(ctx)
enabled := d.GetManagementState() == operatorv1.Managed
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed

Expand Down Expand Up @@ -135,7 +135,7 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
// common: Deploy odh-dashboard manifests
// TODO: check if we can have the same component name odh-dashboard for both, or still keep rhods-dashboard for RHOAI
switch platform {
case cluster.SelfManagedRhods, cluster.ManagedRhods:
case cluster.SelfManagedRhoai, cluster.ManagedRhoai:
// anaconda
if err := cluster.CreateSecret(ctx, cli, "anaconda-ce-access", dscispec.ApplicationsNamespace); err != nil {
return fmt.Errorf("failed to create access-secret for anaconda: %w", err)
Expand All @@ -153,7 +153,7 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
}

// CloudService Monitoring handling
if platform == cluster.ManagedRhods {
if platform == cluster.ManagedRhoai {
if err := d.UpdatePrometheusConfig(cli, l, enabled && monitoringEnabled, ComponentNameDownstream); err != nil {
return err
}
Expand Down Expand Up @@ -185,15 +185,15 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,

func updateKustomizeVariable(ctx context.Context, cli client.Client, platform cluster.Platform, dscispec *dsciv1.DSCInitializationSpec) (map[string]string, error) {
adminGroups := map[cluster.Platform]string{
cluster.SelfManagedRhods: "rhods-admins",
cluster.ManagedRhods: "dedicated-admins",
cluster.SelfManagedRhoai: "rhods-admins",
cluster.ManagedRhoai: "dedicated-admins",
cluster.OpenDataHub: "odh-admins",
cluster.Unknown: "odh-admins",
}[platform]

sectionTitle := map[cluster.Platform]string{
cluster.SelfManagedRhods: "OpenShift Self Managed Services",
cluster.ManagedRhods: "OpenShift Managed Services",
cluster.SelfManagedRhoai: "OpenShift Self Managed Services",
cluster.ManagedRhoai: "OpenShift Managed Services",
cluster.OpenDataHub: "OpenShift Open Data Hub",
cluster.Unknown: "OpenShift Open Data Hub",
}[platform]
Expand All @@ -203,8 +203,8 @@ func updateKustomizeVariable(ctx context.Context, cli client.Client, platform cl
return nil, fmt.Errorf("error getting console route URL %s : %w", consoleLinkDomain, err)
}
consoleURL := map[cluster.Platform]string{
cluster.SelfManagedRhods: "https://rhods-dashboard-" + dscispec.ApplicationsNamespace + "." + consoleLinkDomain,
cluster.ManagedRhods: "https://rhods-dashboard-" + dscispec.ApplicationsNamespace + "." + consoleLinkDomain,
cluster.SelfManagedRhoai: "https://rhods-dashboard-" + dscispec.ApplicationsNamespace + "." + consoleLinkDomain,
cluster.ManagedRhoai: "https://rhods-dashboard-" + dscispec.ApplicationsNamespace + "." + consoleLinkDomain,
cluster.OpenDataHub: "https://odh-dashboard-" + dscispec.ApplicationsNamespace + "." + consoleLinkDomain,
cluster.Unknown: "https://odh-dashboard-" + dscispec.ApplicationsNamespace + "." + consoleLinkDomain,
}[platform]
Expand Down
5 changes: 2 additions & 3 deletions components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"path/filepath"

"github.com/go-logr/logr"
operatorv1 "github.com/openshift/api/operator/v1"
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -88,12 +87,12 @@ func (d *DataSciencePipelines) GetComponentName() string {

func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
cli client.Client,
l logr.Logger,
owner metav1.Object,
dscispec *dsciv1.DSCInitializationSpec,
platform cluster.Platform,
_ bool,
) error {
l := logf.FromContext(ctx)
enabled := d.GetManagementState() == operatorv1.Managed
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed

Expand Down Expand Up @@ -129,7 +128,7 @@ func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
}

// CloudService Monitoring handling
if platform == cluster.ManagedRhods {
if platform == cluster.ManagedRhoai {
if err := d.UpdatePrometheusConfig(cli, l, enabled && monitoringEnabled, ComponentName); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path/filepath"
"strings"

"github.com/go-logr/logr"
operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -112,7 +111,8 @@ func (k *Kserve) GetComponentName() string {
}

func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
l logr.Logger, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
l := logf.FromContext(ctx)
enabled := k.GetManagementState() == operatorv1.Managed
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed

Expand Down Expand Up @@ -170,7 +170,7 @@ func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
}

// CloudService Monitoring handling
if platform == cluster.ManagedRhods {
if platform == cluster.ManagedRhoai {
// kesrve rules
if err := k.UpdatePrometheusConfig(cli, l, enabled && monitoringEnabled, ComponentName); err != nil {
return err
Expand Down
Loading

0 comments on commit 1dfe150

Please sign in to comment.