Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 7c32f34

Browse files
committed
Fix init lock
Signed-off-by: JunLi <[email protected]>
1 parent 46acfbd commit 7c32f34

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

controllers/kubeadmconfig_controller.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,12 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
162162
}
163163
}()
164164

165-
holdLock := false
166-
defer func() {
167-
if !holdLock {
168-
r.KubeadmInitLock.Unlock(ctx, cluster)
169-
}
170-
}()
171-
172165
if !cluster.Status.ControlPlaneInitialized {
166+
defer func() {
167+
if rerr != nil {
168+
r.KubeadmInitLock.Unlock(ctx, cluster)
169+
}
170+
}()
173171
// if it's NOT a control plane machine, requeue
174172
if !util.IsControlPlaneMachine(machine) {
175173
log.Info(fmt.Sprintf("Machine is not a control plane. If it should be a control plane, add `%s: true` as a label to the Machine", clusterv1.MachineControlPlaneLabelName))
@@ -254,8 +252,6 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
254252
config.Status.BootstrapData = cloudInitData
255253
config.Status.Ready = true
256254

257-
holdLock = true
258-
259255
return ctrl.Result{}, nil
260256
}
261257

0 commit comments

Comments
 (0)