diff --git a/internal/controllers/import_controller_v3.go b/internal/controllers/import_controller_v3.go index 984dd2f1..8d75303f 100644 --- a/internal/controllers/import_controller_v3.go +++ b/internal/controllers/import_controller_v3.go @@ -27,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" errorutils "k8s.io/apimachinery/pkg/util/errors" "k8s.io/client-go/tools/record" - "k8s.io/client-go/util/retry" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -184,13 +183,8 @@ func (r *CAPIImportManagementV3Reconciler) Reconcile(ctx context.Context, req ct errs = append(errs, fmt.Errorf("error reconciling cluster: %w", err)) } - if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { - if err := r.Client.Patch(ctx, capiCluster, patchBase); err != nil { - errs = append(errs, fmt.Errorf("failed to patch cluster: %w", err)) - } - return nil - }); err != nil { - return ctrl.Result{}, err + if err := r.Client.Patch(ctx, capiCluster, patchBase); err != nil { + errs = append(errs, fmt.Errorf("failed to patch cluster: %w", err)) } if len(errs) > 0 { diff --git a/internal/controllers/patch_kcfg_controller.go b/internal/controllers/patch_kcfg_controller.go index 572e2dc5..97d887fd 100644 --- a/internal/controllers/patch_kcfg_controller.go +++ b/internal/controllers/patch_kcfg_controller.go @@ -25,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "k8s.io/client-go/util/retry" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -113,26 +112,21 @@ func (r *RancherKubeconfigSecretReconciler) Reconcile(ctx context.Context, req c return ctrl.Result{}, nil } - if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { - secretCopy := secret.DeepCopy() - if secretCopy.Labels == nil { - secretCopy.Labels = map[string]string{} - } - secretCopy.Labels[clusterv1.ClusterNameLabel] = clusterName + secretCopy := secret.DeepCopy() + if secretCopy.Labels == nil { + secretCopy.Labels = map[string]string{} + } - patchBase := client.MergeFromWithOptions(secret, client.MergeFromWithOptimisticLock{}) + secretCopy.Labels[clusterv1.ClusterNameLabel] = clusterName - if err := r.Client.Patch(ctx, secretCopy, patchBase); err != nil { - return fmt.Errorf("failed to patch secret: %w", err) - } + patchBase := client.MergeFromWithOptions(secret, client.MergeFromWithOptimisticLock{}) - log.V(4).Info("patched kubeconfig secret", "name", secret.Name, "namespace", secret.Namespace, "cluster", clusterName) - - return nil - }); err != nil { - return ctrl.Result{}, err + if err := r.Client.Patch(ctx, secretCopy, patchBase); err != nil { + return ctrl.Result{}, fmt.Errorf("failed to patch secret: %w", err) } + log.V(4).Info("patched kubeconfig secret", "name", secret.Name, "namespace", secret.Namespace, "cluster", clusterName) + return ctrl.Result{}, nil }