diff --git a/apis/components/v1/modelcontroller_types.go b/apis/components/v1/modelcontroller_types.go index e1cc5702f74..1d489dabb79 100644 --- a/apis/components/v1/modelcontroller_types.go +++ b/apis/components/v1/modelcontroller_types.go @@ -57,13 +57,13 @@ type ModelControllerSpec struct { // a mini version of the DSCKserve only keep devflags and management spec type ModelControllerKerveSpec struct { - ManagementState operatorv1.ManagementState `json:"managementState,omitempty"` + ManagementState operatorv1.ManagementState `json:"managementState,omitempty"` common.DevFlagsSpec `json:",inline"` } // a mini version of the DSCModelMeshServing only keep devflags and management spec type ModelControllerMMSpec struct { - ManagementState operatorv1.ManagementState `json:"managementState,omitempty"` + ManagementState operatorv1.ManagementState `json:"managementState,omitempty"` common.DevFlagsSpec `json:",inline"` } diff --git a/controllers/components/kserve/kserve_controller.go b/controllers/components/kserve/kserve_controller.go index da7d838e642..dd155183f3b 100644 --- a/controllers/components/kserve/kserve_controller.go +++ b/controllers/components/kserve/kserve_controller.go @@ -39,6 +39,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/security" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/updatestatus" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/clusterrole" + "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/crd" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/hash" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/resources" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/reconciler" @@ -88,7 +89,7 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl. // for to objects that have the label components.opendatahub.io/managed-by // set to the current owner // - Watches(&extv1.CustomResourceDefinition{}). + Watches(&extv1.CustomResourceDefinition{}, reconciler.WithPredicates(crd.ServingCRD())). // operands - dynamically watched // diff --git a/controllers/components/modelmeshserving/modelmeshserving_controller.go b/controllers/components/modelmeshserving/modelmeshserving_controller.go index ff342e518f1..f1bb07a1322 100644 --- a/controllers/components/modelmeshserving/modelmeshserving_controller.go +++ b/controllers/components/modelmeshserving/modelmeshserving_controller.go @@ -36,6 +36,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/security" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/updatestatus" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/clusterrole" + "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/crd" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/resources" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/reconciler" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/labels" @@ -65,7 +66,7 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl. Owns(&rbacv1.RoleBinding{}). Owns(&rbacv1.ClusterRoleBinding{}). Owns(&appsv1.Deployment{}, reconciler.WithPredicates(resources.NewDeploymentPredicate())). - Watches(&extv1.CustomResourceDefinition{}). // call ForLabel() + new predicates + Watches(&extv1.CustomResourceDefinition{}, reconciler.WithPredicates(crd.ServingCRD())). // call ForLabel() + new predicates // Add ModelMeshServing specific actions WithAction(initialize). WithAction(devFlags). diff --git a/pkg/controller/predicates/crd/crd.go b/pkg/controller/predicates/crd/crd.go new file mode 100644 index 00000000000..60df7f8ea55 --- /dev/null +++ b/pkg/controller/predicates/crd/crd.go @@ -0,0 +1,14 @@ +package crd + +import ( + "sigs.k8s.io/controller-runtime/pkg/event" + "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +func ServingCRD() predicate.Predicate { + return predicate.Funcs{ + UpdateFunc: func(e event.UpdateEvent) bool { + return e.ObjectNew.GetName() != "inferenceservices.serving.kserve.io" && e.ObjectNew.GetName() != "servingruntimes.serving.kserve.io" + }, + } +}