check if cluster ImpersonatorSecretRef is nil before using it

Signed-off-by: stingshen <stingshen@126.com>
This commit is contained in:
stingshen 2022-10-23 16:38:11 +08:00 committed by shenyi
parent 875d2ef6c1
commit e5d156dd61
1 changed files with 5 additions and 0 deletions

View File

@ -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)