Skip to content

Commit

Permalink
Add timeout after kubelet binary and kubeadm upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
  • Loading branch information
xmudrii committed Mar 28, 2019
1 parent fcdc823 commit e8851fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
8 changes: 8 additions & 0 deletions pkg/upgrader/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package upgrade

import (
"time"

"github.com/pkg/errors"

"github.com/kubermatic/kubeone/pkg/certificate"
Expand All @@ -28,6 +30,12 @@ import (
const (
labelUpgradeLock = "kubeone.io/upgrade-in-progress"
labelControlPlaneNode = "node-role.kubernetes.io/master"
// timeoutKubeletUpgrade is time for how long kubeone will wait after upgrading kubelet
// and running the upgrade process on the node
timeoutKubeletUpgrade = 1 * time.Minute
// timeoutNodeUpgrade is time for how long kubeone will wait after finishing the upgrade
// process on the node
timeoutNodeUpgrade = 15 * time.Second
)

// Upgrade performs all the steps required to upgrade Kubernetes on
Expand Down
9 changes: 6 additions & 3 deletions pkg/upgrader/upgrade/upgrade_follower.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,23 @@ func upgradeFollowerExecutor(ctx *util.Context, node *config.HostConfig, conn ss
return errors.Wrap(err, "failed to upgrade kubernetes binaries on follower control plane")
}

logger.Infof("Waiting %v seconds to ensure kubelet is up…", timeoutKubeletUpgrade.String())
time.Sleep(timeoutKubeletUpgrade)

logger.Infoln("Running 'kubeadm upgrade' on the follower control plane node…")
err = upgradeFollowerControlPlane(ctx)
if err != nil {
return errors.Wrap(err, "failed to upgrade follower control plane")
}

logger.Infof("Waiting %v seconds to ensure all components are up…", timeoutNodeUpgrade.String())
time.Sleep(timeoutNodeUpgrade)

logger.Infoln("Unlabeling follower control plane…")
err = unlabelNode(ctx.DynamicClient, node)
if err != nil {
return errors.Wrap(err, "failed to unlabel follower control plane node")
}

logger.Infoln("Waiting 10 seconds to ensure all components are up…")
time.Sleep(10 * time.Second)

return nil
}
9 changes: 6 additions & 3 deletions pkg/upgrader/upgrade/upgrade_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func upgradeLeaderExecutor(ctx *util.Context, node *config.HostConfig, conn ssh.
return errors.Wrap(err, "failed to upgrade kubernetes binaries on leader control plane")
}

logger.Infof("Waiting %v seconds to ensure kubelet is up…", timeoutKubeletUpgrade.String())
time.Sleep(timeoutKubeletUpgrade)

logger.Infoln("Generating kubeadm config …")
if err := generateKubeadmConfig(ctx, node); err != nil {
return errors.Wrap(err, "failed to generate kubeadm config")
Expand All @@ -58,13 +61,13 @@ func upgradeLeaderExecutor(ctx *util.Context, node *config.HostConfig, conn ssh.
return errors.Wrap(err, "failed to run 'kubeadm upgrade' on leader control plane")
}

logger.Infof("Waiting %v seconds to ensure all components are up…", timeoutNodeUpgrade.String())
time.Sleep(timeoutNodeUpgrade)

logger.Infoln("Unlabeling leader control plane…")
if err := unlabelNode(ctx.DynamicClient, node); err != nil {
return errors.Wrap(err, "failed to unlabel leader control plane node")
}

logger.Infoln("Waiting 10 seconds to ensure all components are up…")
time.Sleep(10 * time.Second)

return nil
}

0 comments on commit e8851fe

Please sign in to comment.