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

Commit b7c1ea3

Browse files
authored
Merge pull request #232 from accepting/dev
🐛 Fix init lock
2 parents 53d5475 + 107a30b commit b7c1ea3

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
@@ -161,13 +161,6 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
161161
}
162162
}()
163163

164-
holdLock := false
165-
defer func() {
166-
if !holdLock {
167-
r.KubeadmInitLock.Unlock(ctx, cluster)
168-
}
169-
}()
170-
171164
if !cluster.Status.ControlPlaneInitialized {
172165
// if it's NOT a control plane machine, requeue
173166
if !util.IsControlPlaneMachine(machine) {
@@ -189,6 +182,12 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
189182
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
190183
}
191184

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

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

256-
holdLock = true
257-
258255
return ctrl.Result{}, nil
259256
}
260257

0 commit comments

Comments
 (0)