Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(codeflare): support unmanaged #604

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ spec:
to keep it active. It will only upgrade the component if
it is safe to do so \n - \"Removed\" : the operator is actively
managing the component and will not install it, or if it
is installed, the operator will try to remove it"
is installed, the operator will try to remove it \n - \"Unmanaged\"
: the operator will not take any action related to the component"
enum:
- Managed
- Removed
- Unmanaged
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
Expand Down Expand Up @@ -120,10 +122,12 @@ spec:
to keep it active. It will only upgrade the component if
it is safe to do so \n - \"Removed\" : the operator is actively
managing the component and will not install it, or if it
is installed, the operator will try to remove it"
is installed, the operator will try to remove it \n - \"Unmanaged\"
: the operator will not take any action related to the component"
enum:
- Managed
- Removed
- Unmanaged
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
Expand Down Expand Up @@ -164,10 +168,12 @@ spec:
to keep it active. It will only upgrade the component if
it is safe to do so \n - \"Removed\" : the operator is actively
managing the component and will not install it, or if it
is installed, the operator will try to remove it"
is installed, the operator will try to remove it \n - \"Unmanaged\"
: the operator will not take any action related to the component"
enum:
- Managed
- Removed
- Unmanaged
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
Expand Down Expand Up @@ -210,10 +216,12 @@ spec:
to keep it active. It will only upgrade the component if
it is safe to do so \n - \"Removed\" : the operator is actively
managing the component and will not install it, or if it
is installed, the operator will try to remove it"
is installed, the operator will try to remove it \n - \"Unmanaged\"
: the operator will not take any action related to the component"
enum:
- Managed
- Removed
- Unmanaged
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
Expand Down Expand Up @@ -255,10 +263,12 @@ spec:
to keep it active. It will only upgrade the component if
it is safe to do so \n - \"Removed\" : the operator is actively
managing the component and will not install it, or if it
is installed, the operator will try to remove it"
is installed, the operator will try to remove it \n - \"Unmanaged\"
: the operator will not take any action related to the component"
enum:
- Managed
- Removed
- Unmanaged
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
Expand Down Expand Up @@ -299,10 +309,12 @@ spec:
to keep it active. It will only upgrade the component if
it is safe to do so \n - \"Removed\" : the operator is actively
managing the component and will not install it, or if it
is installed, the operator will try to remove it"
is installed, the operator will try to remove it \n - \"Unmanaged\"
: the operator will not take any action related to the component"
enum:
- Managed
- Removed
- Unmanaged
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
Expand Down Expand Up @@ -342,10 +354,12 @@ spec:
to keep it active. It will only upgrade the component if
it is safe to do so \n - \"Removed\" : the operator is actively
managing the component and will not install it, or if it
is installed, the operator will try to remove it"
is installed, the operator will try to remove it \n - \"Unmanaged\"
: the operator will not take any action related to the component"
enum:
- Managed
- Removed
- Unmanaged
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
Expand Down Expand Up @@ -385,10 +399,12 @@ spec:
to keep it active. It will only upgrade the component if
it is safe to do so \n - \"Removed\" : the operator is actively
managing the component and will not install it, or if it
is installed, the operator will try to remove it"
is installed, the operator will try to remove it \n - \"Unmanaged\"
: the operator will not take any action related to the component"
enum:
- Managed
- Removed
- Unmanaged
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ metadata:
"spec": {
"components": {
"codeflare": {
"managementState": "Removed"
"managementState": "Unmanaged"
},
"dashboard": {
"managementState": "Managed"
Expand All @@ -106,7 +106,7 @@ metadata:
"managementState": "Managed"
},
"ray": {
"managementState": "Removed"
"managementState": "Managed"
},
"workbenches": {
"managementState": "Managed"
Expand Down
48 changes: 22 additions & 26 deletions components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package codeflare

import (
"fmt"

"path/filepath"

dsci "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
Expand All @@ -17,7 +16,7 @@ import (

var (
ComponentName = "codeflare"
CodeflarePath = deploy.DefaultManifestPath + "/" + ComponentName + "/base"
CodeflarePath = deploy.DefaultManifestPath + "/" + ComponentName + "/manifests"
CodeflareOperator = "codeflare-operator"
RHCodeflareOperator = "rhods-codeflare-operator"
)
Expand Down Expand Up @@ -52,45 +51,42 @@ var _ components.ComponentInterface = (*CodeFlare)(nil)

func (c *CodeFlare) ReconcileComponent(cli client.Client, owner metav1.Object, dscispec *dsci.DSCInitializationSpec) error {
var imageParamMap = map[string]string{
"odh-codeflare-operator-controller-image": "RELATED_IMAGE_ODH_CODEFLARE_OPERATOR_IMAGE", // no need mcad, embedded in cfo
"namespace": dscispec.ApplicationsNamespace,
}
enabled := c.GetManagementState() == operatorv1.Managed
platform, err := deploy.GetPlatform(cli)
if err != nil {
return err
}

if enabled {
// Download manifests and update paths
if err = c.OverrideManifests(string(platform)); err != nil {
dependentOperator := CodeflareOperator
// overwrite dependent operator if downstream not match upstream
if platform == deploy.SelfManagedRhods || platform == deploy.ManagedRhods {
dependentOperator = RHCodeflareOperator
}
// Download manifests and update paths
if err = c.OverrideManifests(string(platform)); err != nil {
return err
}
// Update image parameters only when we do not have customized manifests set
if dscispec.DevFlags.ManifestsUri == "" && len(c.DevFlags.Manifests) == 0 {
if err := deploy.ApplyParams(CodeflarePath+"/base", c.SetImageParamsMap(imageParamMap), true); err != nil {
return err
}
}
if c.GetManagementState() == operatorv1.Managed {
// check if the CodeFlare operator is installed
// codeflare operator not installed
dependentOperator := CodeflareOperator
// overwrite dependent operator if downstream not match upstream
if platform == deploy.SelfManagedRhods || platform == deploy.ManagedRhods {
dependentOperator = RHCodeflareOperator
}

if found, err := deploy.OperatorExists(cli, dependentOperator); err != nil {
return err
} else if !found {
return fmt.Errorf("operator %s not found. Please install the operator before enabling %s component",
} else if found {
return fmt.Errorf("operator %s already installed in cluster. Please uninstall the operator before enabling %s component",
dependentOperator, ComponentName)
}

// Update image parameters only when we do not have customized manifests set
if dscispec.DevFlags.ManifestsUri == "" && len(c.DevFlags.Manifests) == 0 {
if err := deploy.ApplyParams(CodeflarePath, c.SetImageParamsMap(imageParamMap), true); err != nil {
return err
}
}
// Deploy Codeflare
err = deploy.DeployManifestsFromPath(cli, owner, CodeflarePath, dscispec.ApplicationsNamespace, c.GetComponentName(), operatorv1.Managed)
return err
}

// Deploy Codeflare
err = deploy.DeployManifestsFromPath(cli, owner, CodeflarePath, dscispec.ApplicationsNamespace, c.GetComponentName(), enabled)
return err
return nil
}

func (c *CodeFlare) DeepCopyInto(target *CodeFlare) {
Expand Down
4 changes: 3 additions & 1 deletion components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type Component struct {
// - "Removed" : the operator is actively managing the component and will not install it,
// or if it is installed, the operator will try to remove it
//
// +kubebuilder:validation:Enum=Managed;Removed
// - "Unmanaged" : the operator will not take any action related to the component
//
// +kubebuilder:validation:Enum=Managed;Removed;Unmanaged
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
// Add any other common fields across components below

Expand Down
21 changes: 8 additions & 13 deletions components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ func (d *Dashboard) ReconcileComponent(cli client.Client, owner metav1.Object, d

// Deploy odh-dashboard manifests
if platform == deploy.OpenDataHub || platform == "" {
if err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
if err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, d.GetManagementState()); err != nil {
return err
}
} else if platform == deploy.SelfManagedRhods || platform == deploy.ManagedRhods {
// Apply authentication overlay
if err := deploy.DeployManifestsFromPath(cli, owner, PathSupported, dscispec.ApplicationsNamespace, ComponentNameSupported, enabled); err != nil {
if err := deploy.DeployManifestsFromPath(cli, owner, PathSupported, dscispec.ApplicationsNamespace, ComponentNameSupported, d.GetManagementState()); err != nil {
return err
}
}
Expand Down Expand Up @@ -163,8 +163,7 @@ func (d *Dashboard) deployCRDsForPlatform(cli client.Client, owner metav1.Object
componentName = ComponentNameSupported
}

enabled := d.ManagementState == operatorv1.Managed
return deploy.DeployManifestsFromPath(cli, owner, PathCRDs, namespace, componentName, enabled)
return deploy.DeployManifestsFromPath(cli, owner, PathCRDs, namespace, componentName, d.GetManagementState())
}

func (d *Dashboard) applyRhodsSpecificConfigs(cli client.Client, owner metav1.Object, namespace string, platform deploy.Platform) error {
Expand All @@ -178,20 +177,19 @@ func (d *Dashboard) applyRhodsSpecificConfigs(cli client.Client, owner metav1.Ob
return err
}

enabled := d.ManagementState == operatorv1.Managed
if err := deploy.DeployManifestsFromPath(cli, owner, PathODHDashboardConfig, namespace, ComponentNameSupported, enabled); err != nil {
if err := deploy.DeployManifestsFromPath(cli, owner, PathODHDashboardConfig, namespace, ComponentNameSupported, d.ManagementState); err != nil {
return fmt.Errorf("failed to set dashboard config from %s: %w", PathODHDashboardConfig, err)
}

if err := deploy.DeployManifestsFromPath(cli, owner, PathOVMS, namespace, ComponentNameSupported, enabled); err != nil {
if err := deploy.DeployManifestsFromPath(cli, owner, PathOVMS, namespace, ComponentNameSupported, d.ManagementState); err != nil {
return fmt.Errorf("failed to set dashboard OVMS from %s: %w", PathOVMS, err)
}

if err := common.CreateSecret(cli, "anaconda-ce-access", namespace); err != nil {
return fmt.Errorf("failed to create access-secret for anaconda: %w", err)
}

return deploy.DeployManifestsFromPath(cli, owner, PathAnaconda, namespace, ComponentNameSupported, enabled)
return deploy.DeployManifestsFromPath(cli, owner, PathAnaconda, namespace, ComponentNameSupported, d.ManagementState)
}

func (d *Dashboard) deployISVManifests(cli client.Client, owner metav1.Object, componentName, namespace string, platform deploy.Platform) error {
Expand All @@ -205,8 +203,7 @@ func (d *Dashboard) deployISVManifests(cli client.Client, owner metav1.Object, c
return nil
}

enabled := d.ManagementState == operatorv1.Managed
if err := deploy.DeployManifestsFromPath(cli, owner, path, namespace, componentName, enabled); err != nil {
if err := deploy.DeployManifestsFromPath(cli, owner, path, namespace, componentName, d.ManagementState); err != nil {
return fmt.Errorf("failed to set dashboard ISV from %s: %w", path, err)
}

Expand All @@ -230,9 +227,7 @@ func (d *Dashboard) deployConsoleLink(cli client.Client, owner metav1.Object, na
if err != nil {
return fmt.Errorf("error replacing with correct dashboard url for ConsoleLink: %w", err)
}

enabled := d.ManagementState == operatorv1.Managed
err = deploy.DeployManifestsFromPath(cli, owner, pathConsoleLink, namespace, componentName, enabled)
err = deploy.DeployManifestsFromPath(cli, owner, pathConsoleLink, namespace, componentName, d.ManagementState)
if err != nil {
return fmt.Errorf("failed to set dashboard consolelink from %s: %w", PathConsoleLink, err)
}
Expand Down
2 changes: 1 addition & 1 deletion components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (d *DataSciencePipelines) ReconcileComponent(cli client.Client, owner metav
}
}

err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, d.GetComponentName(), enabled)
err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, d.GetComponentName(), d.GetManagementState())
return err
}

Expand Down
4 changes: 2 additions & 2 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (k *Kserve) ReconcileComponent(cli client.Client, owner metav1.Object, dsci
}
}

if err := deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
if err := deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, k.GetManagementState()); err != nil {
return err
}

Expand All @@ -133,7 +133,7 @@ func (k *Kserve) ReconcileComponent(cli client.Client, owner metav1.Object, dsci
}
}
}
if err := deploy.DeployManifestsFromPath(cli, owner, DependentPath, dscispec.ApplicationsNamespace, k.GetComponentName(), enabled); err != nil {
if err := deploy.DeployManifestsFromPath(cli, owner, DependentPath, dscispec.ApplicationsNamespace, k.GetComponentName(), k.GetManagementState()); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (m *ModelMeshServing) ReconcileComponent(cli client.Client, owner metav1.Ob
}
}

err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, enabled)
err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, ComponentName, m.GetManagementState())
if err != nil {
return err
}
Expand All @@ -104,7 +104,7 @@ func (m *ModelMeshServing) ReconcileComponent(cli client.Client, owner metav1.Ob
}

// If modelmesh is deployed successfully, deploy modelmesh-monitoring
err = deploy.DeployManifestsFromPath(cli, owner, monitoringPath, monitoringNamespace, ComponentName, enabled)
err = deploy.DeployManifestsFromPath(cli, owner, monitoringPath, monitoringNamespace, ComponentName, m.GetManagementState())

return err
}
Expand Down
2 changes: 1 addition & 1 deletion components/ray/ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (r *Ray) ReconcileComponent(cli client.Client, owner metav1.Object, dscispe
}
}
// Deploy Ray Operator
err = deploy.DeployManifestsFromPath(cli, owner, RayPath, dscispec.ApplicationsNamespace, r.GetComponentName(), enabled)
err = deploy.DeployManifestsFromPath(cli, owner, RayPath, dscispec.ApplicationsNamespace, r.GetComponentName(), r.GetManagementState())
return err
}

Expand Down
2 changes: 1 addition & 1 deletion components/trustyai/trustyai.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (t *TrustyAI) ReconcileComponent(cli client.Client, owner metav1.Object, ds
}
}
// Deploy TrustyAI Operator
err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, t.GetComponentName(), enabled)
err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, t.GetComponentName(), t.GetManagementState())
return err
}

Expand Down
8 changes: 4 additions & 4 deletions components/workbenches/workbenches.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (w *Workbenches) ReconcileComponent(cli client.Client, owner metav1.Object,
}
}

err = deploy.DeployManifestsFromPath(cli, owner, notebookControllerPath, dscispec.ApplicationsNamespace, ComponentName, enabled)
err = deploy.DeployManifestsFromPath(cli, owner, notebookControllerPath, dscispec.ApplicationsNamespace, ComponentName, w.GetManagementState())
if err != nil {
return err
}
Expand All @@ -145,7 +145,7 @@ func (w *Workbenches) ReconcileComponent(cli client.Client, owner metav1.Object,
err = deploy.DeployManifestsFromPath(cli, owner,
kfnotebookControllerPath,
dscispec.ApplicationsNamespace,
ComponentName, enabled)
ComponentName, w.GetManagementState())
if err != nil {
return err
}
Expand All @@ -154,10 +154,10 @@ func (w *Workbenches) ReconcileComponent(cli client.Client, owner metav1.Object,
notebookImagesPath,
dscispec.ApplicationsNamespace,
ComponentName,
enabled)
w.GetManagementState())
return err
} else {
err = deploy.DeployManifestsFromPath(cli, owner, notebookImagesPathSupported, dscispec.ApplicationsNamespace, ComponentName, enabled)
err = deploy.DeployManifestsFromPath(cli, owner, notebookImagesPathSupported, dscispec.ApplicationsNamespace, ComponentName, w.GetManagementState())
return err
}
}
Expand Down
Loading