From 14c1111ae079b627c2278e23ee896fa63ef680cb Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Mon, 11 Nov 2024 18:15:06 +0100 Subject: [PATCH] Remove paused handling from reconcileExternal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- controllers/external/types.go | 3 -- .../machinepool_controller_phases.go | 21 ++--------- .../machinepool_controller_phases_test.go | 37 ------------------- .../clusterclass/clusterclass_controller.go | 9 ----- 4 files changed, 3 insertions(+), 67 deletions(-) diff --git a/controllers/external/types.go b/controllers/external/types.go index 36d2965d3000..0d9462682611 100644 --- a/controllers/external/types.go +++ b/controllers/external/types.go @@ -35,7 +35,4 @@ type ReconcileOutput struct { // Details of the referenced external object. // +optional Result *unstructured.Unstructured - // Indicates if the external object is paused. - // +optional - Paused bool } diff --git a/exp/internal/controllers/machinepool_controller_phases.go b/exp/internal/controllers/machinepool_controller_phases.go index 3a5474d05914..43533e4d4445 100644 --- a/exp/internal/controllers/machinepool_controller_phases.go +++ b/exp/internal/controllers/machinepool_controller_phases.go @@ -106,7 +106,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) { } // reconcileExternal handles generic unstructured objects referenced by a MachinePool. -func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, cluster *clusterv1.Cluster, m *expv1.MachinePool, ref *corev1.ObjectReference) (external.ReconcileOutput, error) { +func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, m *expv1.MachinePool, ref *corev1.ObjectReference) (external.ReconcileOutput, error) { log := ctrl.LoggerFrom(ctx) if err := utilconversion.UpdateReferenceAPIContract(ctx, r.Client, ref); err != nil { @@ -127,12 +127,6 @@ func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, cluster * return external.ReconcileOutput{}, err } - // if external ref is paused, return error. - if annotations.IsPaused(cluster, obj) { - log.V(3).Info("External object referenced is paused") - return external.ReconcileOutput{Paused: true}, nil - } - // Initialize the patch helper. patchHelper, err := patch.NewHelper(obj, r.Client) if err != nil { @@ -179,19 +173,14 @@ func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, cluster * // reconcileBootstrap reconciles the Spec.Bootstrap.ConfigRef object on a MachinePool. func (r *MachinePoolReconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) - cluster := s.cluster m := s.machinePool // Call generic external reconciler if we have an external reference. var bootstrapConfig *unstructured.Unstructured if m.Spec.Template.Spec.Bootstrap.ConfigRef != nil { - bootstrapReconcileResult, err := r.reconcileExternal(ctx, cluster, m, m.Spec.Template.Spec.Bootstrap.ConfigRef) + bootstrapReconcileResult, err := r.reconcileExternal(ctx, m, m.Spec.Template.Spec.Bootstrap.ConfigRef) if err != nil { return ctrl.Result{}, err } - // if the external object is paused, return without any further processing - if bootstrapReconcileResult.Paused { - return ctrl.Result{}, nil - } bootstrapConfig = bootstrapReconcileResult.Result // If the bootstrap config is being deleted, return early. @@ -247,7 +236,7 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s * cluster := s.cluster mp := s.machinePool // Call generic external reconciler. - infraReconcileResult, err := r.reconcileExternal(ctx, cluster, mp, &mp.Spec.Template.Spec.InfrastructureRef) + infraReconcileResult, err := r.reconcileExternal(ctx, mp, &mp.Spec.Template.Spec.InfrastructureRef) if err != nil { if apierrors.IsNotFound(errors.Cause(err)) { log.Error(err, "infrastructure reference could not be found") @@ -262,10 +251,6 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s * } return ctrl.Result{}, err } - // if the external object is paused, return without any further processing - if infraReconcileResult.Paused { - return ctrl.Result{}, nil - } infraConfig := infraReconcileResult.Result if !infraConfig.GetDeletionTimestamp().IsZero() { diff --git a/exp/internal/controllers/machinepool_controller_phases_test.go b/exp/internal/controllers/machinepool_controller_phases_test.go index 070a0ef923e2..7f9bde6996d9 100644 --- a/exp/internal/controllers/machinepool_controller_phases_test.go +++ b/exp/internal/controllers/machinepool_controller_phases_test.go @@ -1215,43 +1215,6 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) { g.Expect(m.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseFailed)) }, }, - { - name: "infrastructure ref is paused", - infraConfig: map[string]interface{}{ - "kind": builder.TestInfrastructureMachineTemplateKind, - "apiVersion": builder.InfrastructureGroupVersion.String(), - "metadata": map[string]interface{}{ - "name": "infra-config1", - "namespace": metav1.NamespaceDefault, - "annotations": map[string]interface{}{ - "cluster.x-k8s.io/paused": "true", - }, - }, - "spec": map[string]interface{}{ - "providerIDList": []interface{}{ - "test://id-1", - }, - }, - "status": map[string]interface{}{ - "ready": true, - "addresses": []interface{}{ - map[string]interface{}{ - "type": "InternalIP", - "address": "10.0.0.1", - }, - map[string]interface{}{ - "type": "InternalIP", - "address": "10.0.0.2", - }, - }, - }, - }, - expectError: false, - expectChanged: false, - expected: func(g *WithT, m *expv1.MachinePool) { - g.Expect(m.Status.InfrastructureReady).To(BeFalse()) - }, - }, { name: "ready bootstrap, infra, and nodeRef, machinepool is running, replicas 0, providerIDList not set", machinepool: &expv1.MachinePool{ diff --git a/internal/controllers/clusterclass/clusterclass_controller.go b/internal/controllers/clusterclass/clusterclass_controller.go index 14fdc9121c35..da3c2d40ed80 100644 --- a/internal/controllers/clusterclass/clusterclass_controller.go +++ b/internal/controllers/clusterclass/clusterclass_controller.go @@ -47,7 +47,6 @@ import ( "sigs.k8s.io/cluster-api/feature" runtimeclient "sigs.k8s.io/cluster-api/internal/runtime/client" "sigs.k8s.io/cluster-api/internal/topology/variables" - "sigs.k8s.io/cluster-api/util/annotations" "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/cluster-api/util/patch" @@ -371,8 +370,6 @@ func refString(ref *corev1.ObjectReference) string { } func (r *Reconciler) reconcileExternal(ctx context.Context, clusterClass *clusterv1.ClusterClass, ref *corev1.ObjectReference) error { - log := ctrl.LoggerFrom(ctx) - obj, err := external.Get(ctx, r.Client, ref, clusterClass.Namespace) if err != nil { if apierrors.IsNotFound(errors.Cause(err)) { @@ -381,12 +378,6 @@ func (r *Reconciler) reconcileExternal(ctx context.Context, clusterClass *cluste return errors.Wrapf(err, "failed to get the external object for the ClusterClass. refGroupVersionKind: %s, refName: %s", ref.GroupVersionKind(), ref.Name) } - // If referenced object is paused, return early. - if annotations.HasPaused(obj) { - log.V(3).Info("External object referenced is paused", "refGroupVersionKind", ref.GroupVersionKind(), "refName", ref.Name) - return nil - } - // Initialize the patch helper. patchHelper, err := patch.NewHelper(obj, r.Client) if err != nil {