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

🐛 Fix init lock #232

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions controllers/kubeadmconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,6 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
}
}()

holdLock := false
defer func() {
if !holdLock {
r.KubeadmInitLock.Unlock(ctx, cluster)
}
}()

if !cluster.Status.ControlPlaneInitialized {
// if it's NOT a control plane machine, requeue
if !util.IsControlPlaneMachine(machine) {
Expand All @@ -190,6 +183,12 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
}

defer func() {
if rerr != nil {
r.KubeadmInitLock.Unlock(ctx, cluster)
}
}()

log.Info("Creating BootstrapData for the init control plane")

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

holdLock = true

return ctrl.Result{}, nil
}

Expand Down