diff --git a/apis/common/types.go b/apis/common/types.go index 44542d158957..473f288e0c85 100644 --- a/apis/common/types.go +++ b/apis/common/types.go @@ -2,6 +2,7 @@ package common import ( operatorv1 "github.com/openshift/api/operator/v1" + "github.com/operator-framework/api/pkg/lib/version" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -82,3 +83,12 @@ type PlatformObject interface { client.Object WithStatus } + +type Platform string + +// Release includes information on operator version and platform +// +kubebuilder:object:generate=true +type Release struct { + Name Platform `json:"name,omitempty"` + Version version.OperatorVersion `json:"version,omitempty"` +} diff --git a/apis/common/zz_generated.deepcopy.go b/apis/common/zz_generated.deepcopy.go index b55b115b3541..6c981a98ca36 100644 --- a/apis/common/zz_generated.deepcopy.go +++ b/apis/common/zz_generated.deepcopy.go @@ -79,6 +79,22 @@ func (in *ManagementSpec) DeepCopy() *ManagementSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Release) DeepCopyInto(out *Release) { + *out = *in + in.Version.DeepCopyInto(&out.Version) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Release. +func (in *Release) DeepCopy() *Release { + if in == nil { + return nil + } + out := new(Release) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Status) DeepCopyInto(out *Status) { *out = *in diff --git a/apis/datasciencecluster/v1/datasciencecluster_types.go b/apis/datasciencecluster/v1/datasciencecluster_types.go index fd5956758a2f..18bb445f0d27 100644 --- a/apis/datasciencecluster/v1/datasciencecluster_types.go +++ b/apis/datasciencecluster/v1/datasciencecluster_types.go @@ -17,12 +17,12 @@ limitations under the License. package v1 import ( + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" - "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" ) // DataScienceClusterSpec defines the desired state of the cluster. @@ -134,7 +134,7 @@ type DataScienceClusterStatus struct { Components ComponentsStatus `json:"components"` // Version and release type - Release cluster.Release `json:"release,omitempty"` + Release common.Release `json:"release,omitempty"` } // +kubebuilder:object:root=true diff --git a/apis/dscinitialization/v1/dscinitialization_types.go b/apis/dscinitialization/v1/dscinitialization_types.go index 7fcf7bb273d1..d8f078401511 100644 --- a/apis/dscinitialization/v1/dscinitialization_types.go +++ b/apis/dscinitialization/v1/dscinitialization_types.go @@ -17,6 +17,7 @@ limitations under the License. package v1 import ( + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" serviceApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/services/v1alpha1" operatorv1 "github.com/openshift/api/operator/v1" conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" @@ -24,7 +25,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1" - "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" ) // +operator-sdk:csv:customresourcedefinitions:order=1 @@ -109,7 +109,7 @@ type DSCInitializationStatus struct { ErrorMessage string `json:"errorMessage,omitempty"` // Version and release type - Release cluster.Release `json:"release,omitempty"` + Release common.Release `json:"release,omitempty"` } //+kubebuilder:object:root=true diff --git a/controllers/components/codeflare/codeflare.go b/controllers/components/codeflare/codeflare.go index 0920a8b45b17..1406097be72a 100644 --- a/controllers/components/codeflare/codeflare.go +++ b/controllers/components/codeflare/codeflare.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" @@ -56,7 +55,7 @@ func (s *componentHandler) NewCRObject(dsc *dscv1.DataScienceCluster) common.Pla } } -func (s *componentHandler) Init(_ cluster.Platform) error { +func (s *componentHandler) Init(_ common.Platform) error { if err := odhdeploy.ApplyParams(paramsPath, imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", paramsPath, err) } diff --git a/controllers/components/dashboard/dashboard.go b/controllers/components/dashboard/dashboard.go index 7070c87d4897..1913f7fe6d36 100644 --- a/controllers/components/dashboard/dashboard.go +++ b/controllers/components/dashboard/dashboard.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" @@ -38,7 +37,7 @@ func (s *componentHandler) GetManagementState(dsc *dscv1.DataScienceCluster) ope return operatorv1.Removed } -func (s *componentHandler) Init(platform cluster.Platform) error { +func (s *componentHandler) Init(platform common.Platform) error { mi := defaultManifestInfo(platform) if err := odhdeploy.ApplyParams(mi.String(), imagesMap); err != nil { diff --git a/controllers/components/dashboard/dashboard_support.go b/controllers/components/dashboard/dashboard_support.go index 70c59cd22648..8f14f34dbded 100644 --- a/controllers/components/dashboard/dashboard_support.go +++ b/controllers/components/dashboard/dashboard_support.go @@ -7,6 +7,7 @@ import ( conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" @@ -29,28 +30,28 @@ const ( ) var ( - adminGroups = map[cluster.Platform]string{ + adminGroups = map[common.Platform]string{ cluster.SelfManagedRhoai: "rhods-admins", cluster.ManagedRhoai: "dedicated-admins", cluster.OpenDataHub: "odh-admins", cluster.Unknown: "odh-admins", } - sectionTitle = map[cluster.Platform]string{ + sectionTitle = map[common.Platform]string{ cluster.SelfManagedRhoai: "OpenShift Self Managed Services", cluster.ManagedRhoai: "OpenShift Managed Services", cluster.OpenDataHub: "OpenShift Open Data Hub", cluster.Unknown: "OpenShift Open Data Hub", } - baseConsoleURL = map[cluster.Platform]string{ + baseConsoleURL = map[common.Platform]string{ cluster.SelfManagedRhoai: "https://rhods-dashboard-", cluster.ManagedRhoai: "https://rhods-dashboard-", cluster.OpenDataHub: "https://odh-dashboard-", cluster.Unknown: "https://odh-dashboard-", } - overlaysSourcePaths = map[cluster.Platform]string{ + overlaysSourcePaths = map[common.Platform]string{ cluster.SelfManagedRhoai: "/rhoai/onprem", cluster.ManagedRhoai: "/rhoai/addon", cluster.OpenDataHub: "/odh", @@ -62,7 +63,7 @@ var ( } ) -func defaultManifestInfo(p cluster.Platform) odhtypes.ManifestInfo { +func defaultManifestInfo(p common.Platform) odhtypes.ManifestInfo { return odhtypes.ManifestInfo{ Path: odhdeploy.DefaultManifestPath, ContextDir: ComponentName, @@ -70,7 +71,7 @@ func defaultManifestInfo(p cluster.Platform) odhtypes.ManifestInfo { } } -func computeKustomizeVariable(ctx context.Context, cli client.Client, platform cluster.Platform, dscispec *dsciv1.DSCInitializationSpec) (map[string]string, error) { +func computeKustomizeVariable(ctx context.Context, cli client.Client, platform common.Platform, dscispec *dsciv1.DSCInitializationSpec) (map[string]string, error) { consoleLinkDomain, err := cluster.GetDomain(ctx, cli) if err != nil { return nil, fmt.Errorf("error getting console route URL %s : %w", consoleLinkDomain, err) diff --git a/controllers/components/datasciencepipelines/datasciencepipelines.go b/controllers/components/datasciencepipelines/datasciencepipelines.go index 7ee17348a28a..9755e4b3edf4 100644 --- a/controllers/components/datasciencepipelines/datasciencepipelines.go +++ b/controllers/components/datasciencepipelines/datasciencepipelines.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/annotations" @@ -38,7 +37,7 @@ func (s *componentHandler) GetManagementState(dsc *dscv1.DataScienceCluster) ope return operatorv1.Removed } -func (s *componentHandler) Init(_ cluster.Platform) error { +func (s *componentHandler) Init(_ common.Platform) error { if err := deploy.ApplyParams(paramsPath().String(), imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", paramsPath(), err) } diff --git a/controllers/components/datasciencepipelines/datasciencepipelines_support.go b/controllers/components/datasciencepipelines/datasciencepipelines_support.go index ea11c2e87262..1fc56a60b0bf 100644 --- a/controllers/components/datasciencepipelines/datasciencepipelines_support.go +++ b/controllers/components/datasciencepipelines/datasciencepipelines_support.go @@ -3,6 +3,7 @@ package datasciencepipelines import ( conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" @@ -35,7 +36,7 @@ var ( "IMAGES_MLMDGRPC": "RELATED_IMAGE_ODH_MLMD_GRPC_SERVER_IMAGE", } - overlaysSourcePaths = map[cluster.Platform]string{ + overlaysSourcePaths = map[common.Platform]string{ cluster.SelfManagedRhoai: "overlays/rhoai", cluster.ManagedRhoai: "overlays/rhoai", cluster.OpenDataHub: "overlays/odh", @@ -51,7 +52,7 @@ func paramsPath() types.ManifestInfo { } } -func manifestPath(p cluster.Platform) types.ManifestInfo { +func manifestPath(p common.Platform) types.ManifestInfo { return types.ManifestInfo{ Path: odhdeploy.DefaultManifestPath, ContextDir: ComponentName, diff --git a/controllers/components/kserve/kserve.go b/controllers/components/kserve/kserve.go index 8c1ddb51bc81..e52a0a107583 100644 --- a/controllers/components/kserve/kserve.go +++ b/controllers/components/kserve/kserve.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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/metadata/annotations" ) @@ -42,7 +41,7 @@ func init() { //nolint:gochecknoinits } // Init for set images. -func (s *componentHandler) Init(platform cluster.Platform) error { +func (s *componentHandler) Init(platform common.Platform) error { return nil } diff --git a/controllers/components/kueue/kueue.go b/controllers/components/kueue/kueue.go index 23287e9898fd..af285c3a0b03 100644 --- a/controllers/components/kueue/kueue.go +++ b/controllers/components/kueue/kueue.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" @@ -56,7 +55,7 @@ func (s *componentHandler) NewCRObject(dsc *dscv1.DataScienceCluster) common.Pla } } -func (s *componentHandler) Init(platform cluster.Platform) error { +func (s *componentHandler) Init(platform common.Platform) error { if err := odhdeploy.ApplyParams(manifestsPath().String(), imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", manifestsPath(), err) } diff --git a/controllers/components/modelcontroller/modelcontroller.go b/controllers/components/modelcontroller/modelcontroller.go index 234281939efc..5ca91c61aea2 100644 --- a/controllers/components/modelcontroller/modelcontroller.go +++ b/controllers/components/modelcontroller/modelcontroller.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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/componentsregistry" odhdeploy "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/annotations" @@ -76,7 +75,7 @@ func (s *componentHandler) NewCRObject(dsc *dscv1.DataScienceCluster) common.Pla } // Init for set images. -func (s *componentHandler) Init(_ cluster.Platform) error { +func (s *componentHandler) Init(_ common.Platform) error { // Update image parameters if err := odhdeploy.ApplyParams(manifestsPath().String(), imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", manifestsPath(), err) diff --git a/controllers/components/modelmeshserving/modelmeshserving.go b/controllers/components/modelmeshserving/modelmeshserving.go index 22bbb6aceea8..bc0374cf182f 100644 --- a/controllers/components/modelmeshserving/modelmeshserving.go +++ b/controllers/components/modelmeshserving/modelmeshserving.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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/componentsregistry" odhdeploy "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/annotations" @@ -38,7 +37,7 @@ func (s *componentHandler) GetManagementState(dsc *dscv1.DataScienceCluster) ope return operatorv1.Removed } -func (s *componentHandler) Init(_ cluster.Platform) error { +func (s *componentHandler) Init(_ common.Platform) error { // Update image parameters if err := odhdeploy.ApplyParams(manifestsPath().String(), imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", manifestsPath(), err) diff --git a/controllers/components/modelregistry/modelregistry.go b/controllers/components/modelregistry/modelregistry.go index 31b13a1ed2cb..98f72e2c26e0 100644 --- a/controllers/components/modelregistry/modelregistry.go +++ b/controllers/components/modelregistry/modelregistry.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" @@ -38,7 +37,7 @@ func (s *componentHandler) GetManagementState(dsc *dscv1.DataScienceCluster) ope return operatorv1.Removed } -func (s *componentHandler) Init(_ cluster.Platform) error { +func (s *componentHandler) Init(_ common.Platform) error { mi := baseManifestInfo(BaseManifestsSourcePath) if err := odhdeploy.ApplyParams(mi.String(), imagesMap, extraParamsMap); err != nil { diff --git a/controllers/components/ray/ray.go b/controllers/components/ray/ray.go index 551961a84ab9..47777d8f48b4 100644 --- a/controllers/components/ray/ray.go +++ b/controllers/components/ray/ray.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" @@ -56,7 +55,7 @@ func (s *componentHandler) NewCRObject(dsc *dscv1.DataScienceCluster) common.Pla } } -func (s *componentHandler) Init(_ cluster.Platform) error { +func (s *componentHandler) Init(_ common.Platform) error { if err := odhdeploy.ApplyParams(manifestPath().String(), imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", manifestPath(), err) } diff --git a/controllers/components/trainingoperator/trainingoperator.go b/controllers/components/trainingoperator/trainingoperator.go index 316d686b0c20..46c57fd38fac 100644 --- a/controllers/components/trainingoperator/trainingoperator.go +++ b/controllers/components/trainingoperator/trainingoperator.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" @@ -55,7 +54,7 @@ func (s *componentHandler) NewCRObject(dsc *dscv1.DataScienceCluster) common.Pla } } -func (s *componentHandler) Init(platform cluster.Platform) error { +func (s *componentHandler) Init(platform common.Platform) error { if err := odhdeploy.ApplyParams(manifestPath().String(), imageParamMap); err != nil { return fmt.Errorf("failed to update images on path %s: %w", manifestPath(), err) } diff --git a/controllers/components/trustyai/trustyai.go b/controllers/components/trustyai/trustyai.go index 2dd4c138eb15..31cdbc9b67be 100644 --- a/controllers/components/trustyai/trustyai.go +++ b/controllers/components/trustyai/trustyai.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" @@ -56,7 +55,7 @@ func (s *componentHandler) NewCRObject(dsc *dscv1.DataScienceCluster) common.Pla } } -func (s *componentHandler) Init(platform cluster.Platform) error { +func (s *componentHandler) Init(platform common.Platform) error { mp := manifestsPath(platform) if err := odhdeploy.ApplyParams(mp.String(), imageParamMap); err != nil { diff --git a/controllers/components/trustyai/trustyai_support.go b/controllers/components/trustyai/trustyai_support.go index f758e443c576..6f85425f13e3 100644 --- a/controllers/components/trustyai/trustyai_support.go +++ b/controllers/components/trustyai/trustyai_support.go @@ -3,6 +3,7 @@ package trustyai import ( conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" @@ -27,7 +28,7 @@ var ( "trustyaiOperatorImage": "RELATED_IMAGE_ODH_TRUSTYAI_SERVICE_OPERATOR_IMAGE", } - overlaysSourcePaths = map[cluster.Platform]string{ + overlaysSourcePaths = map[common.Platform]string{ cluster.SelfManagedRhoai: "/overlays/rhoai", cluster.ManagedRhoai: "/overlays/rhoai", cluster.OpenDataHub: "/overlays/odh", @@ -35,7 +36,7 @@ var ( } ) -func manifestsPath(p cluster.Platform) types.ManifestInfo { +func manifestsPath(p common.Platform) types.ManifestInfo { return types.ManifestInfo{ Path: odhdeploy.DefaultManifestPath, ContextDir: ComponentName, diff --git a/controllers/components/workbenches/workbenches.go b/controllers/components/workbenches/workbenches.go index 9e2f95cc8f32..a3087819ce4d 100644 --- a/controllers/components/workbenches/workbenches.go +++ b/controllers/components/workbenches/workbenches.go @@ -15,7 +15,6 @@ import ( componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" "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" @@ -56,7 +55,7 @@ func (s *componentHandler) NewCRObject(dsc *dscv1.DataScienceCluster) common.Pla } } -func (s *componentHandler) Init(platform cluster.Platform) error { +func (s *componentHandler) Init(platform common.Platform) error { nbcManifestInfo := notebookControllerManifestInfo(notebookControllerManifestSourcePath) if err := odhdeploy.ApplyParams(nbcManifestInfo.String(), map[string]string{ "odh-notebook-controller-image": "RELATED_IMAGE_ODH_NOTEBOOK_CONTROLLER_IMAGE", diff --git a/controllers/dscinitialization/utils.go b/controllers/dscinitialization/utils.go index 5c00a5f4215c..2b6678be823f 100644 --- a/controllers/dscinitialization/utils.go +++ b/controllers/dscinitialization/utils.go @@ -22,6 +22,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" logf "sigs.k8s.io/controller-runtime/pkg/log" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" @@ -43,7 +44,7 @@ var ( // - 2. Patch monitoring namespace // - 3. Network Policies 'opendatahub' that allow traffic between the ODH namespaces // - 4. ConfigMap 'odh-common-config'. -func (r *DSCInitializationReconciler) createOperatorResource(ctx context.Context, dscInit *dsciv1.DSCInitialization, platform cluster.Platform) error { +func (r *DSCInitializationReconciler) createOperatorResource(ctx context.Context, dscInit *dsciv1.DSCInitialization, platform common.Platform) error { log := logf.FromContext(ctx) if err := r.appNamespaceHandler(ctx, dscInit, platform); err != nil { @@ -75,7 +76,7 @@ func (r *DSCInitializationReconciler) createOperatorResource(ctx context.Context return nil } -func (r *DSCInitializationReconciler) appNamespaceHandler(ctx context.Context, dscInit *dsciv1.DSCInitialization, platform cluster.Platform) error { +func (r *DSCInitializationReconciler) appNamespaceHandler(ctx context.Context, dscInit *dsciv1.DSCInitialization, platform common.Platform) error { log := logf.FromContext(ctx) nsList := &corev1.NamespaceList{} @@ -115,7 +116,7 @@ func (r *DSCInitializationReconciler) appNamespaceHandler(ctx context.Context, d } } -func (r *DSCInitializationReconciler) createAppNamespace(ctx context.Context, nsName string, platform cluster.Platform, extraLabel ...map[string]string) error { +func (r *DSCInitializationReconciler) createAppNamespace(ctx context.Context, nsName string, platform common.Platform, extraLabel ...map[string]string) error { desiredDefaultNS := &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{Name: nsName}, } @@ -172,7 +173,7 @@ func (r *DSCInitializationReconciler) patchMonitoringNS(ctx context.Context, dsc func (r *DSCInitializationReconciler) reconcileDefaultNetworkPolicy( ctx context.Context, dscInit *dsciv1.DSCInitialization, - platform cluster.Platform, + platform common.Platform, ) error { log := logf.FromContext(ctx) name := dscInit.Spec.ApplicationsNamespace diff --git a/main.go b/main.go index 44b240f7d91e..8563ac4f8696 100644 --- a/main.go +++ b/main.go @@ -60,6 +60,7 @@ import ( ctrlmetrics "sigs.k8s.io/controller-runtime/pkg/metrics/server" ctrlwebhook "sigs.k8s.io/controller-runtime/pkg/webhook" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" @@ -133,7 +134,7 @@ func init() { //nolint:gochecknoinits utilruntime.Must(templatev1.Install(scheme)) } -func initComponents(_ context.Context, p cluster.Platform) error { +func initComponents(_ context.Context, p common.Platform) error { return cr.ForEach(func(ch cr.ComponentHandler) error { return ch.Init(p) }) @@ -454,7 +455,7 @@ func main() { //nolint:funlen,maintidx,gocyclo } } -func getCommonCache(ctx context.Context, cli client.Client, platform cluster.Platform) (map[string]cache.Config, error) { +func getCommonCache(ctx context.Context, cli client.Client, platform common.Platform) (map[string]cache.Config, error) { namespaceConfigs := map[string]cache.Config{} // newtowkrpolicy need operator namespace operatorNs, err := cluster.GetOperatorNamespace() @@ -495,7 +496,7 @@ func getCommonCache(ctx context.Context, cli client.Client, platform cluster.Pla return namespaceConfigs, nil } -func createSecretCacheConfig(ctx context.Context, cli client.Client, platform cluster.Platform) (map[string]cache.Config, error) { +func createSecretCacheConfig(ctx context.Context, cli client.Client, platform common.Platform) (map[string]cache.Config, error) { namespaceConfigs := map[string]cache.Config{ "istio-system": {}, // for both knative-serving-cert and default-modelregistry-cert, as an easy workarond, to watch both in this namespace "openshift-ingress": {}, @@ -511,7 +512,7 @@ func createSecretCacheConfig(ctx context.Context, cli client.Client, platform cl return namespaceConfigs, nil } -func createODHGeneralCacheConfig(ctx context.Context, cli client.Client, platform cluster.Platform) (map[string]cache.Config, error) { +func createODHGeneralCacheConfig(ctx context.Context, cli client.Client, platform common.Platform) (map[string]cache.Config, error) { namespaceConfigs := map[string]cache.Config{ "istio-system": {}, // for serivcemonitor: data-science-smcp-pilot-monitor } diff --git a/pkg/cluster/cluster_config.go b/pkg/cluster/cluster_config.go index 2afbbdf1a637..a9b7172d4726 100644 --- a/pkg/cluster/cluster_config.go +++ b/pkg/cluster/cluster_config.go @@ -20,18 +20,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" logf "sigs.k8s.io/controller-runtime/pkg/log" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster/gvk" ) -type Platform string - -// Release includes information on operator version and platform -// +kubebuilder:object:generate=true -type Release struct { - Name Platform `json:"name,omitempty"` - Version version.OperatorVersion `json:"version,omitempty"` -} - type ClusterInfo struct { Type string `json:"type,omitempty"` // openshift , TODO: can be other value if we later support other type Version version.OperatorVersion `json:"version,omitempty"` @@ -39,7 +31,7 @@ type ClusterInfo struct { var clusterConfig struct { Namespace string - Release Release + Release common.Release ClusterInfo ClusterInfo } @@ -84,7 +76,7 @@ func GetOperatorNamespace() (string, error) { return clusterConfig.Namespace, nil } -func GetRelease() Release { +func GetRelease() common.Release { return clusterConfig.Release } @@ -169,8 +161,8 @@ func GetClusterServiceVersion(ctx context.Context, c client.Client, namespace st } // detectSelfManaged detects if it is Self Managed Rhoai or OpenDataHub. -func detectSelfManaged(ctx context.Context, cli client.Client) (Platform, error) { - variants := map[string]Platform{ +func detectSelfManaged(ctx context.Context, cli client.Client) (common.Platform, error) { + variants := map[string]common.Platform{ "opendatahub-operator": OpenDataHub, "rhods-operator": SelfManagedRhoai, } @@ -189,7 +181,7 @@ func detectSelfManaged(ctx context.Context, cli client.Client) (Platform, error) } // detectManagedRhoai checks if catsrc CR add-on exists ManagedRhoai. -func detectManagedRhoai(ctx context.Context, cli client.Client) (Platform, error) { +func detectManagedRhoai(ctx context.Context, cli client.Client) (common.Platform, error) { catalogSource := &ofapiv1alpha1.CatalogSource{} operatorNs, err := GetOperatorNamespace() if err != nil { @@ -202,7 +194,7 @@ func detectManagedRhoai(ctx context.Context, cli client.Client) (Platform, error return ManagedRhoai, nil } -func getPlatform(ctx context.Context, cli client.Client) (Platform, error) { +func getPlatform(ctx context.Context, cli client.Client) (common.Platform, error) { switch os.Getenv("ODH_PLATFORM_TYPE") { case "OpenDataHub": return OpenDataHub, nil @@ -223,8 +215,8 @@ func getPlatform(ctx context.Context, cli client.Client) (Platform, error) { } } -func getRelease(ctx context.Context, cli client.Client) (Release, error) { - initRelease := Release{ +func getRelease(ctx context.Context, cli client.Client) (common.Release, error) { + initRelease := common.Release{ // dummy version set to name "", version 0.0.0 Version: version.OperatorVersion{ Version: semver.Version{}, diff --git a/pkg/cluster/const.go b/pkg/cluster/const.go index 68c6434b6b11..844c139438c1 100644 --- a/pkg/cluster/const.go +++ b/pkg/cluster/const.go @@ -1,14 +1,16 @@ package cluster +import "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" + const ( // ManagedRhoai defines expected addon catalogsource. - ManagedRhoai Platform = "OpenShift AI Cloud Service" + ManagedRhoai common.Platform = "OpenShift AI Cloud Service" // SelfManagedRhoai defines display name in csv. - SelfManagedRhoai Platform = "OpenShift AI Self-Managed" + SelfManagedRhoai common.Platform = "OpenShift AI Self-Managed" // OpenDataHub defines display name in csv. - OpenDataHub Platform = "Open Data Hub" + OpenDataHub common.Platform = "Open Data Hub" // Unknown indicates that operator is not deployed using OLM. - Unknown Platform = "" + Unknown common.Platform = "" // DefaultNotebooksNamespace defines default namespace for notebooks. DefaultNotebooksNamespace = "rhods-notebooks" diff --git a/pkg/cluster/zz_generated.deepcopy.go b/pkg/cluster/zz_generated.deepcopy.go deleted file mode 100644 index 0bc3e0f557d8..000000000000 --- a/pkg/cluster/zz_generated.deepcopy.go +++ /dev/null @@ -1,39 +0,0 @@ -//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 cluster - -import () - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Release) DeepCopyInto(out *Release) { - *out = *in - in.Version.DeepCopyInto(&out.Version) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Release. -func (in *Release) DeepCopy() *Release { - if in == nil { - return nil - } - out := new(Release) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/componentsregistry/componentsregistry.go b/pkg/componentsregistry/componentsregistry.go index 3ad767060670..b438fc3eb5bf 100644 --- a/pkg/componentsregistry/componentsregistry.go +++ b/pkg/componentsregistry/componentsregistry.go @@ -12,13 +12,12 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" - "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" ) // ComponentHandler is an interface to manage a component // Every method should accept ctx since it contains the logger. type ComponentHandler interface { - Init(platform cluster.Platform) error + Init(platform common.Platform) error // GetName and GetManagementState sound like pretty much the same across // all components, but I could not find a way to avoid it GetName() string diff --git a/pkg/controller/actions/deleteresource/action_delete_resources_test.go b/pkg/controller/actions/deleteresource/action_delete_resources_test.go index ecf6b540e04c..20fc19291a64 100644 --- a/pkg/controller/actions/deleteresource/action_delete_resources_test.go +++ b/pkg/controller/actions/deleteresource/action_delete_resources_test.go @@ -9,6 +9,7 @@ import ( appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster/gvk" @@ -65,7 +66,7 @@ func TestDeleteResourcesAction(t *testing.T) { Client: cl, Instance: nil, DSCI: &dsciv1.DSCInitialization{Spec: dsciv1.DSCInitializationSpec{ApplicationsNamespace: ns}}, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, }) g.Expect(err).ShouldNot(HaveOccurred()) diff --git a/pkg/controller/actions/deploy/action_deploy_cache_test.go b/pkg/controller/actions/deploy/action_deploy_cache_test.go index 4ee26b6b31d0..297d23f95c07 100644 --- a/pkg/controller/actions/deploy/action_deploy_cache_test.go +++ b/pkg/controller/actions/deploy/action_deploy_cache_test.go @@ -20,6 +20,7 @@ import ( ctrlCli "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" @@ -152,7 +153,7 @@ func testResourceNotReDeployed(t *testing.T, cli *client.Client, obj ctrlCli.Obj Generation: 1, }, }, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{Version: semver.Version{ Major: 1, Minor: 2, Patch: 3, @@ -225,7 +226,7 @@ func testCacheTTL(t *testing.T, cli *client.Client, obj ctrlCli.Object) { Generation: 1, }, }, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{Version: semver.Version{ Major: 1, Minor: 2, Patch: 3, diff --git a/pkg/controller/actions/deploy/action_deploy_test.go b/pkg/controller/actions/deploy/action_deploy_test.go index 16e80c50270e..1928ee5e98c6 100644 --- a/pkg/controller/actions/deploy/action_deploy_test.go +++ b/pkg/controller/actions/deploy/action_deploy_test.go @@ -24,6 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/envtest" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" @@ -79,7 +80,7 @@ func TestDeployAction(t *testing.T) { Generation: 1, }, }, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{Version: semver.Version{ Major: 1, Minor: 2, Patch: 3, @@ -165,7 +166,7 @@ func TestDeployNotOwnedSkip(t *testing.T) { Generation: 1, }, }, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{Version: semver.Version{ Major: 1, Minor: 2, Patch: 3, @@ -231,7 +232,7 @@ func TestDeployNotOwnedCreate(t *testing.T) { Generation: 1, }, }, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{Version: semver.Version{ Major: 1, Minor: 2, Patch: 3, @@ -358,7 +359,7 @@ func deployClusterRoles(t *testing.T, ctx context.Context, cli *odhCli.Client, r UID: apimachinery.UID(xid.New().String()), }, }, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{Version: semver.Version{ Major: 1, Minor: 2, Patch: 3, @@ -425,7 +426,7 @@ func TestDeployCRD(t *testing.T) { UID: apimachinery.UID(id), }, }, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{Version: semver.Version{ Major: 1, Minor: 2, Patch: 3, @@ -598,7 +599,7 @@ func TestDeployOwnerRef(t *testing.T) { ApplicationsNamespace: id, }}, Instance: instance, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{Version: semver.Version{ Major: 1, Minor: 2, Patch: 3, diff --git a/pkg/controller/actions/gc/action_gc_test.go b/pkg/controller/actions/gc/action_gc_test.go index 2020c7ee3b27..27ef6c118111 100644 --- a/pkg/controller/actions/gc/action_gc_test.go +++ b/pkg/controller/actions/gc/action_gc_test.go @@ -23,6 +23,7 @@ import ( ctrlCli "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" @@ -199,7 +200,7 @@ func TestGcAction(t *testing.T) { UID: apytypes.UID(id), }, }, - Release: cluster.Release{ + Release: common.Release{ Name: cluster.OpenDataHub, Version: version.OperatorVersion{ Version: tt.version, diff --git a/pkg/controller/actions/render/kustomize/action_render_manifests_test.go b/pkg/controller/actions/render/kustomize/action_render_manifests_test.go index 01a7a0f7f4d3..2d5ab6eecc99 100644 --- a/pkg/controller/actions/render/kustomize/action_render_manifests_test.go +++ b/pkg/controller/actions/render/kustomize/action_render_manifests_test.go @@ -9,6 +9,7 @@ import ( "github.com/rs/xid" "sigs.k8s.io/kustomize/kyaml/filesys" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" @@ -129,7 +130,7 @@ func TestRenderResourcesAction(t *testing.T) { Client: cl, Instance: &componentApi.Dashboard{}, DSCI: &dsciv1.DSCInitialization{Spec: dsciv1.DSCInitializationSpec{ApplicationsNamespace: ns}}, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, Manifests: []types.ManifestInfo{{Path: id}}, } @@ -215,7 +216,7 @@ func TestRenderResourcesWithCacheAction(t *testing.T) { Client: cl, Instance: &d, DSCI: &dsciv1.DSCInitialization{Spec: dsciv1.DSCInitializationSpec{ApplicationsNamespace: ns}}, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, Manifests: []types.ManifestInfo{{Path: id}}, } diff --git a/pkg/controller/actions/render/template/action_render_templates_test.go b/pkg/controller/actions/render/template/action_render_templates_test.go index 0839fbe7fb8b..e9e5484bb31a 100644 --- a/pkg/controller/actions/render/template/action_render_templates_test.go +++ b/pkg/controller/actions/render/template/action_render_templates_test.go @@ -11,6 +11,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apytypes "k8s.io/apimachinery/pkg/types" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1" @@ -56,7 +57,7 @@ func TestRenderTemplate(t *testing.T) { }, }, }, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, Templates: []types.TemplateInfo{{FS: testFS, Path: "resources/smm.tmpl.yaml"}}, } @@ -120,7 +121,7 @@ func TestRenderTemplateWithData(t *testing.T) { }, }, }, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, Templates: []types.TemplateInfo{{FS: testFS, Path: "resources/smm-data.tmpl.yaml"}}, } @@ -165,7 +166,7 @@ func TestRenderTemplateWithDataErr(t *testing.T) { }, }, DSCI: &dsciv1.DSCInitialization{}, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, Templates: []types.TemplateInfo{{FS: testFS, Path: "resources/smm-data.tmpl.yaml"}}, } @@ -216,7 +217,7 @@ func TestRenderTemplateWithCache(t *testing.T) { Client: cl, Instance: &d, DSCI: &dsci, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, Templates: []types.TemplateInfo{{FS: testFS, Path: "resources/smm.tmpl.yaml"}}, } diff --git a/pkg/controller/actions/updatestatus/action_update_status_test.go b/pkg/controller/actions/updatestatus/action_update_status_test.go index 7eb47d60e926..e52c47a60112 100644 --- a/pkg/controller/actions/updatestatus/action_update_status_test.go +++ b/pkg/controller/actions/updatestatus/action_update_status_test.go @@ -11,6 +11,7 @@ import ( appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" @@ -78,7 +79,7 @@ func TestUpdateStatusActionNotReady(t *testing.T) { Client: cl, Instance: &componentApi.Dashboard{}, DSCI: &dsciv1.DSCInitialization{Spec: dsciv1.DSCInitializationSpec{ApplicationsNamespace: ns}}, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, } err = action(ctx, &rr) @@ -148,7 +149,7 @@ func TestUpdateStatusActionReady(t *testing.T) { Client: cl, Instance: &componentApi.Dashboard{}, DSCI: &dsciv1.DSCInitialization{Spec: dsciv1.DSCInitializationSpec{ApplicationsNamespace: ns}}, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, } err = action(ctx, &rr) @@ -217,7 +218,7 @@ func TestUpdateStatusActionReadyAutoSelector(t *testing.T) { Client: cl, Instance: &componentApi.Dashboard{}, DSCI: &dsciv1.DSCInitialization{Spec: dsciv1.DSCInitializationSpec{ApplicationsNamespace: ns}}, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, } err = action(ctx, &rr) @@ -286,7 +287,7 @@ func TestUpdateStatusActionNotReadyNotFound(t *testing.T) { Client: cl, Instance: &componentApi.Dashboard{}, DSCI: &dsciv1.DSCInitialization{Spec: dsciv1.DSCInitializationSpec{ApplicationsNamespace: ns}}, - Release: cluster.Release{Name: cluster.OpenDataHub}, + Release: common.Release{Name: cluster.OpenDataHub}, } err = action(ctx, &rr) diff --git a/pkg/controller/reconciler/reconciler.go b/pkg/controller/reconciler/reconciler.go index 565738e3a7b7..8256614c7d14 100644 --- a/pkg/controller/reconciler/reconciler.go +++ b/pkg/controller/reconciler/reconciler.go @@ -35,7 +35,7 @@ type Reconciler struct { Log logr.Logger Controller controller.Controller Recorder record.EventRecorder - Release cluster.Release + Release common.Release name string m *odhManager.Manager @@ -71,7 +71,7 @@ func NewReconciler[T common.PlatformObject](mgr manager.Manager, name string, ob return &cc, nil } -func (r *Reconciler) GetRelease() cluster.Release { +func (r *Reconciler) GetRelease() common.Release { return r.Release } diff --git a/pkg/controller/types/types.go b/pkg/controller/types/types.go index d46b5c6d1452..d0165805cae0 100644 --- a/pkg/controller/types/types.go +++ b/pkg/controller/types/types.go @@ -13,7 +13,6 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" - "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" odhClient "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/client" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/manager" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/resources" @@ -59,7 +58,7 @@ type ReconciliationRequest struct { Manager *manager.Manager Instance common.PlatformObject DSCI *dsciv1.DSCInitialization - Release cluster.Release + Release common.Release Manifests []ManifestInfo // diff --git a/pkg/upgrade/uninstallation.go b/pkg/upgrade/uninstallation.go index 5f300091f1d8..f5395719cb7c 100644 --- a/pkg/upgrade/uninstallation.go +++ b/pkg/upgrade/uninstallation.go @@ -12,6 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" logf "sigs.k8s.io/controller-runtime/pkg/log" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" @@ -26,7 +27,7 @@ const ( // OperatorUninstall deletes all the externally generated resources. // This includes DSCI, namespace created by operator (but not workbench or MR's), subscription and CSV. -func OperatorUninstall(ctx context.Context, cli client.Client, platform cluster.Platform) error { +func OperatorUninstall(ctx context.Context, cli client.Client, platform common.Platform) error { log := logf.FromContext(ctx) if err := removeDSC(ctx, cli); err != nil { diff --git a/pkg/upgrade/upgrade.go b/pkg/upgrade/upgrade.go index 0ca00cbb6fbd..9e0206ed757c 100644 --- a/pkg/upgrade/upgrade.go +++ b/pkg/upgrade/upgrade.go @@ -106,7 +106,7 @@ func CreateDefaultDSC(ctx context.Context, cli client.Client) error { // CreateDefaultDSCI creates a default instance of DSCI // If there exists default-dsci instance already, it will not update DSCISpec on it. // Note: DSCI CR modifcations are not supported, as it is the initial prereq setting for the components. -func CreateDefaultDSCI(ctx context.Context, cli client.Client, _ cluster.Platform, monNamespace string) error { +func CreateDefaultDSCI(ctx context.Context, cli client.Client, _ common.Platform, monNamespace string) error { log := logf.FromContext(ctx) defaultDsciSpec := &dsciv1.DSCInitializationSpec{ Monitoring: serviceApi.DSCMonitoring{ @@ -204,9 +204,9 @@ func getDashboardWatsonResources(ns string) []ResourceSpec { // TODO: remove function once we have a generic solution across all components. func CleanupExistingResource(ctx context.Context, cli client.Client, - platform cluster.Platform, + platform common.Platform, dscMonitoringNamespace string, - oldReleaseVersion cluster.Release, + oldReleaseVersion common.Release, ) error { var multiErr *multierror.Error // get DSCI CR to get application namespace @@ -366,7 +366,7 @@ func removOdhApplicationsCR(ctx context.Context, cli client.Client, gvk schema.G // 1. unset ownerreference for CR odh-dashboard-config // 2. flip TrustyAI BiasMetrics to false (.spec.dashboardConfig.disableBiasMetrics) if it is lower release version than input 'release'. // 3. flip ModelRegistry to false (.spec.dashboardConfig.disableModelRegistry) if it is lower release version than input 'release'. -func upgradeODCCR(ctx context.Context, cli client.Client, instanceName string, applicationNS string, release cluster.Release) error { +func upgradeODCCR(ctx context.Context, cli client.Client, instanceName string, applicationNS string, release common.Release) error { crd := &apiextv1.CustomResourceDefinition{} if err := cli.Get(ctx, client.ObjectKey{Name: "odhdashboardconfigs.opendatahub.io"}, crd); err != nil { return client.IgnoreNotFound(err) @@ -402,7 +402,7 @@ func unsetOwnerReference(ctx context.Context, cli client.Client, instanceName st return nil } -func updateODCBiasMetrics(ctx context.Context, cli client.Client, instanceName string, oldRelease cluster.Release, odhObject *unstructured.Unstructured) error { +func updateODCBiasMetrics(ctx context.Context, cli client.Client, instanceName string, oldRelease common.Release, odhObject *unstructured.Unstructured) error { log := logf.FromContext(ctx) // "from version" as oldRelease, if return "0.0.0" meaning running on 2.10- release/dummy CI build // if oldRelease is lower than 2.14.0(e.g 2.13.x-a), flip disableBiasMetrics to false (even the field did not exist) @@ -419,7 +419,7 @@ func updateODCBiasMetrics(ctx context.Context, cli client.Client, instanceName s return nil } -func updateODCModelRegistry(ctx context.Context, cli client.Client, instanceName string, oldRelease cluster.Release, odhObject *unstructured.Unstructured) error { +func updateODCModelRegistry(ctx context.Context, cli client.Client, instanceName string, oldRelease common.Release, odhObject *unstructured.Unstructured) error { log := logf.FromContext(ctx) // "from version" as oldRelease, if return "0.0.0" meaning running on 2.10- release/dummy CI build // if oldRelease is lower than 2.14.0(e.g 2.13.x-a), flip disableModelRegistry to false (even the field did not exist) @@ -467,10 +467,10 @@ func removeRBACProxyModelRegistry(ctx context.Context, cli client.Client, compon return nil } -func GetDeployedRelease(ctx context.Context, cli client.Client) (cluster.Release, error) { +func GetDeployedRelease(ctx context.Context, cli client.Client) (common.Release, error) { dsciInstance := &dsciv1.DSCInitializationList{} if err := cli.List(ctx, dsciInstance); err != nil { - return cluster.Release{}, err + return common.Release{}, err } if len(dsciInstance.Items) == 1 { // found one DSCI CR found // can return a valid Release or 0.0.0 @@ -479,16 +479,16 @@ func GetDeployedRelease(ctx context.Context, cli client.Client) (cluster.Release // no DSCI CR found, try with DSC CR dscInstances := &dscv1.DataScienceClusterList{} if err := cli.List(ctx, dscInstances); err != nil { - return cluster.Release{}, err + return common.Release{}, err } if len(dscInstances.Items) == 1 { // one DSC CR found return dscInstances.Items[0].Status.Release, nil } // could be a clean installation or both CRs are deleted already - return cluster.Release{}, nil + return common.Release{}, nil } -func cleanupNimIntegration(ctx context.Context, cli client.Client, oldRelease cluster.Release, applicationNS string) error { +func cleanupNimIntegration(ctx context.Context, cli client.Client, oldRelease common.Release, applicationNS string) error { var errs *multierror.Error if oldRelease.Version.Minor >= 14 && oldRelease.Version.Minor <= 16 { diff --git a/tests/e2e/controller_test.go b/tests/e2e/controller_test.go index 887847b995e6..b78e5893ed12 100644 --- a/tests/e2e/controller_test.go +++ b/tests/e2e/controller_test.go @@ -27,6 +27,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" + "github.com/opendatahub-io/opendatahub-operator/v2/apis/common" componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" @@ -101,7 +102,7 @@ type testContext struct { // test DSCI CR because we do not create it in ODH by default testDSCI *dsciv1.DSCInitialization // test platform - platform cluster.Platform + platform common.Platform // context for accessing resources //nolint:containedctx //reason: legacy v1 test setup ctx context.Context