From 004831da0e3c1ce20636ae05df71f48d063cd187 Mon Sep 17 00:00:00 2001 From: huangyanfeng Date: Tue, 2 Apr 2024 20:31:22 +0800 Subject: [PATCH] if an error is non-nil not need to set Result.Requeue Signed-off-by: huangyanfeng --- .../crb_application_failover_controller.go | 4 ++-- .../rb_application_failover_controller.go | 4 ++-- pkg/controllers/binding/binding_controller.go | 12 ++++++------ .../binding/binding_controller_test.go | 2 +- .../cluster_resource_binding_controller.go | 12 ++++++------ .../certificate/cert_rotation_controller.go | 8 ++++---- pkg/controllers/cluster/cluster_controller.go | 18 +++++++++--------- pkg/controllers/cluster/taint_manager.go | 6 +++--- .../cronfederatedhpa_controller.go | 6 +++--- .../execution/execution_controller.go | 16 ++++++++-------- ...derated_resource_quota_status_controller.go | 4 ++-- ...federated_resource_quota_sync_controller.go | 8 ++++---- .../crb_graceful_eviction_controller.go | 4 ++-- .../rb_graceful_eviction_controller.go | 4 ++-- .../mcs/service_import_controller.go | 8 ++++---- .../endpointslice_collect_controller.go | 8 ++++---- .../endpointslice_dispatch_controller.go | 10 +++++----- .../namespace/namespace_sync_controller.go | 6 +++--- .../status/cluster_status_controller.go | 6 +++--- .../status/cluster_status_controller_test.go | 2 +- .../status/crb_status_controller.go | 4 ++-- pkg/controllers/status/rb_status_controller.go | 4 ++-- .../status/work_status_controller.go | 10 +++++----- .../status/work_status_controller_test.go | 6 +++--- .../unifiedauth/unified_auth_controller.go | 4 ++-- 25 files changed, 88 insertions(+), 88 deletions(-) diff --git a/pkg/controllers/applicationfailover/crb_application_failover_controller.go b/pkg/controllers/applicationfailover/crb_application_failover_controller.go index dcf7bfc73ceb..f370af87440f 100644 --- a/pkg/controllers/applicationfailover/crb_application_failover_controller.go +++ b/pkg/controllers/applicationfailover/crb_application_failover_controller.go @@ -71,7 +71,7 @@ func (c *CRBApplicationFailoverController) Reconcile(ctx context.Context, req co c.workloadUnhealthyMap.delete(req.NamespacedName) return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !c.clusterResourceBindingFilter(binding) { @@ -81,7 +81,7 @@ func (c *CRBApplicationFailoverController) Reconcile(ctx context.Context, req co retryDuration, err := c.syncBinding(binding) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if retryDuration > 0 { klog.V(4).Infof("Retry to check health status of the workload after %v minutes.", retryDuration.Minutes()) diff --git a/pkg/controllers/applicationfailover/rb_application_failover_controller.go b/pkg/controllers/applicationfailover/rb_application_failover_controller.go index 2e6024575393..913593a18a96 100644 --- a/pkg/controllers/applicationfailover/rb_application_failover_controller.go +++ b/pkg/controllers/applicationfailover/rb_application_failover_controller.go @@ -71,7 +71,7 @@ func (c *RBApplicationFailoverController) Reconcile(ctx context.Context, req con c.workloadUnhealthyMap.delete(req.NamespacedName) return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !c.bindingFilter(binding) { @@ -81,7 +81,7 @@ func (c *RBApplicationFailoverController) Reconcile(ctx context.Context, req con retryDuration, err := c.syncBinding(binding) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if retryDuration > 0 { klog.V(4).Infof("Retry to check health status of the workload after %v minutes.", retryDuration.Minutes()) diff --git a/pkg/controllers/binding/binding_controller.go b/pkg/controllers/binding/binding_controller.go index 4a641aa98fc4..34caa09a3788 100644 --- a/pkg/controllers/binding/binding_controller.go +++ b/pkg/controllers/binding/binding_controller.go @@ -77,14 +77,14 @@ func (c *ResourceBindingController) Reconcile(ctx context.Context, req controlle return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !binding.DeletionTimestamp.IsZero() { klog.V(4).Infof("Begin to delete works owned by binding(%s).", req.NamespacedName.String()) if err := helper.DeleteWorkByRBNamespaceAndName(c.Client, req.Namespace, req.Name); err != nil { klog.Errorf("Failed to delete works related to %s/%s: %v", binding.GetNamespace(), binding.GetName(), err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return c.removeFinalizer(binding) } @@ -101,7 +101,7 @@ func (c *ResourceBindingController) removeFinalizer(rb *workv1alpha2.ResourceBin controllerutil.RemoveFinalizer(rb, util.BindingControllerFinalizer) err := c.Client.Update(context.TODO(), rb) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil } @@ -109,7 +109,7 @@ func (c *ResourceBindingController) removeFinalizer(rb *workv1alpha2.ResourceBin // syncBinding will sync resourceBinding to Works. func (c *ResourceBindingController) syncBinding(binding *workv1alpha2.ResourceBinding) (controllerruntime.Result, error) { if err := c.removeOrphanWorks(binding); err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } workload, err := helper.FetchResourceTemplate(c.DynamicClient, c.InformerManager, c.RESTMapper, binding.Spec.Resource) @@ -122,7 +122,7 @@ func (c *ResourceBindingController) syncBinding(binding *workv1alpha2.ResourceBi } klog.Errorf("Failed to fetch workload for resourceBinding(%s/%s). Error: %v.", binding.GetNamespace(), binding.GetName(), err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } start := time.Now() err = ensureWork(c.Client, c.ResourceInterpreter, workload, c.OverrideManager, binding, apiextensionsv1.NamespaceScoped) @@ -132,7 +132,7 @@ func (c *ResourceBindingController) syncBinding(binding *workv1alpha2.ResourceBi binding.GetNamespace(), binding.GetName(), err) c.EventRecorder.Event(binding, corev1.EventTypeWarning, events.EventReasonSyncWorkFailed, err.Error()) c.EventRecorder.Event(workload, corev1.EventTypeWarning, events.EventReasonSyncWorkFailed, err.Error()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } msg := fmt.Sprintf("Sync work of resourceBinding(%s/%s) successful.", binding.Namespace, binding.Name) diff --git a/pkg/controllers/binding/binding_controller_test.go b/pkg/controllers/binding/binding_controller_test.go index 108c724b6c33..563b971fc79f 100644 --- a/pkg/controllers/binding/binding_controller_test.go +++ b/pkg/controllers/binding/binding_controller_test.go @@ -111,7 +111,7 @@ func TestResourceBindingController_Reconcile(t *testing.T) { }, { name: "RB found without deleting", - want: controllerruntime.Result{Requeue: true}, + want: controllerruntime.Result{}, wantErr: true, rb: &workv1alpha2.ResourceBinding{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/controllers/binding/cluster_resource_binding_controller.go b/pkg/controllers/binding/cluster_resource_binding_controller.go index 4e33ab0fa93e..be06e321c06a 100644 --- a/pkg/controllers/binding/cluster_resource_binding_controller.go +++ b/pkg/controllers/binding/cluster_resource_binding_controller.go @@ -77,14 +77,14 @@ func (c *ClusterResourceBindingController) Reconcile(ctx context.Context, req co return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !clusterResourceBinding.DeletionTimestamp.IsZero() { klog.V(4).Infof("Begin to delete works owned by binding(%s).", req.NamespacedName.String()) if err := helper.DeleteWorkByCRBName(c.Client, req.Name); err != nil { klog.Errorf("Failed to delete works related to %s: %v", clusterResourceBinding.GetName(), err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return c.removeFinalizer(clusterResourceBinding) } @@ -101,7 +101,7 @@ func (c *ClusterResourceBindingController) removeFinalizer(crb *workv1alpha2.Clu controllerutil.RemoveFinalizer(crb, util.ClusterResourceBindingControllerFinalizer) err := c.Client.Update(context.TODO(), crb) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil } @@ -109,7 +109,7 @@ func (c *ClusterResourceBindingController) removeFinalizer(crb *workv1alpha2.Clu // syncBinding will sync clusterResourceBinding to Works. func (c *ClusterResourceBindingController) syncBinding(binding *workv1alpha2.ClusterResourceBinding) (controllerruntime.Result, error) { if err := c.removeOrphanWorks(binding); err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } workload, err := helper.FetchResourceTemplate(c.DynamicClient, c.InformerManager, c.RESTMapper, binding.Spec.Resource) @@ -121,7 +121,7 @@ func (c *ClusterResourceBindingController) syncBinding(binding *workv1alpha2.Clu return controllerruntime.Result{}, nil } klog.Errorf("Failed to fetch workload for clusterResourceBinding(%s). Error: %v.", binding.GetName(), err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } start := time.Now() @@ -131,7 +131,7 @@ func (c *ClusterResourceBindingController) syncBinding(binding *workv1alpha2.Clu klog.Errorf("Failed to transform clusterResourceBinding(%s) to works. Error: %v.", binding.GetName(), err) c.EventRecorder.Event(binding, corev1.EventTypeWarning, events.EventReasonSyncWorkFailed, err.Error()) c.EventRecorder.Event(workload, corev1.EventTypeWarning, events.EventReasonSyncWorkFailed, err.Error()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } msg := fmt.Sprintf("Sync work of clusterResourceBinding(%s) successful.", binding.GetName()) diff --git a/pkg/controllers/certificate/cert_rotation_controller.go b/pkg/controllers/certificate/cert_rotation_controller.go index e48dffac81ba..fd24a8587047 100644 --- a/pkg/controllers/certificate/cert_rotation_controller.go +++ b/pkg/controllers/certificate/cert_rotation_controller.go @@ -98,7 +98,7 @@ func (c *CertRotationController) Reconcile(ctx context.Context, req controllerru return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !cluster.DeletionTimestamp.IsZero() { @@ -109,18 +109,18 @@ func (c *CertRotationController) Reconcile(ctx context.Context, req controllerru c.ClusterClient, err = c.ClusterClientSetFunc(cluster.Name, c.Client, c.ClusterClientOption) if err != nil { klog.Errorf("Failed to create a ClusterClient for the given member cluster: %s, err is: %v", cluster.Name, err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } secret, err := c.ClusterClient.KubeClient.CoreV1().Secrets(c.KarmadaKubeconfigNamespace).Get(ctx, KarmadaKubeconfigName, metav1.GetOptions{}) if err != nil { klog.Errorf("failed to get karmada kubeconfig secret: %v", err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if err = c.syncCertRotation(secret); err != nil { klog.Errorf("Failed to rotate the certificate of karmada-agent for the given member cluster: %s, err is: %v", cluster.Name, err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{RequeueAfter: c.CertRotationCheckingInterval}, nil diff --git a/pkg/controllers/cluster/cluster_controller.go b/pkg/controllers/cluster/cluster_controller.go index dd2e61aeb318..418cb699fcec 100644 --- a/pkg/controllers/cluster/cluster_controller.go +++ b/pkg/controllers/cluster/cluster_controller.go @@ -185,7 +185,7 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !cluster.DeletionTimestamp.IsZero() { @@ -225,13 +225,13 @@ func (c *Controller) syncCluster(ctx context.Context, cluster *clusterv1alpha1.C err := c.createExecutionSpace(cluster) if err != nil { c.EventRecorder.Event(cluster, corev1.EventTypeWarning, events.EventReasonCreateExecutionSpaceFailed, err.Error()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } // taint cluster by condition err = c.taintClusterByCondition(ctx, cluster) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } // ensure finalizer @@ -242,20 +242,20 @@ func (c *Controller) removeCluster(ctx context.Context, cluster *clusterv1alpha1 // add terminating taint before cluster is deleted if err := c.updateClusterTaints(ctx, []*corev1.Taint{TerminatingTaintTemplate}, nil, cluster); err != nil { klog.ErrorS(err, "Failed to update terminating taint", "cluster", cluster.Name) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if err := c.removeExecutionSpace(cluster); err != nil { klog.Errorf("Failed to remove execution space %s: %v", cluster.Name, err) c.EventRecorder.Event(cluster, corev1.EventTypeWarning, events.EventReasonRemoveExecutionSpaceFailed, err.Error()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } msg := fmt.Sprintf("Removed execution space for cluster(%s).", cluster.Name) c.EventRecorder.Event(cluster, corev1.EventTypeNormal, events.EventReasonRemoveExecutionSpaceSucceed, msg) if exist, err := c.ExecutionSpaceExistForCluster(cluster.Name); err != nil { klog.Errorf("Failed to check weather the execution space exist in the given member cluster or not, error is: %v", err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } else if exist { klog.Infof("Requeuing operation until the cluster(%s) execution space deleted", cluster.Name) return controllerruntime.Result{RequeueAfter: c.ExecutionSpaceRetryFrequency}, nil @@ -268,7 +268,7 @@ func (c *Controller) removeCluster(ctx context.Context, cluster *clusterv1alpha1 if c.EnableTaintManager { if done, err := c.isTargetClusterRemoved(ctx, cluster); err != nil { klog.ErrorS(err, "Failed to check whether target cluster is removed from bindings", "cluster", cluster.Name) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } else if !done { klog.InfoS("Terminating taint eviction process has not finished yet, will try again later", "cluster", cluster.Name) return controllerruntime.Result{RequeueAfter: c.ClusterTaintEvictionRetryFrequency}, nil @@ -386,7 +386,7 @@ func (c *Controller) removeFinalizer(cluster *clusterv1alpha1.Cluster) (controll controllerutil.RemoveFinalizer(cluster, util.ClusterControllerFinalizer) err := c.Client.Update(context.TODO(), cluster) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil @@ -400,7 +400,7 @@ func (c *Controller) ensureFinalizer(cluster *clusterv1alpha1.Cluster) (controll controllerutil.AddFinalizer(cluster, util.ClusterControllerFinalizer) err := c.Client.Update(context.TODO(), cluster) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil diff --git a/pkg/controllers/cluster/taint_manager.go b/pkg/controllers/cluster/taint_manager.go index 0bead2e81ede..dbcc14ab0244 100644 --- a/pkg/controllers/cluster/taint_manager.go +++ b/pkg/controllers/cluster/taint_manager.go @@ -67,7 +67,7 @@ func (tc *NoExecuteTaintManager) Reconcile(ctx context.Context, req reconcile.Re if apierrors.IsNotFound(err) { return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } // Check whether the target cluster has no execute taints. @@ -85,7 +85,7 @@ func (tc *NoExecuteTaintManager) syncCluster(ctx context.Context, cluster *clust Selector: fields.OneTermEqualSelector(rbClusterKeyIndex, cluster.Name), }); err != nil { klog.ErrorS(err, "Failed to list ResourceBindings", "cluster", cluster.Name) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } for i := range rbList.Items { key, err := keys.FederatedKeyFunc(cluster.Name, &rbList.Items[i]) @@ -102,7 +102,7 @@ func (tc *NoExecuteTaintManager) syncCluster(ctx context.Context, cluster *clust Selector: fields.OneTermEqualSelector(crbClusterKeyIndex, cluster.Name), }); err != nil { klog.ErrorS(err, "Failed to list ClusterResourceBindings", "cluster", cluster.Name) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } for i := range crbList.Items { key, err := keys.FederatedKeyFunc(cluster.Name, &crbList.Items[i]) diff --git a/pkg/controllers/cronfederatedhpa/cronfederatedhpa_controller.go b/pkg/controllers/cronfederatedhpa/cronfederatedhpa_controller.go index 9b3ef3feb044..fff06ae8358a 100755 --- a/pkg/controllers/cronfederatedhpa/cronfederatedhpa_controller.go +++ b/pkg/controllers/cronfederatedhpa/cronfederatedhpa_controller.go @@ -64,7 +64,7 @@ func (c *CronFHPAController) Reconcile(ctx context.Context, req controllerruntim } klog.Errorf("Fail to get CronFederatedHPA(%s):%v", req.NamespacedName, err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } // If this CronFederatedHPA is deleting, stop all related cron executors @@ -92,7 +92,7 @@ func (c *CronFHPAController) Reconcile(ctx context.Context, req controllerruntim newRuleSets := sets.New[string]() for _, rule := range cronFHPA.Spec.Rules { if err = c.processCronRule(cronFHPA, rule); err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } newRuleSets.Insert(rule.Name) } @@ -104,7 +104,7 @@ func (c *CronFHPAController) Reconcile(ctx context.Context, req controllerruntim } c.CronHandler.StopRuleExecutor(req.NamespacedName.String(), name) if err = c.removeCronFHPAHistory(cronFHPA, name); err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } } diff --git a/pkg/controllers/execution/execution_controller.go b/pkg/controllers/execution/execution_controller.go index 3c7496dcd3b9..d41885ec9936 100644 --- a/pkg/controllers/execution/execution_controller.go +++ b/pkg/controllers/execution/execution_controller.go @@ -79,19 +79,19 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } clusterName, err := names.GetClusterName(work.Namespace) if err != nil { klog.Errorf("Failed to get member cluster name for work %s/%s", work.Namespace, work.Name) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } cluster, err := util.GetCluster(c.Client, clusterName) if err != nil { klog.Errorf("Failed to get the given member cluster %s", clusterName) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !work.DeletionTimestamp.IsZero() { @@ -100,10 +100,10 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques err := c.tryDeleteWorkload(clusterName, work) if err != nil { klog.Errorf("Failed to delete work %v, namespace is %v, err is %v", work.Name, work.Namespace, err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } } else if cluster.DeletionTimestamp.IsZero() { // cluster is unready, but not terminating - return controllerruntime.Result{Requeue: true}, fmt.Errorf("cluster(%s) not ready", cluster.Name) + return controllerruntime.Result{}, fmt.Errorf("cluster(%s) not ready", cluster.Name) } return c.removeFinalizer(work) @@ -111,7 +111,7 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques if !util.IsClusterReady(&cluster.Status) { klog.Errorf("Stop sync work(%s/%s) for cluster(%s) as cluster not ready.", work.Namespace, work.Name, cluster.Name) - return controllerruntime.Result{Requeue: true}, fmt.Errorf("cluster(%s) not ready", cluster.Name) + return controllerruntime.Result{}, fmt.Errorf("cluster(%s) not ready", cluster.Name) } return c.syncWork(clusterName, work) @@ -136,7 +136,7 @@ func (c *Controller) syncWork(clusterName string, work *workv1alpha1.Work) (cont msg := fmt.Sprintf("Failed to sync work(%s) to cluster(%s): %v", work.Name, clusterName, err) klog.Errorf(msg) c.EventRecorder.Event(work, corev1.EventTypeWarning, events.EventReasonSyncWorkloadFailed, msg) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } msg := fmt.Sprintf("Sync work (%s) to cluster(%s) successful.", work.Name, clusterName) klog.V(4).Infof(msg) @@ -194,7 +194,7 @@ func (c *Controller) removeFinalizer(work *workv1alpha1.Work) (controllerruntime controllerutil.RemoveFinalizer(work, util.ExecutionControllerFinalizer) err := c.Client.Update(context.TODO(), work) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil } diff --git a/pkg/controllers/federatedresourcequota/federated_resource_quota_status_controller.go b/pkg/controllers/federatedresourcequota/federated_resource_quota_status_controller.go index 23dd982b8dda..8034a86e2be2 100644 --- a/pkg/controllers/federatedresourcequota/federated_resource_quota_status_controller.go +++ b/pkg/controllers/federatedresourcequota/federated_resource_quota_status_controller.go @@ -70,7 +70,7 @@ func (c *StatusController) Reconcile(ctx context.Context, req controllerruntime. if apierrors.IsNotFound(err) { return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !quota.DeletionTimestamp.IsZero() { @@ -80,7 +80,7 @@ func (c *StatusController) Reconcile(ctx context.Context, req controllerruntime. if err := c.collectQuotaStatus(quota); err != nil { klog.Errorf("Failed to collect status from works to federatedResourceQuota(%s), error: %v", req.NamespacedName.String(), err) c.EventRecorder.Eventf(quota, corev1.EventTypeWarning, events.EventReasonCollectFederatedResourceQuotaStatusFailed, err.Error()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } c.EventRecorder.Eventf(quota, corev1.EventTypeNormal, events.EventReasonCollectFederatedResourceQuotaStatusSucceed, "Collect status of FederatedResourceQuota(%s) succeed.", req.NamespacedName.String()) return controllerruntime.Result{}, nil diff --git a/pkg/controllers/federatedresourcequota/federated_resource_quota_sync_controller.go b/pkg/controllers/federatedresourcequota/federated_resource_quota_sync_controller.go index 78aac7b1d727..6c2a49844424 100644 --- a/pkg/controllers/federatedresourcequota/federated_resource_quota_sync_controller.go +++ b/pkg/controllers/federatedresourcequota/federated_resource_quota_sync_controller.go @@ -67,23 +67,23 @@ func (c *SyncController) Reconcile(ctx context.Context, req controllerruntime.Re klog.V(4).Infof("Begin to cleanup works created by federatedResourceQuota(%s)", req.NamespacedName.String()) if err = c.cleanUpWorks(req.Namespace, req.Name); err != nil { klog.Errorf("Failed to cleanup works created by federatedResourceQuota(%s)", req.NamespacedName.String()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } clusterList := &clusterv1alpha1.ClusterList{} if err := c.Client.List(ctx, clusterList); err != nil { klog.Errorf("Failed to list clusters, error: %v", err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if err := c.buildWorks(quota, clusterList.Items); err != nil { klog.Errorf("Failed to build works for federatedResourceQuota(%s), error: %v", req.NamespacedName.String(), err) c.EventRecorder.Eventf(quota, corev1.EventTypeWarning, events.EventReasonSyncFederatedResourceQuotaFailed, err.Error()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } c.EventRecorder.Eventf(quota, corev1.EventTypeNormal, events.EventReasonSyncFederatedResourceQuotaSucceed, "Sync works for FederatedResourceQuota(%s) succeed.", req.NamespacedName.String()) diff --git a/pkg/controllers/gracefuleviction/crb_graceful_eviction_controller.go b/pkg/controllers/gracefuleviction/crb_graceful_eviction_controller.go index 1c03cfba1cf1..ff2fdf3a91fb 100644 --- a/pkg/controllers/gracefuleviction/crb_graceful_eviction_controller.go +++ b/pkg/controllers/gracefuleviction/crb_graceful_eviction_controller.go @@ -59,7 +59,7 @@ func (c *CRBGracefulEvictionController) Reconcile(ctx context.Context, req contr if apierrors.IsNotFound(err) { return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !binding.DeletionTimestamp.IsZero() { @@ -68,7 +68,7 @@ func (c *CRBGracefulEvictionController) Reconcile(ctx context.Context, req contr retryDuration, err := c.syncBinding(binding) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if retryDuration > 0 { klog.V(4).Infof("Retry to evict task after %v minutes.", retryDuration.Minutes()) diff --git a/pkg/controllers/gracefuleviction/rb_graceful_eviction_controller.go b/pkg/controllers/gracefuleviction/rb_graceful_eviction_controller.go index 6f35718dc806..1973e087ff77 100644 --- a/pkg/controllers/gracefuleviction/rb_graceful_eviction_controller.go +++ b/pkg/controllers/gracefuleviction/rb_graceful_eviction_controller.go @@ -59,7 +59,7 @@ func (c *RBGracefulEvictionController) Reconcile(ctx context.Context, req contro if apierrors.IsNotFound(err) { return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !binding.DeletionTimestamp.IsZero() { @@ -68,7 +68,7 @@ func (c *RBGracefulEvictionController) Reconcile(ctx context.Context, req contro retryDuration, err := c.syncBinding(binding) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if retryDuration > 0 { klog.V(4).Infof("Retry to evict task after %v minutes.", retryDuration.Minutes()) diff --git a/pkg/controllers/mcs/service_import_controller.go b/pkg/controllers/mcs/service_import_controller.go index 7cb50c68ecaf..329e5256e0c5 100644 --- a/pkg/controllers/mcs/service_import_controller.go +++ b/pkg/controllers/mcs/service_import_controller.go @@ -54,7 +54,7 @@ func (c *ServiceImportController) Reconcile(ctx context.Context, req controllerr return c.deleteDerivedService(req.NamespacedName) } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !svcImport.DeletionTimestamp.IsZero() || svcImport.Spec.Type != mcsv1alpha1.ClusterSetIP { @@ -63,7 +63,7 @@ func (c *ServiceImportController) Reconcile(ctx context.Context, req controllerr if err := c.deriveServiceFromServiceImport(svcImport); err != nil { c.EventRecorder.Eventf(svcImport, corev1.EventTypeWarning, events.EventReasonSyncDerivedServiceFailed, err.Error()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } c.EventRecorder.Eventf(svcImport, corev1.EventTypeNormal, events.EventReasonSyncDerivedServiceSucceed, "Sync derived service for serviceImport(%s) succeed.", svcImport.Name) return controllerruntime.Result{}, nil @@ -86,13 +86,13 @@ func (c *ServiceImportController) deleteDerivedService(svcImport types.Namespace return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } err = c.Client.Delete(context.TODO(), derivedSvc) if err != nil && !apierrors.IsNotFound(err) { klog.Errorf("Delete derived service(%s) failed, Error: %v", derivedSvcNamespacedName, err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil diff --git a/pkg/controllers/multiclusterservice/endpointslice_collect_controller.go b/pkg/controllers/multiclusterservice/endpointslice_collect_controller.go index 95c4b0b6d630..5bf535f3b738 100644 --- a/pkg/controllers/multiclusterservice/endpointslice_collect_controller.go +++ b/pkg/controllers/multiclusterservice/endpointslice_collect_controller.go @@ -86,7 +86,7 @@ func (c *EndpointSliceCollectController) Reconcile(ctx context.Context, req cont if apierrors.IsNotFound(err) { return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !helper.IsWorkContains(work.Spec.Workload.Manifests, multiClusterServiceGVK) { @@ -101,15 +101,15 @@ func (c *EndpointSliceCollectController) Reconcile(ctx context.Context, req cont clusterName, err := names.GetClusterName(work.Namespace) if err != nil { klog.Errorf("Failed to get cluster name for work %s/%s", work.Namespace, work.Name) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if err = c.buildResourceInformers(clusterName); err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if err = c.collectTargetEndpointSlice(work, clusterName); err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil diff --git a/pkg/controllers/multiclusterservice/endpointslice_dispatch_controller.go b/pkg/controllers/multiclusterservice/endpointslice_dispatch_controller.go index adf7660ebfe2..bf65147c11e7 100644 --- a/pkg/controllers/multiclusterservice/endpointslice_dispatch_controller.go +++ b/pkg/controllers/multiclusterservice/endpointslice_dispatch_controller.go @@ -69,7 +69,7 @@ func (c *EndpointsliceDispatchController) Reconcile(ctx context.Context, req con if apierrors.IsNotFound(err) { return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !helper.IsWorkContains(work.Spec.Workload.Manifests, util.EndpointSliceGVK) { @@ -80,7 +80,7 @@ func (c *EndpointsliceDispatchController) Reconcile(ctx context.Context, req con if !work.DeletionTimestamp.IsZero() || mcsName == "" { if err := c.cleanupEndpointSliceFromConsumerClusters(ctx, work); err != nil { klog.Errorf("Failed to cleanup EndpointSlice from consumer clusters for work %s/%s:%v", work.Namespace, work.Name, err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil } @@ -92,7 +92,7 @@ func (c *EndpointsliceDispatchController) Reconcile(ctx context.Context, req con klog.Warningf("MultiClusterService %s/%s is not found", mcsNS, mcsName) return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } var err error @@ -107,11 +107,11 @@ func (c *EndpointsliceDispatchController) Reconcile(ctx context.Context, req con }() if err = c.cleanOrphanDispatchedEndpointSlice(ctx, mcs); err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if err = c.dispatchEndpointSlice(ctx, work.DeepCopy(), mcs); err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil diff --git a/pkg/controllers/namespace/namespace_sync_controller.go b/pkg/controllers/namespace/namespace_sync_controller.go index 2a29e32644cb..efed0d6bce78 100644 --- a/pkg/controllers/namespace/namespace_sync_controller.go +++ b/pkg/controllers/namespace/namespace_sync_controller.go @@ -77,7 +77,7 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !namespace.DeletionTimestamp.IsZero() { @@ -95,13 +95,13 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques clusterList := &clusterv1alpha1.ClusterList{} if err := c.Client.List(ctx, clusterList); err != nil { klog.Errorf("Failed to list clusters, error: %v", err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } err := c.buildWorks(namespace, clusterList.Items) if err != nil { klog.Errorf("Failed to build work for namespace %s. Error: %v.", namespace.GetName(), err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil diff --git a/pkg/controllers/status/cluster_status_controller.go b/pkg/controllers/status/cluster_status_controller.go index 9f4ae02e5cf8..d94bff005344 100644 --- a/pkg/controllers/status/cluster_status_controller.go +++ b/pkg/controllers/status/cluster_status_controller.go @@ -143,7 +143,7 @@ func (c *ClusterStatusController) Reconcile(ctx context.Context, req controllerr return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } // start syncing status only when the finalizer is present on the given Cluster to @@ -213,7 +213,7 @@ func (c *ClusterStatusController) syncClusterStatus(cluster *clusterv1alpha1.Clu err := c.setCurrentClusterStatus(clusterClient, cluster, ¤tClusterStatus) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } } @@ -293,7 +293,7 @@ func (c *ClusterStatusController) updateStatusIfNeeded(cluster *clusterv1alpha1. }) if err != nil { klog.Errorf("Failed to update health status of the member cluster: %v, err is : %v", cluster.Name, err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } } diff --git a/pkg/controllers/status/cluster_status_controller_test.go b/pkg/controllers/status/cluster_status_controller_test.go index f9b9bd1bbedf..f4ee028bb24e 100644 --- a/pkg/controllers/status/cluster_status_controller_test.go +++ b/pkg/controllers/status/cluster_status_controller_test.go @@ -979,7 +979,7 @@ func TestClusterStatusController_updateStatusIfNeeded(t *testing.T) { } actual, err := c.updateStatusIfNeeded(cluster, currentClusterStatus) - expect := controllerruntime.Result{Requeue: true} + expect := controllerruntime.Result{} assert.Equal(t, expect, actual) assert.NotEmpty(t, err, "updateStatusIfNeeded doesn't return error") }) diff --git a/pkg/controllers/status/crb_status_controller.go b/pkg/controllers/status/crb_status_controller.go index ae04bee082f3..9d2888a387a3 100644 --- a/pkg/controllers/status/crb_status_controller.go +++ b/pkg/controllers/status/crb_status_controller.go @@ -67,7 +67,7 @@ func (c *CRBStatusController) Reconcile(ctx context.Context, req controllerrunti return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } // The crb is being deleted, in which case we stop processing. @@ -77,7 +77,7 @@ func (c *CRBStatusController) Reconcile(ctx context.Context, req controllerrunti err := c.syncBindingStatus(binding) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil } diff --git a/pkg/controllers/status/rb_status_controller.go b/pkg/controllers/status/rb_status_controller.go index a0cc7ef0eebf..3d6c13c2ad25 100644 --- a/pkg/controllers/status/rb_status_controller.go +++ b/pkg/controllers/status/rb_status_controller.go @@ -67,7 +67,7 @@ func (c *RBStatusController) Reconcile(ctx context.Context, req controllerruntim return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } // The rb is being deleted, in which case we stop processing. @@ -77,7 +77,7 @@ func (c *RBStatusController) Reconcile(ctx context.Context, req controllerruntim err := c.syncBindingStatus(binding) if err != nil { - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil } diff --git a/pkg/controllers/status/work_status_controller.go b/pkg/controllers/status/work_status_controller.go index 1fda70a9df80..cbb8cdda2914 100644 --- a/pkg/controllers/status/work_status_controller.go +++ b/pkg/controllers/status/work_status_controller.go @@ -88,7 +88,7 @@ func (c *WorkStatusController) Reconcile(ctx context.Context, req controllerrunt return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !work.DeletionTimestamp.IsZero() { @@ -102,18 +102,18 @@ func (c *WorkStatusController) Reconcile(ctx context.Context, req controllerrunt clusterName, err := names.GetClusterName(work.GetNamespace()) if err != nil { klog.Errorf("Failed to get member cluster name by %s. Error: %v.", work.GetNamespace(), err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } cluster, err := util.GetCluster(c.Client, clusterName) if err != nil { klog.Errorf("Failed to the get given member cluster %s", clusterName) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !util.IsClusterReady(&cluster.Status) { klog.Errorf("Stop sync work(%s/%s) for cluster(%s) as cluster not ready.", work.Namespace, work.Name, cluster.Name) - return controllerruntime.Result{Requeue: true}, fmt.Errorf("cluster(%s) not ready", cluster.Name) + return controllerruntime.Result{}, fmt.Errorf("cluster(%s) not ready", cluster.Name) } return c.buildResourceInformers(cluster, work) @@ -125,7 +125,7 @@ func (c *WorkStatusController) buildResourceInformers(cluster *clusterv1alpha1.C err := c.registerInformersAndStart(cluster, work) if err != nil { klog.Errorf("Failed to register informer for Work %s/%s. Error: %v.", work.GetNamespace(), work.GetName(), err) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } return controllerruntime.Result{}, nil } diff --git a/pkg/controllers/status/work_status_controller_test.go b/pkg/controllers/status/work_status_controller_test.go index 97e70b33948c..68274e847f35 100644 --- a/pkg/controllers/status/work_status_controller_test.go +++ b/pkg/controllers/status/work_status_controller_test.go @@ -235,7 +235,7 @@ func TestWorkStatusController_Reconcile(t *testing.T) { }, }, ns: "karmada-cluster", - expectRes: controllerruntime.Result{Requeue: true}, + expectRes: controllerruntime.Result{}, existErr: true, }, { @@ -263,7 +263,7 @@ func TestWorkStatusController_Reconcile(t *testing.T) { }, }, ns: "karmada-es-cluster", - expectRes: controllerruntime.Result{Requeue: true}, + expectRes: controllerruntime.Result{}, existErr: true, }, { @@ -291,7 +291,7 @@ func TestWorkStatusController_Reconcile(t *testing.T) { }, }, ns: "karmada-es-cluster", - expectRes: controllerruntime.Result{Requeue: true}, + expectRes: controllerruntime.Result{}, existErr: true, }, } diff --git a/pkg/controllers/unifiedauth/unified_auth_controller.go b/pkg/controllers/unifiedauth/unified_auth_controller.go index 1a32f5114e0b..63545d4633e0 100644 --- a/pkg/controllers/unifiedauth/unified_auth_controller.go +++ b/pkg/controllers/unifiedauth/unified_auth_controller.go @@ -73,7 +73,7 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques return controllerruntime.Result{}, nil } - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } if !cluster.DeletionTimestamp.IsZero() { @@ -91,7 +91,7 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques if err != nil { klog.Errorf("Failed to sync impersonation config for cluster %s. Error: %v.", cluster.Name, err) c.EventRecorder.Eventf(cluster, corev1.EventTypeWarning, events.EventReasonSyncImpersonationConfigFailed, err.Error()) - return controllerruntime.Result{Requeue: true}, err + return controllerruntime.Result{}, err } c.EventRecorder.Eventf(cluster, corev1.EventTypeNormal, events.EventReasonSyncImpersonationConfigSucceed, "Sync impersonation config succeed.")