Skip to content

Commit 469e0d8

Browse files
authored
Merge pull request #11400 from sbueringer/pr-remove-reconcile-external-pause
🌱 Remove paused handling from reconcileExternal
2 parents e5c47ee + 14c1111 commit 469e0d8

File tree

4 files changed

+3
-67
lines changed

4 files changed

+3
-67
lines changed

controllers/external/types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,4 @@ type ReconcileOutput struct {
3535
// Details of the referenced external object.
3636
// +optional
3737
Result *unstructured.Unstructured
38-
// Indicates if the external object is paused.
39-
// +optional
40-
Paused bool
4138
}

exp/internal/controllers/machinepool_controller_phases.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) {
106106
}
107107

108108
// reconcileExternal handles generic unstructured objects referenced by a MachinePool.
109-
func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, cluster *clusterv1.Cluster, m *expv1.MachinePool, ref *corev1.ObjectReference) (external.ReconcileOutput, error) {
109+
func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, m *expv1.MachinePool, ref *corev1.ObjectReference) (external.ReconcileOutput, error) {
110110
log := ctrl.LoggerFrom(ctx)
111111

112112
if err := utilconversion.UpdateReferenceAPIContract(ctx, r.Client, ref); err != nil {
@@ -127,12 +127,6 @@ func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, cluster *
127127
return external.ReconcileOutput{}, err
128128
}
129129

130-
// if external ref is paused, return error.
131-
if annotations.IsPaused(cluster, obj) {
132-
log.V(3).Info("External object referenced is paused")
133-
return external.ReconcileOutput{Paused: true}, nil
134-
}
135-
136130
// Initialize the patch helper.
137131
patchHelper, err := patch.NewHelper(obj, r.Client)
138132
if err != nil {
@@ -179,19 +173,14 @@ func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, cluster *
179173
// reconcileBootstrap reconciles the Spec.Bootstrap.ConfigRef object on a MachinePool.
180174
func (r *MachinePoolReconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Result, error) {
181175
log := ctrl.LoggerFrom(ctx)
182-
cluster := s.cluster
183176
m := s.machinePool
184177
// Call generic external reconciler if we have an external reference.
185178
var bootstrapConfig *unstructured.Unstructured
186179
if m.Spec.Template.Spec.Bootstrap.ConfigRef != nil {
187-
bootstrapReconcileResult, err := r.reconcileExternal(ctx, cluster, m, m.Spec.Template.Spec.Bootstrap.ConfigRef)
180+
bootstrapReconcileResult, err := r.reconcileExternal(ctx, m, m.Spec.Template.Spec.Bootstrap.ConfigRef)
188181
if err != nil {
189182
return ctrl.Result{}, err
190183
}
191-
// if the external object is paused, return without any further processing
192-
if bootstrapReconcileResult.Paused {
193-
return ctrl.Result{}, nil
194-
}
195184
bootstrapConfig = bootstrapReconcileResult.Result
196185

197186
// If the bootstrap config is being deleted, return early.
@@ -247,7 +236,7 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s *
247236
cluster := s.cluster
248237
mp := s.machinePool
249238
// Call generic external reconciler.
250-
infraReconcileResult, err := r.reconcileExternal(ctx, cluster, mp, &mp.Spec.Template.Spec.InfrastructureRef)
239+
infraReconcileResult, err := r.reconcileExternal(ctx, mp, &mp.Spec.Template.Spec.InfrastructureRef)
251240
if err != nil {
252241
if apierrors.IsNotFound(errors.Cause(err)) {
253242
log.Error(err, "infrastructure reference could not be found")
@@ -262,10 +251,6 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s *
262251
}
263252
return ctrl.Result{}, err
264253
}
265-
// if the external object is paused, return without any further processing
266-
if infraReconcileResult.Paused {
267-
return ctrl.Result{}, nil
268-
}
269254
infraConfig := infraReconcileResult.Result
270255

271256
if !infraConfig.GetDeletionTimestamp().IsZero() {

exp/internal/controllers/machinepool_controller_phases_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,43 +1229,6 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) {
12291229
g.Expect(m.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseFailed))
12301230
},
12311231
},
1232-
{
1233-
name: "infrastructure ref is paused",
1234-
infraConfig: map[string]interface{}{
1235-
"kind": builder.TestInfrastructureMachineTemplateKind,
1236-
"apiVersion": builder.InfrastructureGroupVersion.String(),
1237-
"metadata": map[string]interface{}{
1238-
"name": "infra-config1",
1239-
"namespace": metav1.NamespaceDefault,
1240-
"annotations": map[string]interface{}{
1241-
"cluster.x-k8s.io/paused": "true",
1242-
},
1243-
},
1244-
"spec": map[string]interface{}{
1245-
"providerIDList": []interface{}{
1246-
"test://id-1",
1247-
},
1248-
},
1249-
"status": map[string]interface{}{
1250-
"ready": true,
1251-
"addresses": []interface{}{
1252-
map[string]interface{}{
1253-
"type": "InternalIP",
1254-
"address": "10.0.0.1",
1255-
},
1256-
map[string]interface{}{
1257-
"type": "InternalIP",
1258-
"address": "10.0.0.2",
1259-
},
1260-
},
1261-
},
1262-
},
1263-
expectError: false,
1264-
expectChanged: false,
1265-
expected: func(g *WithT, m *expv1.MachinePool) {
1266-
g.Expect(m.Status.InfrastructureReady).To(BeFalse())
1267-
},
1268-
},
12691232
{
12701233
name: "ready bootstrap, infra, and nodeRef, machinepool is running, replicas 0, providerIDList not set",
12711234
machinepool: &expv1.MachinePool{

internal/controllers/clusterclass/clusterclass_controller.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import (
4747
"sigs.k8s.io/cluster-api/feature"
4848
runtimeclient "sigs.k8s.io/cluster-api/internal/runtime/client"
4949
"sigs.k8s.io/cluster-api/internal/topology/variables"
50-
"sigs.k8s.io/cluster-api/util/annotations"
5150
"sigs.k8s.io/cluster-api/util/conditions"
5251
"sigs.k8s.io/cluster-api/util/conversion"
5352
"sigs.k8s.io/cluster-api/util/patch"
@@ -371,8 +370,6 @@ func refString(ref *corev1.ObjectReference) string {
371370
}
372371

373372
func (r *Reconciler) reconcileExternal(ctx context.Context, clusterClass *clusterv1.ClusterClass, ref *corev1.ObjectReference) error {
374-
log := ctrl.LoggerFrom(ctx)
375-
376373
obj, err := external.Get(ctx, r.Client, ref, clusterClass.Namespace)
377374
if err != nil {
378375
if apierrors.IsNotFound(errors.Cause(err)) {
@@ -381,12 +378,6 @@ func (r *Reconciler) reconcileExternal(ctx context.Context, clusterClass *cluste
381378
return errors.Wrapf(err, "failed to get the external object for the ClusterClass. refGroupVersionKind: %s, refName: %s", ref.GroupVersionKind(), ref.Name)
382379
}
383380

384-
// If referenced object is paused, return early.
385-
if annotations.HasPaused(obj) {
386-
log.V(3).Info("External object referenced is paused", "refGroupVersionKind", ref.GroupVersionKind(), "refName", ref.Name)
387-
return nil
388-
}
389-
390381
// Initialize the patch helper.
391382
patchHelper, err := patch.NewHelper(obj, r.Client)
392383
if err != nil {

0 commit comments

Comments
 (0)