diff --git a/apis/datasciencecluster/v1/datasciencecluster_types.go b/apis/datasciencecluster/v1/datasciencecluster_types.go index 39166651ac1..eec561044b9 100644 --- a/apis/datasciencecluster/v1/datasciencecluster_types.go +++ b/apis/datasciencecluster/v1/datasciencecluster_types.go @@ -87,12 +87,6 @@ type Components struct { TrainingOperator trainingoperator.TrainingOperator `json:"trainingoperator,omitempty"` } -// ComponentsStatus defines the custom status of DataScienceCluster components. -type ComponentsStatus struct { - // ModelRegistry component status - ModelRegistry *status.ModelRegistryStatus `json:"modelregistry,omitempty"` -} - // DataScienceClusterStatus defines the observed state of DataScienceCluster. type DataScienceClusterStatus struct { // Phase describes the Phase of DataScienceCluster reconciliation state @@ -114,7 +108,7 @@ type DataScienceClusterStatus struct { // Expose component's specific status // +optional - Components ComponentsStatus `json:"components,omitempty"` + Components status.ComponentsStatus `json:"components,omitempty"` // Version and release type Release cluster.Release `json:"release,omitempty"` diff --git a/apis/datasciencecluster/v1/zz_generated.deepcopy.go b/apis/datasciencecluster/v1/zz_generated.deepcopy.go index f089d70e9ee..642686fced1 100644 --- a/apis/datasciencecluster/v1/zz_generated.deepcopy.go +++ b/apis/datasciencecluster/v1/zz_generated.deepcopy.go @@ -21,7 +21,6 @@ limitations under the License. package v1 import ( - "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" corev1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -53,26 +52,6 @@ func (in *Components) DeepCopy() *Components { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ComponentsStatus) DeepCopyInto(out *ComponentsStatus) { - *out = *in - if in.ModelRegistry != nil { - in, out := &in.ModelRegistry, &out.ModelRegistry - *out = new(status.ModelRegistryStatus) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentsStatus. -func (in *ComponentsStatus) DeepCopy() *ComponentsStatus { - if in == nil { - return nil - } - out := new(ComponentsStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DataScienceCluster) DeepCopyInto(out *DataScienceCluster) { *out = *in diff --git a/components/codeflare/codeflare.go b/components/codeflare/codeflare.go index 7e114389465..e83c23f9300 100644 --- a/components/codeflare/codeflare.go +++ b/components/codeflare/codeflare.go @@ -15,6 +15,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" ) @@ -71,6 +72,26 @@ func (c *CodeFlare) GetComponentName() string { return ComponentName } +func (c *CodeFlare) UpdateStatus(in *status.ComponentsStatus) error { + if c.GetManagementState() != operatorv1.Managed { + in.CodeFlare = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.CodeFlare = &status.CodeFlareStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (c *CodeFlare) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, diff --git a/components/component.go b/components/component.go index 8256fbb0542..9cdc1730fb2 100644 --- a/components/component.go +++ b/components/component.go @@ -14,6 +14,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" ) @@ -86,6 +87,7 @@ type ComponentInterface interface { 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 + UpdateStatus(status *status.ComponentsStatus) error GetManagementState() operatorv1.ManagementState OverrideManifests(ctx context.Context, platform cluster.Platform) error UpdatePrometheusConfig(cli client.Client, logger logr.Logger, enable bool, component string) error diff --git a/components/dashboard/dashboard.go b/components/dashboard/dashboard.go index 47a2ce2ba04..12549edd73b 100644 --- a/components/dashboard/dashboard.go +++ b/components/dashboard/dashboard.go @@ -19,6 +19,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" ) @@ -82,6 +83,17 @@ func (d *Dashboard) GetComponentName() string { return ComponentNameUpstream } +func (d *Dashboard) UpdateStatus(in *status.ComponentsStatus) error { + if d.GetManagementState() != operatorv1.Managed { + in.Dashboard = nil + return nil + } + + in.Dashboard = &status.DashboardStatus{} + + return nil +} + func (d *Dashboard) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, diff --git a/components/datasciencepipelines/datasciencepipelines.go b/components/datasciencepipelines/datasciencepipelines.go index d11cae6153d..99a5fe3a1fe 100644 --- a/components/datasciencepipelines/datasciencepipelines.go +++ b/components/datasciencepipelines/datasciencepipelines.go @@ -92,6 +92,26 @@ func (d *DataSciencePipelines) GetComponentName() string { return ComponentName } +func (d *DataSciencePipelines) UpdateStatus(in *status.ComponentsStatus) error { + if d.GetManagementState() != operatorv1.Managed { + in.DataSciencePipelines = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.DataSciencePipelines = &status.DataSciencePipelinesStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, diff --git a/components/kserve/kserve.go b/components/kserve/kserve.go index 3734551ba56..141986386a9 100644 --- a/components/kserve/kserve.go +++ b/components/kserve/kserve.go @@ -16,6 +16,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" ) @@ -110,6 +111,26 @@ func (k *Kserve) GetComponentName() string { return ComponentName } +func (k *Kserve) UpdateStatus(in *status.ComponentsStatus) error { + if k.GetManagementState() != operatorv1.Managed { + in.Kserve = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.Kserve = &status.KserveStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { l := logf.FromContext(ctx) diff --git a/components/kueue/kueue.go b/components/kueue/kueue.go index 0e63f707548..d8e3037b830 100644 --- a/components/kueue/kueue.go +++ b/components/kueue/kueue.go @@ -13,6 +13,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" ) @@ -67,6 +68,26 @@ func (k *Kueue) GetComponentName() string { return ComponentName } +func (k *Kueue) UpdateStatus(in *status.ComponentsStatus) error { + if k.GetManagementState() != operatorv1.Managed { + in.Kueue = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.Kueue = &status.KueueStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (k *Kueue) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { l := logf.FromContext(ctx) diff --git a/components/modelmeshserving/modelmeshserving.go b/components/modelmeshserving/modelmeshserving.go index 40034741cfe..12d28d77e2f 100644 --- a/components/modelmeshserving/modelmeshserving.go +++ b/components/modelmeshserving/modelmeshserving.go @@ -15,6 +15,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" ) @@ -100,6 +101,26 @@ func (m *ModelMeshServing) GetComponentName() string { return ComponentName } +func (m *ModelMeshServing) UpdateStatus(in *status.ComponentsStatus) error { + if m.GetManagementState() != operatorv1.Managed { + in.ModelMeshServing = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.ModelMeshServing = &status.ModelMeshServingStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (m *ModelMeshServing) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, diff --git a/components/modelregistry/modelregistry.go b/components/modelregistry/modelregistry.go index 242bea853f1..66292cd25c0 100644 --- a/components/modelregistry/modelregistry.go +++ b/components/modelregistry/modelregistry.go @@ -19,6 +19,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/conversion" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" @@ -96,6 +97,26 @@ func (m *ModelRegistry) GetComponentName() string { return ComponentName } +func (m *ModelRegistry) UpdateStatus(in *status.ComponentsStatus) error { + if m.GetManagementState() != operatorv1.Managed { + in.ModelRegistry = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.ModelRegistry = &status.ModelRegistryStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (m *ModelRegistry) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { l := logf.FromContext(ctx) diff --git a/components/ray/ray.go b/components/ray/ray.go index 8b6e3cc6dfb..3ee15319ecd 100644 --- a/components/ray/ray.go +++ b/components/ray/ray.go @@ -15,6 +15,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" ) @@ -68,6 +69,26 @@ func (r *Ray) GetComponentName() string { return ComponentName } +func (r *Ray) UpdateStatus(in *status.ComponentsStatus) error { + if r.GetManagementState() != operatorv1.Managed { + in.Ray = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.Ray = &status.RayStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (r *Ray) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { l := logf.FromContext(ctx) diff --git a/components/trainingoperator/trainingoperator.go b/components/trainingoperator/trainingoperator.go index 9346a54f1b9..b4a4bfd489c 100644 --- a/components/trainingoperator/trainingoperator.go +++ b/components/trainingoperator/trainingoperator.go @@ -15,6 +15,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" ) @@ -69,6 +70,26 @@ func (r *TrainingOperator) GetComponentName() string { return ComponentName } +func (r *TrainingOperator) UpdateStatus(in *status.ComponentsStatus) error { + if r.GetManagementState() != operatorv1.Managed { + in.TrainingOperator = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.TrainingOperator = &status.TrainingOperatorStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (r *TrainingOperator) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { l := logf.FromContext(ctx) diff --git a/components/trustyai/trustyai.go b/components/trustyai/trustyai.go index b0ad4eb2bed..a9981a61b92 100644 --- a/components/trustyai/trustyai.go +++ b/components/trustyai/trustyai.go @@ -14,6 +14,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" ) @@ -78,6 +79,26 @@ func (t *TrustyAI) GetComponentName() string { return ComponentName } +func (t *TrustyAI) UpdateStatus(in *status.ComponentsStatus) error { + if t.GetManagementState() != operatorv1.Managed { + in.TrustyAI = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.TrustyAI = &status.TrustyAIStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (t *TrustyAI) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { l := logf.FromContext(ctx) diff --git a/components/workbenches/workbenches.go b/components/workbenches/workbenches.go index 46671b4b028..581c42d69da 100644 --- a/components/workbenches/workbenches.go +++ b/components/workbenches/workbenches.go @@ -15,6 +15,7 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/labels" @@ -110,6 +111,26 @@ func (w *Workbenches) GetComponentName() string { return ComponentName } +func (w *Workbenches) UpdateStatus(in *status.ComponentsStatus) error { + if w.GetManagementState() != operatorv1.Managed { + in.Workbenches = nil + return nil + } + + releases, err := status.GetReleaseStatus(deploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + + in.Workbenches = &status.WorkbenchesStatus{ + ComponentStatus: status.ComponentStatus{ + Releases: releases, + }, + } + return nil +} + func (w *Workbenches) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { l := logf.FromContext(ctx) diff --git a/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml b/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml index 41d1c76d658..f04b8fbd7cb 100644 --- a/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml +++ b/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml @@ -650,11 +650,161 @@ spec: components: description: Expose component's specific status properties: + codeflare: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + dashboard: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + datasciencepipelines: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + kserve: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + kueue: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + modelmeshserving: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object modelregistry: - description: ModelRegistry component status properties: registriesNamespace: type: string + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + ray: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + trainingoperator: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + trustyai: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array + type: object + workbenches: + properties: + releases: + items: + properties: + name: + type: string + repoURL: + type: string + version: + type: string + type: object + type: array type: object type: object conditions: diff --git a/controllers/datasciencecluster/datasciencecluster_controller.go b/controllers/datasciencecluster/datasciencecluster_controller.go index 22a5944676f..3332a0dd711 100644 --- a/controllers/datasciencecluster/datasciencecluster_controller.go +++ b/controllers/datasciencecluster/datasciencecluster_controller.go @@ -54,7 +54,6 @@ import ( dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/components/datasciencepipelines" - "github.com/opendatahub-io/opendatahub-operator/v2/components/modelregistry" "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" annotations "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/annotations" @@ -338,20 +337,16 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(ctx context.Context saved.Status.InstalledComponents = make(map[string]bool) } saved.Status.InstalledComponents[componentName] = enabled + err := component.UpdateStatus(&saved.Status.Components) + + if err != nil { + r.reportError(ctx, err, instance, "failed to update DataScienceCluster status after reconciling "+componentName) + } if enabled { status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileCompleted, "Component reconciled successfully", corev1.ConditionTrue) } else { status.RemoveComponentCondition(&saved.Status.Conditions, componentName) } - - // TODO: replace this hack with a full refactor of component status in the future - if mr, isMR := component.(*modelregistry.ModelRegistry); isMR { - if enabled { - saved.Status.Components.ModelRegistry = &status.ModelRegistryStatus{RegistriesNamespace: mr.RegistriesNamespace} - } else { - saved.Status.Components.ModelRegistry = nil - } - } }) if err != nil { instance = r.reportError(ctx, err, instance, "failed to update DataScienceCluster status after reconciling "+componentName) diff --git a/controllers/secretgenerator/secretgenerator_controller_test.go b/controllers/secretgenerator/secretgenerator_controller_test.go index 4eac042d7f0..bba6dc87551 100644 --- a/controllers/secretgenerator/secretgenerator_controller_test.go +++ b/controllers/secretgenerator/secretgenerator_controller_test.go @@ -23,8 +23,7 @@ import ( . "github.com/onsi/gomega" ) -//nolint:ireturn -func newFakeClient(objs ...client.Object) client.Client { +func newFakeClient(objs ...client.Object) client.Client { //nolint:ireturn scheme := runtime.NewScheme() utilruntime.Must(corev1.AddToScheme(scheme)) utilruntime.Must(appsv1.AddToScheme(scheme)) diff --git a/controllers/status/status.go b/controllers/status/status.go index 808cfee2f7b..540cb6ae521 100644 --- a/controllers/status/status.go +++ b/controllers/status/status.go @@ -19,7 +19,13 @@ limitations under the License. package status import ( + "os" + "path/filepath" + + "github.com/blang/semver/v4" conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" + "github.com/operator-framework/api/pkg/lib/version" + "gopkg.in/yaml.v2" corev1 "k8s.io/api/core/v1" ) @@ -210,7 +216,136 @@ func RemoveComponentCondition(conditions *[]conditionsv1.Condition, component st conditionsv1.RemoveStatusCondition(conditions, conditionsv1.ConditionType(component+ReadySuffix)) } -// ModelRegistryStatus struct holds the status for the ModelRegistry component. +// +k8s:deepcopy-gen=true +type ComponentReleaseStatus struct { + Name string `json:"name,omitempty"` + Version version.OperatorVersion `json:"version,omitempty"` + RepoURL string `json:"repoURL,omitempty"` +} + +// +k8s:deepcopy-gen=true +type ComponentStatus struct { + Releases []ComponentReleaseStatus `json:"releases,omitempty"` +} + +// +k8s:deepcopy-gen=true +type CodeFlareStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type DashboardStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type WorkbenchesStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type ModelMeshServingStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type DataSciencePipelinesStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type KserveStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type KueueStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type RayStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type TrustyAIStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true type ModelRegistryStatus struct { RegistriesNamespace string `json:"registriesNamespace,omitempty"` + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type TrainingOperatorStatus struct { + ComponentStatus `json:",inline"` +} + +// +k8s:deepcopy-gen=true +type ComponentsStatus struct { + CodeFlare *CodeFlareStatus `json:"codeflare,omitempty"` + Dashboard *DashboardStatus `json:"dashboard,omitempty"` + DataSciencePipelines *DataSciencePipelinesStatus `json:"datasciencepipelines,omitempty"` + ModelMeshServing *ModelMeshServingStatus `json:"modelmeshserving,omitempty"` + ModelRegistry *ModelRegistryStatus `json:"modelregistry,omitempty"` + Kserve *KserveStatus `json:"kserve,omitempty"` + Kueue *KueueStatus `json:"kueue,omitempty"` + Ray *RayStatus `json:"ray,omitempty"` + TrustyAI *TrustyAIStatus `json:"trustyai,omitempty"` + TrainingOperator *TrainingOperatorStatus `json:"trainingoperator,omitempty"` + Workbenches *WorkbenchesStatus `json:"workbenches,omitempty"` +} + +// +k8s:deepcopy-gen=true +type ReleaseFileMeta struct { + Releases []ComponentReleaseStatusMeta `json:"releases,omitempty"` +} + +// +k8s:deepcopy-gen=true +type ComponentReleaseStatusMeta struct { + Name string `yaml:"name,omitempty"` + Version string `yaml:"version,omitempty"` + RepoURL string `yaml:"repoURL,omitempty"` +} + +// GetReleaseStatus reads odh_metadata.yaml file and parses release information. +// If version is not set or set to "", return empty slice along with error. +func GetReleaseStatus(defaultManifestPath string, componentName string) ([]ComponentReleaseStatus, error) { + var componentVersion semver.Version + var releaseInfo ReleaseFileMeta + var releaseStatus ComponentReleaseStatus + componentReleaseStatus := make([]ComponentReleaseStatus, 0) + + yamlData, err := os.ReadFile(filepath.Join(defaultManifestPath, componentName, "odh_metadata.yaml")) + if err != nil { + if os.IsNotExist(err) { + return nil, nil + } + return nil, err + } + + err = yaml.Unmarshal(yamlData, &releaseInfo) + if err != nil { + return nil, err + } + + for _, release := range releaseInfo.Releases { + componentVersion, err = semver.Parse(release.Version) + + if err != nil { + return nil, err + } + + releaseStatus = ComponentReleaseStatus{ + Name: release.Name, + Version: version.OperatorVersion{Version: componentVersion}, + RepoURL: release.RepoURL, + } + componentReleaseStatus = append(componentReleaseStatus, releaseStatus) + } + + return componentReleaseStatus, nil } diff --git a/controllers/status/zz_generated.deepcopy.go b/controllers/status/zz_generated.deepcopy.go new file mode 100644 index 00000000000..ddbf90d7e93 --- /dev/null +++ b/controllers/status/zz_generated.deepcopy.go @@ -0,0 +1,342 @@ +//go:build !ignore_autogenerated + +/* +Copyright 2023. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package status + +import () + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CodeFlareStatus) DeepCopyInto(out *CodeFlareStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CodeFlareStatus. +func (in *CodeFlareStatus) DeepCopy() *CodeFlareStatus { + if in == nil { + return nil + } + out := new(CodeFlareStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentReleaseStatus) DeepCopyInto(out *ComponentReleaseStatus) { + *out = *in + in.Version.DeepCopyInto(&out.Version) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentReleaseStatus. +func (in *ComponentReleaseStatus) DeepCopy() *ComponentReleaseStatus { + if in == nil { + return nil + } + out := new(ComponentReleaseStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentReleaseStatusMeta) DeepCopyInto(out *ComponentReleaseStatusMeta) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentReleaseStatusMeta. +func (in *ComponentReleaseStatusMeta) DeepCopy() *ComponentReleaseStatusMeta { + if in == nil { + return nil + } + out := new(ComponentReleaseStatusMeta) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentStatus) DeepCopyInto(out *ComponentStatus) { + *out = *in + if in.Releases != nil { + in, out := &in.Releases, &out.Releases + *out = make([]ComponentReleaseStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentStatus. +func (in *ComponentStatus) DeepCopy() *ComponentStatus { + if in == nil { + return nil + } + out := new(ComponentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentsStatus) DeepCopyInto(out *ComponentsStatus) { + *out = *in + if in.CodeFlare != nil { + in, out := &in.CodeFlare, &out.CodeFlare + *out = new(CodeFlareStatus) + (*in).DeepCopyInto(*out) + } + if in.Dashboard != nil { + in, out := &in.Dashboard, &out.Dashboard + *out = new(DashboardStatus) + (*in).DeepCopyInto(*out) + } + if in.DataSciencePipelines != nil { + in, out := &in.DataSciencePipelines, &out.DataSciencePipelines + *out = new(DataSciencePipelinesStatus) + (*in).DeepCopyInto(*out) + } + if in.ModelMeshServing != nil { + in, out := &in.ModelMeshServing, &out.ModelMeshServing + *out = new(ModelMeshServingStatus) + (*in).DeepCopyInto(*out) + } + if in.ModelRegistry != nil { + in, out := &in.ModelRegistry, &out.ModelRegistry + *out = new(ModelRegistryStatus) + (*in).DeepCopyInto(*out) + } + if in.Kserve != nil { + in, out := &in.Kserve, &out.Kserve + *out = new(KserveStatus) + (*in).DeepCopyInto(*out) + } + if in.Kueue != nil { + in, out := &in.Kueue, &out.Kueue + *out = new(KueueStatus) + (*in).DeepCopyInto(*out) + } + if in.Ray != nil { + in, out := &in.Ray, &out.Ray + *out = new(RayStatus) + (*in).DeepCopyInto(*out) + } + if in.TrustyAI != nil { + in, out := &in.TrustyAI, &out.TrustyAI + *out = new(TrustyAIStatus) + (*in).DeepCopyInto(*out) + } + if in.TrainingOperator != nil { + in, out := &in.TrainingOperator, &out.TrainingOperator + *out = new(TrainingOperatorStatus) + (*in).DeepCopyInto(*out) + } + if in.Workbenches != nil { + in, out := &in.Workbenches, &out.Workbenches + *out = new(WorkbenchesStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentsStatus. +func (in *ComponentsStatus) DeepCopy() *ComponentsStatus { + if in == nil { + return nil + } + out := new(ComponentsStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DashboardStatus) DeepCopyInto(out *DashboardStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardStatus. +func (in *DashboardStatus) DeepCopy() *DashboardStatus { + if in == nil { + return nil + } + out := new(DashboardStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DataSciencePipelinesStatus) DeepCopyInto(out *DataSciencePipelinesStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataSciencePipelinesStatus. +func (in *DataSciencePipelinesStatus) DeepCopy() *DataSciencePipelinesStatus { + if in == nil { + return nil + } + out := new(DataSciencePipelinesStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KserveStatus) DeepCopyInto(out *KserveStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KserveStatus. +func (in *KserveStatus) DeepCopy() *KserveStatus { + if in == nil { + return nil + } + out := new(KserveStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KueueStatus) DeepCopyInto(out *KueueStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KueueStatus. +func (in *KueueStatus) DeepCopy() *KueueStatus { + if in == nil { + return nil + } + out := new(KueueStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ModelMeshServingStatus) DeepCopyInto(out *ModelMeshServingStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ModelMeshServingStatus. +func (in *ModelMeshServingStatus) DeepCopy() *ModelMeshServingStatus { + if in == nil { + return nil + } + out := new(ModelMeshServingStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ModelRegistryStatus) DeepCopyInto(out *ModelRegistryStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ModelRegistryStatus. +func (in *ModelRegistryStatus) DeepCopy() *ModelRegistryStatus { + if in == nil { + return nil + } + out := new(ModelRegistryStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RayStatus) DeepCopyInto(out *RayStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RayStatus. +func (in *RayStatus) DeepCopy() *RayStatus { + if in == nil { + return nil + } + out := new(RayStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ReleaseFileMeta) DeepCopyInto(out *ReleaseFileMeta) { + *out = *in + if in.Releases != nil { + in, out := &in.Releases, &out.Releases + *out = make([]ComponentReleaseStatusMeta, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReleaseFileMeta. +func (in *ReleaseFileMeta) DeepCopy() *ReleaseFileMeta { + if in == nil { + return nil + } + out := new(ReleaseFileMeta) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TrainingOperatorStatus) DeepCopyInto(out *TrainingOperatorStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrainingOperatorStatus. +func (in *TrainingOperatorStatus) DeepCopy() *TrainingOperatorStatus { + if in == nil { + return nil + } + out := new(TrainingOperatorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TrustyAIStatus) DeepCopyInto(out *TrustyAIStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrustyAIStatus. +func (in *TrustyAIStatus) DeepCopy() *TrustyAIStatus { + if in == nil { + return nil + } + out := new(TrustyAIStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkbenchesStatus) DeepCopyInto(out *WorkbenchesStatus) { + *out = *in + in.ComponentStatus.DeepCopyInto(&out.ComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkbenchesStatus. +func (in *WorkbenchesStatus) DeepCopy() *WorkbenchesStatus { + if in == nil { + return nil + } + out := new(WorkbenchesStatus) + in.DeepCopyInto(out) + return out +} diff --git a/docs/api-overview.md b/docs/api-overview.md index 9c2e8971dde..66addcda2d8 100644 --- a/docs/api-overview.md +++ b/docs/api-overview.md @@ -413,22 +413,6 @@ _Appears in:_ | `trainingoperator` _[TrainingOperator](#trainingoperator)_ | Training Operator component configuration. | | | -#### ComponentsStatus - - - -ComponentsStatus defines the custom status of DataScienceCluster components. - - - -_Appears in:_ -- [DataScienceClusterStatus](#datascienceclusterstatus) - -| Field | Description | Default | Validation | -| --- | --- | --- | --- | -| `modelregistry` _[ModelRegistryStatus](#modelregistrystatus)_ | ModelRegistry component status | | | - - #### ControlPlaneSpec diff --git a/go.mod b/go.mod index 9b86d8e92c2..28cb6b8c825 100644 --- a/go.mod +++ b/go.mod @@ -59,10 +59,12 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/ompluscator/dynamic-struct v1.4.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.18.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect diff --git a/go.sum b/go.sum index 3b193384846..4fbf5689661 100644 --- a/go.sum +++ b/go.sum @@ -246,6 +246,8 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -262,6 +264,8 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/ompluscator/dynamic-struct v1.4.0 h1:I/Si9LZtItSwiTMe7vosEuIu2TKdOvWbE3R/lokpN4Q= +github.com/ompluscator/dynamic-struct v1.4.0/go.mod h1:ADQ1+6Ox1D+ntuNwTHyl1NvpAqY2lBXPSPbcO4CJdeA= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=