Skip to content

Commit

Permalink
feat: pass platform from env variable or fall back to use old logic (o…
Browse files Browse the repository at this point in the history
…pendatahub-io#1252)

* feat: pass platform from env variables or fall back to use old logic

- introduce new env var ODH_PLATFORM_TYPE, value set during build time
  - if value not match, fall back to detect managed then self-managed

Signed-off-by: Wen Zhou <[email protected]>

---------

Signed-off-by: Wen Zhou <[email protected]>
(cherry picked from commit 283d350)
  • Loading branch information
zdtsw authored and openshift-merge-bot[bot] committed Oct 17, 2024
1 parent 4263893 commit e5b9904
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 3 additions & 1 deletion bundle/manifests/rhods-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ metadata:
categories: AI/Machine Learning, Big Data
certified: "False"
containerImage: REPLACE_IMAGE:latest
createdAt: "2024-10-17T12:04:27Z"
createdAt: "2024-10-17T12:29:02Z"
description: Operator for deployment and management of Red Hat OpenShift AI
features.operators.openshift.io/disconnected: "true"
features.operators.openshift.io/fips-compliant: "false"
Expand Down Expand Up @@ -1177,6 +1177,8 @@ spec:
fieldPath: metadata.namespace
- name: DEFAULT_MANIFESTS_PATH
value: /opt/manifests
# - name: ODH_PLATFORM_TYPE # comment this out due to konflux is not ready to support different value
# value: SelfManagedRHOAI # for the managed we need to set it to ManagedRHOAI
image: REPLACE_IMAGE:latest
imagePullPolicy: Always
livenessProbe:
Expand Down
5 changes: 2 additions & 3 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ spec:
fieldPath: metadata.namespace
- name: DEFAULT_MANIFESTS_PATH
value: /opt/manifests
args:
- --leader-elect
- --operator-name=opendatahub
- name: ODH_PLATFORM_TYPE
value: SelfManagedRHOAI
image: controller:latest
imagePullPolicy: Always
name: manager
Expand Down
21 changes: 14 additions & 7 deletions pkg/cluster/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,21 @@ func detectManagedRHODS(ctx context.Context, cli client.Client) (Platform, error
}

func getPlatform(ctx context.Context, cli client.Client) (Platform, error) {
// First check if its addon installation to return 'ManagedRhods, nil'
if platform, err := detectManagedRHODS(ctx, cli); err != nil {
return Unknown, err
} else if platform == ManagedRhods {
switch os.Getenv("ODH_PLATFORM_TYPE") {
case "OpenDataHub", "":
return OpenDataHub, nil
case "ManagedRHOAI":
return ManagedRhods, nil
case "SelfManagedRHOAI":
return SelfManagedRhods, nil
default: // fall back to detect platform if ODH_PLATFORM_TYPE env is not provided
if platform, err := detectManagedRHODS(ctx, cli); err != nil {
return Unknown, err
} else if platform == ManagedRhods {
return ManagedRhods, nil
}
return detectSelfManaged(ctx, cli)
}

// check and return whether ODH or self-managed platform
return detectSelfManaged(ctx, cli)
}

// Release includes information on operator version and platform
Expand Down Expand Up @@ -153,6 +159,7 @@ func GetRelease(ctx context.Context, cli client.Client) (Release, error) {
if os.Getenv("CI") == "true" {
return initRelease, nil
}

// Set Version
// Get watchNamespace
operatorNamespace, err := GetOperatorNamespace()
Expand Down

0 comments on commit e5b9904

Please sign in to comment.