Skip to content

Commit 8ebd235

Browse files
committed
Set Machine's BootstrapReady when there is no ConfigRef
If there is no ConfigRef but the bootstrap data secret is set by the user (instead of a bootstrap provider), then BootstrapReady should be true. This is the case for MachineSet, and was originally the case for Machine since 5113f80. However, in d93eadc this changed as a side effect of ensuring that bootstrap config object can continue to be reconciled after the bootstrap provider has produced the bootstrap data secret. This change ensures that, once a bootstrap data secret exists, in the case of a ConfigRef it can still be reconciled, while in the case there is no ConfigRef, BootstrapReady is set. Signed-off-by: Zane Bitter <[email protected]>
1 parent 5bd7ded commit 8ebd235

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

internal/controllers/machine/machine_controller_phases.go

+22-20
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,26 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Res
132132
cluster := s.cluster
133133
m := s.machine
134134

135-
// If the Bootstrap ref is nil (and so the machine should use user generated data secret), return.
136-
if m.Spec.Bootstrap.ConfigRef == nil {
137-
return ctrl.Result{}, nil
138-
}
139-
140-
// Call generic external reconciler if we have an external reference.
141-
obj, err := r.reconcileExternal(ctx, cluster, m, m.Spec.Bootstrap.ConfigRef)
142-
if err != nil {
143-
if apierrors.IsNotFound(err) {
144-
s.bootstrapConfigIsNotFound = true
145-
146-
if !s.machine.DeletionTimestamp.IsZero() {
147-
// Tolerate bootstrap object not found when the machine is being deleted.
148-
// TODO: we can also relax this and tolerate the absence of the bootstrap ref way before, e.g. after node ref is set
149-
return ctrl.Result{}, nil
135+
if m.Spec.Bootstrap.ConfigRef != nil {
136+
// Call generic external reconciler if we have an external reference.
137+
obj, err := r.reconcileExternal(ctx, cluster, m, m.Spec.Bootstrap.ConfigRef)
138+
if err != nil {
139+
if apierrors.IsNotFound(err) {
140+
s.bootstrapConfigIsNotFound = true
141+
142+
if !s.machine.DeletionTimestamp.IsZero() {
143+
// Tolerate bootstrap object not found when the machine is being deleted.
144+
// TODO: we can also relax this and tolerate the absence of the bootstrap ref way before, e.g. after node ref is set
145+
return ctrl.Result{}, nil
146+
}
147+
log.Info("Could not find bootstrap config object, requeuing", m.Spec.Bootstrap.ConfigRef.Kind, klog.KRef(m.Spec.Bootstrap.ConfigRef.Namespace, m.Spec.Bootstrap.ConfigRef.Name))
148+
// TODO: we can make this smarter and requeue only if we are before node ref is set
149+
return ctrl.Result{RequeueAfter: externalReadyWait}, nil
150150
}
151-
log.Info("Could not find bootstrap config object, requeuing", m.Spec.Bootstrap.ConfigRef.Kind, klog.KRef(m.Spec.Bootstrap.ConfigRef.Namespace, m.Spec.Bootstrap.ConfigRef.Name))
152-
// TODO: we can make this smarter and requeue only if we are before node ref is set
153-
return ctrl.Result{RequeueAfter: externalReadyWait}, nil
151+
return ctrl.Result{}, err
154152
}
155-
return ctrl.Result{}, err
153+
s.bootstrapConfig = obj
156154
}
157-
s.bootstrapConfig = obj
158155

159156
// If the bootstrap data is populated, set ready and return.
160157
if m.Spec.Bootstrap.DataSecretName != nil {
@@ -163,6 +160,11 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Res
163160
return ctrl.Result{}, nil
164161
}
165162

163+
// If the Bootstrap ref is nil (and so the machine should use user generated data secret), return.
164+
if m.Spec.Bootstrap.ConfigRef == nil {
165+
return ctrl.Result{}, nil
166+
}
167+
166168
// Determine if the bootstrap provider is ready.
167169
ready, err := external.IsReady(s.bootstrapConfig)
168170
if err != nil {

0 commit comments

Comments
 (0)