From 3a672d42981c7783112b3b6d56d9e8218ea88014 Mon Sep 17 00:00:00 2001 From: Wen Zhou Date: Wed, 6 Dec 2023 18:09:22 +0100 Subject: [PATCH] fix: do not force check if servicemesh is set to managed in DSCI (#154) * fix: do not force check if servicemesh is set to managed in DSCI Signed-off-by: Wen Zhou * update: add supported value for serverless and servicemesh - currently removed and unmanaged are the same logic Signed-off-by: Wen Zhou * update: do not remove resources if it has label Signed-off-by: Wen Zhou --------- Signed-off-by: Wen Zhou --- ...datasciencecluster.opendatahub.io_datascienceclusters.yaml | 1 + .../dscinitialization.opendatahub.io_dscinitializations.yaml | 3 ++- components/kserve/kserve.go | 2 +- ...datasciencecluster.opendatahub.io_datascienceclusters.yaml | 1 + .../dscinitialization.opendatahub.io_dscinitializations.yaml | 3 ++- infrastructure/v1/serverless_types.go | 2 +- infrastructure/v1/servicemesh_types.go | 4 ++-- pkg/deploy/deploy.go | 4 +++- pkg/upgrade/upgrade.go | 1 + 9 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bundle/manifests/datasciencecluster.opendatahub.io_datascienceclusters.yaml b/bundle/manifests/datasciencecluster.opendatahub.io_datascienceclusters.yaml index 5898f7c854b..53406a108f1 100644 --- a/bundle/manifests/datasciencecluster.opendatahub.io_datascienceclusters.yaml +++ b/bundle/manifests/datasciencecluster.opendatahub.io_datascienceclusters.yaml @@ -265,6 +265,7 @@ spec: default: Managed enum: - Managed + - Unmanaged - Removed pattern: ^(Managed|Unmanaged|Force|Removed)$ type: string diff --git a/bundle/manifests/dscinitialization.opendatahub.io_dscinitializations.yaml b/bundle/manifests/dscinitialization.opendatahub.io_dscinitializations.yaml index b3267a446f0..c3757674e01 100644 --- a/bundle/manifests/dscinitialization.opendatahub.io_dscinitializations.yaml +++ b/bundle/manifests/dscinitialization.opendatahub.io_dscinitializations.yaml @@ -115,9 +115,10 @@ spec: type: string type: object managementState: - default: Managed + default: Removed enum: - Managed + - Unmanaged - Removed pattern: ^(Managed|Unmanaged|Force|Removed)$ type: string diff --git a/components/kserve/kserve.go b/components/kserve/kserve.go index c69e4a47876..3bb37ca2c9d 100644 --- a/components/kserve/kserve.go +++ b/components/kserve/kserve.go @@ -159,7 +159,7 @@ func (k *Kserve) Cleanup(_ client.Client, instance *dsciv1.DSCInitializationSpec func (k *Kserve) configureServerless(instance *dsciv1.DSCInitializationSpec) error { if k.Serving.ManagementState == operatorv1.Managed { if instance.ServiceMesh.ManagementState != operatorv1.Managed { - return fmt.Errorf("serviceMesh is not configured as Managaed in DSCI instance but required by KServe serving") + fmt.Println("ServiceMesh is not configured as Managed in DSCI instance") } serverlessInitializer := feature.NewFeaturesInitializer(instance, k.configureServerlessFeatures) diff --git a/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml b/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml index 4331b158de2..c0e4a1e2562 100644 --- a/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml +++ b/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml @@ -266,6 +266,7 @@ spec: default: Managed enum: - Managed + - Unmanaged - Removed pattern: ^(Managed|Unmanaged|Force|Removed)$ type: string diff --git a/config/crd/bases/dscinitialization.opendatahub.io_dscinitializations.yaml b/config/crd/bases/dscinitialization.opendatahub.io_dscinitializations.yaml index 97091ed5d9e..01213c67a24 100644 --- a/config/crd/bases/dscinitialization.opendatahub.io_dscinitializations.yaml +++ b/config/crd/bases/dscinitialization.opendatahub.io_dscinitializations.yaml @@ -116,9 +116,10 @@ spec: type: string type: object managementState: - default: Managed + default: Removed enum: - Managed + - Unmanaged - Removed pattern: ^(Managed|Unmanaged|Force|Removed)$ type: string diff --git a/infrastructure/v1/serverless_types.go b/infrastructure/v1/serverless_types.go index f49f5164c7b..c5022a85e91 100644 --- a/infrastructure/v1/serverless_types.go +++ b/infrastructure/v1/serverless_types.go @@ -7,7 +7,7 @@ import ( // ServingSpec specifies the configuration for the KNative Serving components and their // bindings with the Service Mesh. type ServingSpec struct { - // +kubebuilder:validation:Enum=Managed;Removed + // +kubebuilder:validation:Enum=Managed;Unmanaged;Removed // +kubebuilder:default=Managed ManagementState operatorv1.ManagementState `json:"managementState,omitempty"` // Name specifies the name of the KNativeServing resource that is going to be diff --git a/infrastructure/v1/servicemesh_types.go b/infrastructure/v1/servicemesh_types.go index 1a3006cf51d..9c093d0c663 100644 --- a/infrastructure/v1/servicemesh_types.go +++ b/infrastructure/v1/servicemesh_types.go @@ -4,8 +4,8 @@ import operatorv1 "github.com/openshift/api/operator/v1" // ServiceMeshSpec configures Service Mesh. type ServiceMeshSpec struct { - // +kubebuilder:validation:Enum=Managed;Removed - // +kubebuilder:default=Managed + // +kubebuilder:validation:Enum=Managed;Unmanaged;Removed + // +kubebuilder:default=Removed ManagementState operatorv1.ManagementState `json:"managementState,omitempty"` // ControlPlane holds configuration of Service Mesh used by Opendatahub. ControlPlane ControlPlaneSpec `json:"controlPlane,omitempty"` diff --git a/pkg/deploy/deploy.go b/pkg/deploy/deploy.go index 60b97064f98..a10a67445fe 100644 --- a/pkg/deploy/deploy.go +++ b/pkg/deploy/deploy.go @@ -234,7 +234,9 @@ func manageResource(ctx context.Context, cli client.Client, obj *unstructured.Un } existingOwnerReferences := obj.GetOwnerReferences() - if existingOwnerReferences == nil { + selector := "app.opendatahub.io/" + componentName + // only removed the resource with our label applied, not the same name resource maually created by user + if existingOwnerReferences == nil && resourceLabels[selector] == "true" { return cli.Delete(ctx, found) } else if len(existingOwnerReferences) > 0 { for _, owner := range existingOwnerReferences { diff --git a/pkg/upgrade/upgrade.go b/pkg/upgrade/upgrade.go index a36c9802571..94ee446f82b 100644 --- a/pkg/upgrade/upgrade.go +++ b/pkg/upgrade/upgrade.go @@ -241,6 +241,7 @@ func CreateDefaultDSCI(cli client.Client, platform deploy.Platform, appNamespace fmt.Printf("DSCInitialization resource already exists. It will not be updated with default DSCI.") return nil case len(instances.Items) == 0: + fmt.Printf("create default DSCI CR.") err := cli.Create(context.TODO(), defaultDsci) if err != nil { return err