-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Set Machine's BootstrapReady when there is no ConfigRef #11459
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this come after reconciling the bootstrap config? The data secret name is either set by the user, in which case bootstrap config is not needed, or, it is set by the bootstrap provider, in which case the bootstrap config has already been reconciled. Wondering if we just need to move this block above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe #7394 has the answer to that:
|
||
|
@@ -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 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
So we take care of user provided data secret first, and then we handle when data secret is generated by the bootstrap provider (without mixing the two use cases)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like it would work (though people thought the same about this). I guess it comes down to whether it's worse to duplicate the code that marks the bootstrap ready, or to duplicate an
if
statement.