Skip to content

Commit 834bead

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 834bead

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

internal/controllers/machine/machine_controller_phases.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ func (r *Reconciler) ensureExternalOwnershipAndWatch(ctx context.Context, cluste
126126
return obj, nil
127127
}
128128

129+
// checkMachineBootstrapReady checks if the bootstrap data for a Machine is
130+
// available and marks it as ready if so.
131+
func checkMachineBootstrapReady(m *Machine) bool {
132+
if m.Spec.Bootstrap.DataSecretName != nil {
133+
m.Status.BootstrapReady = true
134+
conditions.MarkTrue(m, clusterv1.BootstrapReadyCondition)
135+
return true
136+
}
137+
return false
138+
}
139+
129140
// reconcileBootstrap reconciles the Spec.Bootstrap.ConfigRef object on a Machine.
130141
func (r *Reconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Result, error) {
131142
log := ctrl.LoggerFrom(ctx)
@@ -134,6 +145,8 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Res
134145

135146
// If the Bootstrap ref is nil (and so the machine should use user generated data secret), return.
136147
if m.Spec.Bootstrap.ConfigRef == nil {
148+
// If the bootstrap data is populated, set ready.
149+
_ = checkMachineBootstrapReady(m)
137150
return ctrl.Result{}, nil
138151
}
139152

@@ -157,9 +170,7 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Res
157170
s.bootstrapConfig = obj
158171

159172
// If the bootstrap data is populated, set ready and return.
160-
if m.Spec.Bootstrap.DataSecretName != nil {
161-
m.Status.BootstrapReady = true
162-
conditions.MarkTrue(m, clusterv1.BootstrapReadyCondition)
173+
if checkMachineBootstrapReady(m) {
163174
return ctrl.Result{}, nil
164175
}
165176

0 commit comments

Comments
 (0)