From 70e59a74ea7e1ab4438a2379368c103422577abe Mon Sep 17 00:00:00 2001 From: Wen Zhou Date: Wed, 20 Nov 2024 13:43:52 +0100 Subject: [PATCH] update: watches to watchesgvk on two component types Signed-off-by: Wen Zhou --- .../modelcontroller/modelcontroller_controller.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/controllers/components/modelcontroller/modelcontroller_controller.go b/controllers/components/modelcontroller/modelcontroller_controller.go index e9269eaab02..ba314fe4a1e 100644 --- a/controllers/components/modelcontroller/modelcontroller_controller.go +++ b/controllers/components/modelcontroller/modelcontroller_controller.go @@ -29,9 +29,11 @@ import ( extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/handler" componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" + "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster/gvk" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/deploy" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/render" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/render/kustomize" @@ -68,9 +70,9 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl. Owns(&admissionregistrationv1.ValidatingWebhookConfiguration{}). Owns(&templatev1.Template{}). Owns(&appsv1.Deployment{}, builder.WithPredicates(resources.NewDeploymentPredicate())). - Watches(&componentsv1.ModelMeshServing{}). // watch ModelMeshServing - Watches(&componentsv1.Kserve{}). // watch Kserve - Watches(&extv1.CustomResourceDefinition{}). // call ForLabel() + new predicates + WatchesGVK(gvk.ModelMeshServing, &handler.EnqueueRequestForObject{}). // watch ModelMeshServing type with all default create, update, delete and generic + WatchesGVK(gvk.Kserve, &handler.EnqueueRequestForObject{}). // watch Kserve type with all default create, update, delete and generic + Watches(&extv1.CustomResourceDefinition{}). // call ForLabel() + new predicates // Add ModelController specific actions WithAction(initialize). WithAction(devFlags).