diff --git a/internal/controllers/machine/machine_controller_phases.go b/internal/controllers/machine/machine_controller_phases.go index f7e53d0ce232..6d00dbebca27 100644 --- a/internal/controllers/machine/machine_controller_phases.go +++ b/internal/controllers/machine/machine_controller_phases.go @@ -132,29 +132,26 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Res cluster := s.cluster m := s.machine - // If the Bootstrap ref is nil (and so the machine should use user generated data secret), return. - if m.Spec.Bootstrap.ConfigRef == nil { - return ctrl.Result{}, nil - } - - // Call generic external reconciler if we have an external reference. - obj, err := r.reconcileExternal(ctx, cluster, m, m.Spec.Bootstrap.ConfigRef) - if err != nil { - if apierrors.IsNotFound(err) { - s.bootstrapConfigIsNotFound = true - - if !s.machine.DeletionTimestamp.IsZero() { - // Tolerate bootstrap object not found when the machine is being deleted. - // TODO: we can also relax this and tolerate the absence of the bootstrap ref way before, e.g. after node ref is set - return ctrl.Result{}, nil + if m.Spec.Bootstrap.ConfigRef != nil { + // Call generic external reconciler if we have an external reference. + obj, err := r.reconcileExternal(ctx, cluster, m, m.Spec.Bootstrap.ConfigRef) + if err != nil { + if apierrors.IsNotFound(err) { + s.bootstrapConfigIsNotFound = true + + if !s.machine.DeletionTimestamp.IsZero() { + // Tolerate bootstrap object not found when the machine is being deleted. + // TODO: we can also relax this and tolerate the absence of the bootstrap ref way before, e.g. after node ref is set + return ctrl.Result{}, nil + } + 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)) + // TODO: we can make this smarter and requeue only if we are before node ref is set + return ctrl.Result{RequeueAfter: externalReadyWait}, nil } - 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)) - // TODO: we can make this smarter and requeue only if we are before node ref is set - return ctrl.Result{RequeueAfter: externalReadyWait}, nil + return ctrl.Result{}, err } - return ctrl.Result{}, err + s.bootstrapConfig = obj } - s.bootstrapConfig = obj // If the bootstrap data is populated, set ready and return. if m.Spec.Bootstrap.DataSecretName != nil { @@ -163,6 +160,11 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Res return ctrl.Result{}, nil } + // If the Bootstrap ref is nil (and so the machine should use user generated data secret), return. + if m.Spec.Bootstrap.ConfigRef == nil { + return ctrl.Result{}, nil + } + // Determine if the bootstrap provider is ready. ready, err := external.IsReady(s.bootstrapConfig) if err != nil {