From cdf61377b72162ac2aeb8284df9a85e1abc105e3 Mon Sep 17 00:00:00 2001 From: Saravana Date: Thu, 9 Jan 2025 01:01:42 +0530 Subject: [PATCH] feat:Mapping component versions to RHOAI releases --- apis/components/v1alpha1/codeflare_types.go | 3 + apis/components/v1alpha1/dashboard_types.go | 2 + .../v1alpha1/datasciencepipelines_types.go | 2 + apis/components/v1alpha1/kserve_types.go | 2 + apis/components/v1alpha1/kueue_types.go | 2 + .../v1alpha1/modelcontroller_types.go | 2 + .../v1alpha1/modelmeshserving_types.go | 2 + .../v1alpha1/modelregistry_types.go | 2 + apis/components/v1alpha1/ray_types.go | 2 + .../v1alpha1/trainingoperator_types.go | 2 + apis/components/v1alpha1/trustyai_types.go | 2 + apis/components/v1alpha1/workbenches_types.go | 2 + controllers/components/codeflare/codeflare.go | 8 +++ controllers/components/dashboard/dashboard.go | 8 +++ .../datasciencepipelines.go | 12 +++- controllers/components/kserve/kserve.go | 9 +++ controllers/components/kueue/kueue.go | 8 +++ .../modelmeshserving/modelmeshserving.go | 8 +++ .../components/modelregistry/modelregistry.go | 8 +++ controllers/components/ray/ray.go | 8 +++ .../trainingoperator/trainingoperator.go | 8 +++ controllers/components/trustyai/trustyai.go | 8 +++ .../components/workbenches/workbenches.go | 8 +++ controllers/status/status.go | 64 +++++++++++++++++++ docs/api-overview.md | 13 ++++ 25 files changed, 193 insertions(+), 2 deletions(-) diff --git a/apis/components/v1alpha1/codeflare_types.go b/apis/components/v1alpha1/codeflare_types.go index 771121ee97e..0736dcb4ba7 100644 --- a/apis/components/v1alpha1/codeflare_types.go +++ b/apis/components/v1alpha1/codeflare_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -36,6 +37,7 @@ type CodeFlareCommonStatus struct { type CodeFlareStatus struct { common.Status `json:",inline"` CodeFlareCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } // +kubebuilder:object:root=true @@ -96,4 +98,5 @@ type DSCCodeFlare struct { type DSCCodeFlareStatus struct { common.ManagementSpec `json:",inline"` *CodeFlareCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/dashboard_types.go b/apis/components/v1alpha1/dashboard_types.go index b537f6ffc07..42a7bc2c8ff 100644 --- a/apis/components/v1alpha1/dashboard_types.go +++ b/apis/components/v1alpha1/dashboard_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -104,4 +105,5 @@ type DSCDashboard struct { type DSCDashboardStatus struct { common.ManagementSpec `json:",inline"` *DashboardCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/datasciencepipelines_types.go b/apis/components/v1alpha1/datasciencepipelines_types.go index 0af6338a874..e1f4e7c0c5a 100644 --- a/apis/components/v1alpha1/datasciencepipelines_types.go +++ b/apis/components/v1alpha1/datasciencepipelines_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -94,4 +95,5 @@ type DSCDataSciencePipelines struct { type DSCDataSciencePipelinesStatus struct { common.ManagementSpec `json:",inline"` *DataSciencePipelinesCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/kserve_types.go b/apis/components/v1alpha1/kserve_types.go index 3ae7714b8f5..21adf5f5b66 100644 --- a/apis/components/v1alpha1/kserve_types.go +++ b/apis/components/v1alpha1/kserve_types.go @@ -22,6 +22,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" ) const ( @@ -132,4 +133,5 @@ type DSCKserve struct { type DSCKserveStatus struct { common.ManagementSpec `json:",inline"` *KserveCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/kueue_types.go b/apis/components/v1alpha1/kueue_types.go index 9363b0c73b7..d0d01c281db 100644 --- a/apis/components/v1alpha1/kueue_types.go +++ b/apis/components/v1alpha1/kueue_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -95,4 +96,5 @@ type DSCKueue struct { type DSCKueueStatus struct { common.ManagementSpec `json:",inline"` *KueueCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/modelcontroller_types.go b/apis/components/v1alpha1/modelcontroller_types.go index 41e34af03b9..7f2ec711182 100644 --- a/apis/components/v1alpha1/modelcontroller_types.go +++ b/apis/components/v1alpha1/modelcontroller_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -79,6 +80,7 @@ func (s *ModelControllerMMSpec) GetDevFlags() *common.DevFlags { // ModelControllerStatus defines the observed state of ModelController type ModelControllerStatus struct { common.Status `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } // +kubebuilder:object:root=true diff --git a/apis/components/v1alpha1/modelmeshserving_types.go b/apis/components/v1alpha1/modelmeshserving_types.go index 5547bc32947..3ea41afe1ac 100644 --- a/apis/components/v1alpha1/modelmeshserving_types.go +++ b/apis/components/v1alpha1/modelmeshserving_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -95,4 +96,5 @@ type DSCModelMeshServing struct { type DSCModelMeshServingStatus struct { common.ManagementSpec `json:",inline"` *ModelMeshServingCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/modelregistry_types.go b/apis/components/v1alpha1/modelregistry_types.go index 3997fad78d7..8f9850c2450 100644 --- a/apis/components/v1alpha1/modelregistry_types.go +++ b/apis/components/v1alpha1/modelregistry_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -112,4 +113,5 @@ type DSCModelRegistry struct { type DSCModelRegistryStatus struct { common.ManagementSpec `json:",inline"` *ModelRegistryCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/ray_types.go b/apis/components/v1alpha1/ray_types.go index 3356ded2b64..9441dad3e98 100644 --- a/apis/components/v1alpha1/ray_types.go +++ b/apis/components/v1alpha1/ray_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -95,4 +96,5 @@ type DSCRay struct { type DSCRayStatus struct { common.ManagementSpec `json:",inline"` *RayCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/trainingoperator_types.go b/apis/components/v1alpha1/trainingoperator_types.go index 663e039677e..d3304177764 100644 --- a/apis/components/v1alpha1/trainingoperator_types.go +++ b/apis/components/v1alpha1/trainingoperator_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -95,4 +96,5 @@ type DSCTrainingOperator struct { type DSCTrainingOperatorStatus struct { common.ManagementSpec `json:",inline"` *TrainingOperatorCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/trustyai_types.go b/apis/components/v1alpha1/trustyai_types.go index 05f84f2c9aa..ebf4db99639 100644 --- a/apis/components/v1alpha1/trustyai_types.go +++ b/apis/components/v1alpha1/trustyai_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -95,4 +96,5 @@ type DSCTrustyAI struct { type DSCTrustyAIStatus struct { common.ManagementSpec `json:",inline"` *TrustyAICommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/apis/components/v1alpha1/workbenches_types.go b/apis/components/v1alpha1/workbenches_types.go index 968fc98e38d..4845d465f13 100644 --- a/apis/components/v1alpha1/workbenches_types.go +++ b/apis/components/v1alpha1/workbenches_types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -101,4 +102,5 @@ type DSCWorkbenches struct { type DSCWorkbenchesStatus struct { common.ManagementSpec `json:",inline"` *WorkbenchesCommonStatus `json:",inline"` + Releases []status.ComponentReleaseStatus `json:"releases,omitempty"` } diff --git a/controllers/components/codeflare/codeflare.go b/controllers/components/codeflare/codeflare.go index 486c4cd52cf..2d94cf5a923 100644 --- a/controllers/components/codeflare/codeflare.go +++ b/controllers/components/codeflare/codeflare.go @@ -85,6 +85,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.CodeFlare.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.CodeFlare.CodeFlareCommonStatus = nil + dsc.Status.Components.CodeFlare.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -97,6 +104,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.CodeFlare.CodeFlareCommonStatus = c.Status.CodeFlareCommonStatus.DeepCopy() + dsc.Status.Components.CodeFlare.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/dashboard/dashboard.go b/controllers/components/dashboard/dashboard.go index 2adf25580a3..bfee7de8322 100644 --- a/controllers/components/dashboard/dashboard.go +++ b/controllers/components/dashboard/dashboard.go @@ -75,6 +75,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.Dashboard.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.Dashboard.DashboardCommonStatus = nil + dsc.Status.Components.Dashboard.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -87,6 +94,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.Dashboard.DashboardCommonStatus = c.Status.DashboardCommonStatus.DeepCopy() + dsc.Status.Components.Dashboard.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/datasciencepipelines/datasciencepipelines.go b/controllers/components/datasciencepipelines/datasciencepipelines.go index 0b0274ce805..48229a71ada 100644 --- a/controllers/components/datasciencepipelines/datasciencepipelines.go +++ b/controllers/components/datasciencepipelines/datasciencepipelines.go @@ -17,7 +17,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" cr "github.com/opendatahub-io/opendatahub-operator/v2/pkg/componentsregistry" - "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + odhdeploy "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/annotations" ) @@ -63,7 +63,7 @@ func (s *componentHandler) Init(platform cluster.Platform) error { "IMAGESV2_ARGO_MLMDGRPC": "RELATED_IMAGE_ODH_MLMD_GRPC_SERVER_IMAGE", } - if err := deploy.ApplyParams(defaultPath.String(), imageParamMap); err != nil { + if err := odhdeploy.ApplyParams(defaultPath.String(), imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", defaultPath.String(), err) } @@ -97,6 +97,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.DataSciencePipelines.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.DataSciencePipelines.DataSciencePipelinesCommonStatus = nil + dsc.Status.Components.DataSciencePipelines.Releases = nil nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -105,10 +106,17 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl Message: "Not Available", } + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } + switch s.GetManagementState(dsc) { case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.DataSciencePipelines.DataSciencePipelinesCommonStatus = c.Status.DataSciencePipelinesCommonStatus.DeepCopy() + dsc.Status.Components.DataSciencePipelines.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/kserve/kserve.go b/controllers/components/kserve/kserve.go index ebbfd984148..30f461a18e6 100644 --- a/controllers/components/kserve/kserve.go +++ b/controllers/components/kserve/kserve.go @@ -17,6 +17,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" cr "github.com/opendatahub-io/opendatahub-operator/v2/pkg/componentsregistry" + odhdeploy "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/annotations" ) @@ -83,6 +84,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.Kserve.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.Kserve.KserveCommonStatus = nil + dsc.Status.Components.Kserve.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, componentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -95,6 +103,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.Kserve.KserveCommonStatus = c.Status.KserveCommonStatus.DeepCopy() + dsc.Status.Components.Kserve.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/kueue/kueue.go b/controllers/components/kueue/kueue.go index 8470a055a99..83d77735441 100644 --- a/controllers/components/kueue/kueue.go +++ b/controllers/components/kueue/kueue.go @@ -85,6 +85,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.Kueue.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.Kueue.KueueCommonStatus = nil + dsc.Status.Components.Kueue.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -97,6 +104,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.Kueue.KueueCommonStatus = c.Status.KueueCommonStatus.DeepCopy() + dsc.Status.Components.Kueue.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/modelmeshserving/modelmeshserving.go b/controllers/components/modelmeshserving/modelmeshserving.go index 51de78e481c..369f2f2c4f7 100644 --- a/controllers/components/modelmeshserving/modelmeshserving.go +++ b/controllers/components/modelmeshserving/modelmeshserving.go @@ -86,6 +86,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.ModelMeshServing.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.ModelMeshServing.ModelMeshServingCommonStatus = nil + dsc.Status.Components.ModelMeshServing.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -98,6 +105,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.ModelMeshServing.ModelMeshServingCommonStatus = c.Status.ModelMeshServingCommonStatus.DeepCopy() + dsc.Status.Components.ModelMeshServing.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/modelregistry/modelregistry.go b/controllers/components/modelregistry/modelregistry.go index 36c4f912ebb..feeb791dafe 100644 --- a/controllers/components/modelregistry/modelregistry.go +++ b/controllers/components/modelregistry/modelregistry.go @@ -83,6 +83,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.ModelRegistry.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.ModelRegistry.ModelRegistryCommonStatus = nil + dsc.Status.Components.ModelRegistry.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -95,6 +102,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.ModelRegistry.ModelRegistryCommonStatus = c.Status.ModelRegistryCommonStatus.DeepCopy() + dsc.Status.Components.ModelRegistry.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/ray/ray.go b/controllers/components/ray/ray.go index f479e307684..de49f5e6c36 100644 --- a/controllers/components/ray/ray.go +++ b/controllers/components/ray/ray.go @@ -84,6 +84,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.Ray.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.Ray.RayCommonStatus = nil + dsc.Status.Components.Ray.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -96,6 +103,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.Ray.RayCommonStatus = c.Status.RayCommonStatus.DeepCopy() + dsc.Status.Components.Ray.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/trainingoperator/trainingoperator.go b/controllers/components/trainingoperator/trainingoperator.go index fae79280141..751e3ed07c1 100644 --- a/controllers/components/trainingoperator/trainingoperator.go +++ b/controllers/components/trainingoperator/trainingoperator.go @@ -84,6 +84,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.TrainingOperator.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.TrainingOperator.TrainingOperatorCommonStatus = nil + dsc.Status.Components.TrainingOperator.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -96,6 +103,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.TrainingOperator.TrainingOperatorCommonStatus = c.Status.TrainingOperatorCommonStatus.DeepCopy() + dsc.Status.Components.TrainingOperator.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/trustyai/trustyai.go b/controllers/components/trustyai/trustyai.go index 0f5c33c7a6e..b0ec37828ab 100644 --- a/controllers/components/trustyai/trustyai.go +++ b/controllers/components/trustyai/trustyai.go @@ -92,6 +92,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.TrustyAI.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.TrustyAI.TrustyAICommonStatus = nil + dsc.Status.Components.TrustyAI.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -104,6 +111,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.TrustyAI.TrustyAICommonStatus = c.Status.TrustyAICommonStatus.DeepCopy() + dsc.Status.Components.TrustyAI.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/components/workbenches/workbenches.go b/controllers/components/workbenches/workbenches.go index 795549a2355..7516987fbb6 100644 --- a/controllers/components/workbenches/workbenches.go +++ b/controllers/components/workbenches/workbenches.go @@ -83,6 +83,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[s.GetName()] = false dsc.Status.Components.Workbenches.ManagementSpec.ManagementState = s.GetManagementState(dsc) dsc.Status.Components.Workbenches.WorkbenchesCommonStatus = nil + dsc.Status.Components.Workbenches.Releases = nil + + releases, err := status.GetReleaseStatus(odhdeploy.DefaultManifestPath, ComponentName) + + if err != nil { + return err + } nc := conditionsv1.Condition{ Type: conditionsv1.ConditionType(s.GetName() + status.ReadySuffix), @@ -95,6 +102,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[s.GetName()] = true dsc.Status.Components.Workbenches.WorkbenchesCommonStatus = c.Status.WorkbenchesCommonStatus.DeepCopy() + dsc.Status.Components.Workbenches.Releases = releases if rc := meta.FindStatusCondition(c.Status.Conditions, status.ConditionTypeReady); rc != nil { nc.Status = corev1.ConditionStatus(rc.Status) diff --git a/controllers/status/status.go b/controllers/status/status.go index 664c8bbfcff..bc8e616b0dc 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" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -242,3 +248,61 @@ func SetStatusCondition(obj common.WithStatus, condition metav1.Condition) bool s := obj.GetStatus() return meta.SetStatusCondition(&s.Conditions, condition) } + +// +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"` +} + +// +k8s:deepcopy-gen=true +type ComponentReleaseStatus struct { + Name string `json:"name,omitempty"` + Version version.OperatorVersion `json:"version,omitempty"` + RepoURL string `json:"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/docs/api-overview.md b/docs/api-overview.md index cc5445e6a7a..4ff9d27b2e6 100644 --- a/docs/api-overview.md +++ b/docs/api-overview.md @@ -144,6 +144,7 @@ _Appears in:_ | `phase` _string_ | | | | | `observedGeneration` _integer_ | | | | | `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#condition-v1-meta) array_ | | | | +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCCodeFlare @@ -177,6 +178,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCDashboard @@ -210,6 +212,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCDataSciencePipelines @@ -243,6 +246,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCKserve @@ -279,6 +283,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCKueue @@ -312,6 +317,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCModelMeshServing @@ -345,6 +351,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCModelRegistry @@ -379,6 +386,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCRay @@ -412,6 +420,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCTrainingOperator @@ -445,6 +454,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCTrustyAI @@ -478,6 +488,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### DSCWorkbenches @@ -511,6 +522,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `managementState` _[ManagementState](#managementstate)_ | Set to one of the following values:

- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so

- "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 | | Enum: [Managed Removed]
| +| `releases` _ComponentReleaseStatus array_ | | | | #### Dashboard @@ -1081,6 +1093,7 @@ _Appears in:_ | `phase` _string_ | | | | | `observedGeneration` _integer_ | | | | | `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#condition-v1-meta) array_ | | | | +| `releases` _ComponentReleaseStatus array_ | | | | #### ModelMeshServing