From 345c292ba334da5f44dc49036302a262345361b0 Mon Sep 17 00:00:00 2001 From: Wei-Xiang Sun Date: Mon, 20 Jun 2022 10:56:10 +0800 Subject: [PATCH] add a switch for persistentPodState controller (#1002) Signed-off-by: mingzhou.swx Co-authored-by: mingzhou.swx --- .../persistentpodstate/persistent_pod_state_controller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/controller/persistentpodstate/persistent_pod_state_controller.go b/pkg/controller/persistentpodstate/persistent_pod_state_controller.go index 100650fa39..ab698870fd 100644 --- a/pkg/controller/persistentpodstate/persistent_pod_state_controller.go +++ b/pkg/controller/persistentpodstate/persistent_pod_state_controller.go @@ -27,6 +27,7 @@ import ( appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" "github.com/openkruise/kruise/pkg/util" "github.com/openkruise/kruise/pkg/util/controllerfinder" + "github.com/openkruise/kruise/pkg/util/discovery" "github.com/openkruise/kruise/pkg/util/ratelimiter" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -58,6 +59,7 @@ var ( KindSts = appsv1.SchemeGroupVersion.WithKind("StatefulSet") // kruise KruiseKindSts = appsv1beta1.SchemeGroupVersion.WithKind("StatefulSet") + KruiseKindPps = appsv1alpha1.SchemeGroupVersion.WithKind("PersistentPodState") // AutoGeneratePersistentPodStatePrefix auto generate PersistentPodState crd AutoGeneratePersistentPodStatePrefix = "generate#" ) @@ -70,6 +72,9 @@ var ( // Add creates a new PersistentPodState Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(mgr manager.Manager) error { + if !discovery.DiscoverGVK(KruiseKindPps) { + return nil + } return add(mgr, newReconciler(mgr)) }