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

Commit 107a30b

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

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

controllers/kubeadmconfig_controller.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,6 @@ 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 {
173166
// if it's NOT a control plane machine, requeue
174167
if !util.IsControlPlaneMachine(machine) {
@@ -190,6 +183,12 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
190183
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
191184
}
192185

186+
defer func() {
187+
if rerr != nil {
188+
r.KubeadmInitLock.Unlock(ctx, cluster)
189+
}
190+
}()
191+
193192
log.Info("Creating BootstrapData for the init control plane")
194193

195194
// get both of ClusterConfiguration and InitConfiguration strings to pass to the cloud init control plane generator
@@ -254,8 +253,6 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
254253
config.Status.BootstrapData = cloudInitData
255254
config.Status.Ready = true
256255

257-
holdLock = true
258-
259256
return ctrl.Result{}, nil
260257
}
261258

0 commit comments

Comments
 (0)