Skip to content

Commit e9ec746

Browse files
authored
Merge pull request #1873 from vincepri/pivot-kubeadm-secret
🐛 Handle CABPK secret case where status has been lost
2 parents 0eae5c6 + d0840ed commit e9ec746

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bootstrap/kubeadm/controllers/kubeadmconfig_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,11 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
173173
// Return early if the configuration and Machine's infrastructure are ready.
174174
case config.Status.Ready && machine.Status.InfrastructureReady:
175175
return ctrl.Result{}, nil
176-
// Reconcile status for machines that have already copied bootstrap data
177-
case machine.Spec.Bootstrap.DataSecretName != nil && !config.Status.Ready:
176+
// Reconcile status for machines that already have a secret reference, but our status isn't up to date.
177+
// This case solves the pivoting scenario (or a backup restore) which doesn't preserve the status subresource on objects.
178+
case machine.Spec.Bootstrap.DataSecretName != nil && (!config.Status.Ready || config.Status.DataSecretName == nil):
178179
config.Status.Ready = true
180+
config.Status.DataSecretName = machine.Spec.Bootstrap.DataSecretName
179181
return ctrl.Result{}, patchHelper.Patch(ctx, config)
180182
// If we've already embedded a time-limited join token into a config, but are still waiting for the token to be used, refresh it
181183
case config.Status.Ready && (config.Spec.JoinConfiguration != nil && config.Spec.JoinConfiguration.Discovery.BootstrapToken != nil):

0 commit comments

Comments
 (0)