Skip to content

Commit

Permalink
Move health check before upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Sedef committed Apr 2, 2020
1 parent 2ef3bc7 commit 0682a9d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions controlplane/kubeadm/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ func (r *KubeadmControlPlaneReconciler) reconcile(ctx context.Context, cluster *
}

controlPlane := internal.NewControlPlane(cluster, kcp, ownedMachines)

numMachines := len(ownedMachines)
// If the control plane is initialized, wait for health checks to pass to continue.
if numMachines > 0 {
result, err := r.generalHealthCheck(ctx, cluster, kcp, controlPlane)
if err != nil {
return result, err
}
}

requireUpgrade := controlPlane.MachinesNeedingUpgrade()
// Upgrade takes precedence over other operations
if len(requireUpgrade) > 0 {
Expand All @@ -218,7 +228,6 @@ func (r *KubeadmControlPlaneReconciler) reconcile(ctx context.Context, cluster *
}

// If we've made it this far, we can assume that all ownedMachines are up to date
numMachines := len(ownedMachines)
desiredReplicas := int(*kcp.Spec.Replicas)

switch {
Expand All @@ -227,13 +236,6 @@ func (r *KubeadmControlPlaneReconciler) reconcile(ctx context.Context, cluster *
// Create new Machine w/ init
logger.Info("Initializing control plane", "Desired", desiredReplicas, "Existing", numMachines)
return r.initializeControlPlane(ctx, cluster, kcp, controlPlane)
// Perform a general health check on control plane before continue
case true:
result, err := r.generalHealthCheck(ctx, cluster, kcp, controlPlane)
if err != nil {
return result, err
}
fallthrough
// We are scaling up
case numMachines < desiredReplicas && numMachines > 0:
// Create a new Machine w/ join
Expand Down

0 comments on commit 0682a9d

Please sign in to comment.