From e5d156dd61a4f019c9f7c7110128c56e7beefd20 Mon Sep 17 00:00:00 2001 From: stingshen Date: Sun, 23 Oct 2022 16:38:11 +0800 Subject: [PATCH] check if cluster ImpersonatorSecretRef is nil before using it Signed-off-by: stingshen --- pkg/controllers/unifiedauth/unified_auth_controller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/controllers/unifiedauth/unified_auth_controller.go b/pkg/controllers/unifiedauth/unified_auth_controller.go index 6be9e8f16..24771a75b 100644 --- a/pkg/controllers/unifiedauth/unified_auth_controller.go +++ b/pkg/controllers/unifiedauth/unified_auth_controller.go @@ -63,6 +63,11 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques return controllerruntime.Result{}, nil } + if cluster.Spec.ImpersonatorSecretRef == nil { + klog.Infof("Aggregated API feature is disabled on cluster %s as it does not have an impersonator secret", cluster.Name) + return controllerruntime.Result{}, nil + } + err := c.syncImpersonationConfig(cluster) if err != nil { klog.Errorf("Failed to sync impersonation config for cluster %s. Error: %v.", cluster.Name, err)