Skip to content

Commit

Permalink
fix: only replace/set default model reg namespace by webhook if compo…
Browse files Browse the repository at this point in the history
…nent is enabled (#1249)

- when modelreg is not set in DSC
- when modelreg is set to be Removed
these two cases should not block operation, for backwards compataible

Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw committed Sep 18, 2024
1 parent ac13bee commit c87dc1c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion controllers/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/http"

operatorv1 "github.com/openshift/api/operator/v1"
admissionv1 "k8s.io/api/admission/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -158,7 +159,7 @@ func (w *OpenDataHubMutatingWebhook) Handle(ctx context.Context, req admission.R

func (w *OpenDataHubMutatingWebhook) setDSCDefaults(_ context.Context, dsc *dscv1.DataScienceCluster) admission.Response {
// set default registriesNamespace if empty
if len(dsc.Spec.Components.ModelRegistry.RegistriesNamespace) == 0 {
if len(dsc.Spec.Components.ModelRegistry.RegistriesNamespace) == 0 && dsc.Spec.Components.ModelRegistry.ManagementState == operatorv1.Managed {
return admission.Patched("Property registriesNamespace set to default value", webhook.JSONPatchOp{
Operation: "replace",
Path: "spec.components.modelregistry.registriesNamespace",
Expand Down

0 comments on commit c87dc1c

Please sign in to comment.