diff --git a/apis/components/v1alpha1/codeflare_types.go b/apis/components/v1alpha1/codeflare_types.go index 9152db29fd0..da89a34f25f 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 14afd14337b..69be47bc3c3 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 da10f02cc8c..ae7c42f80d9 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" ) @@ -96,4 +97,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 b69d88aed83..da051c177a3 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 ( @@ -134,4 +135,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 e0be9ff57ac..81bd2a54ba4 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 9de70bb81ae..884cb5923dd 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" ) @@ -80,6 +81,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 e28649a417c..00ac03c1ff5 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 0d653b7d355..379024950ef 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 a51c29e3cd4..3e044620956 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 2d76ca78e6e..4ef8c00d1d4 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 9ac2652fcc1..f64134f9f29 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 4ea01ce7bbc..cb2f82227a0 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 0920a8b45b1..697aa0318b2 100644 --- a/controllers/components/codeflare/codeflare.go +++ b/controllers/components/codeflare/codeflare.go @@ -73,6 +73,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -85,6 +92,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 7070c87d489..ea4f05f0d6f 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[LegacyComponentNameUpstream] = 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: ReadyConditionType, @@ -87,6 +94,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentNameUpstream] = 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 7ee17348a28..ba664d6294c 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" ) @@ -39,7 +39,7 @@ func (s *componentHandler) GetManagementState(dsc *dscv1.DataScienceCluster) ope } func (s *componentHandler) Init(_ cluster.Platform) error { - if err := deploy.ApplyParams(paramsPath().String(), imageParamMap); err != nil { + if err := odhdeploy.ApplyParams(paramsPath().String(), imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", paramsPath(), err) } @@ -73,6 +73,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -81,10 +82,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[LegacyComponentName] = 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 8c1ddb51bc8..dbbccf7860d 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" ) @@ -85,6 +86,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -97,6 +105,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 23287e9898f..695c269c596 100644 --- a/controllers/components/kueue/kueue.go +++ b/controllers/components/kueue/kueue.go @@ -73,6 +73,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -85,6 +92,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 22bbb6aceea..2f5cdf0d39e 100644 --- a/controllers/components/modelmeshserving/modelmeshserving.go +++ b/controllers/components/modelmeshserving/modelmeshserving.go @@ -75,6 +75,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -87,6 +94,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 31b13a1ed2c..56529224a6d 100644 --- a/controllers/components/modelregistry/modelregistry.go +++ b/controllers/components/modelregistry/modelregistry.go @@ -75,6 +75,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -87,6 +94,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 551961a84ab..bb112a74616 100644 --- a/controllers/components/ray/ray.go +++ b/controllers/components/ray/ray.go @@ -73,6 +73,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -85,6 +92,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 316d686b0c2..05583e5ab8e 100644 --- a/controllers/components/trainingoperator/trainingoperator.go +++ b/controllers/components/trainingoperator/trainingoperator.go @@ -72,6 +72,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -84,6 +91,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 2dd4c138eb1..f25873f381b 100644 --- a/controllers/components/trustyai/trustyai.go +++ b/controllers/components/trustyai/trustyai.go @@ -75,6 +75,13 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl dsc.Status.InstalledComponents[LegacyComponentName] = 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: ReadyConditionType, @@ -87,6 +94,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 9e2f95cc8f3..671fa0c4164 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[LegacyComponentName] = 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: ReadyConditionType, @@ -95,6 +102,7 @@ func (s *componentHandler) UpdateDSCStatus(dsc *dscv1.DataScienceCluster, obj cl case operatorv1.Managed: dsc.Status.InstalledComponents[LegacyComponentName] = 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 926028e7d10..f3402ef2f1e 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 @@ -1085,6 +1097,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