kubeadm: ensure image-pull-timeout flag is respected during upgrade phase

Signed-off-by: SataQiu <1527062125@qq.com>
This commit is contained in:
SataQiu 2020-04-21 16:35:04 +08:00
parent f9532e4663
commit 449b39a450
2 changed files with 7 additions and 3 deletions

View File

@ -145,7 +145,8 @@ func runApply(flags *applyFlags, userVersion string) error {
} }
} }
waiter := getWaiter(flags.dryRun, client) // Set the timeout as flags.imagePullTimeout to ensure that Prepuller truly respects 'image-pull-timeout' flag
waiter := getWaiter(flags.dryRun, client, flags.imagePullTimeout)
// Use a prepuller implementation based on creating DaemonSets // Use a prepuller implementation based on creating DaemonSets
// and block until all DaemonSets are ready; then we know for sure that all control plane images are cached locally // and block until all DaemonSets are ready; then we know for sure that all control plane images are cached locally
@ -159,6 +160,8 @@ func runApply(flags *applyFlags, userVersion string) error {
return errors.Wrap(err, "[upgrade/prepull] Failed prepulled the images for the control plane components error") return errors.Wrap(err, "[upgrade/prepull] Failed prepulled the images for the control plane components error")
} }
waiter = getWaiter(flags.dryRun, client, upgrade.UpgradeManifestTimeout)
// Now; perform the upgrade procedure // Now; perform the upgrade procedure
klog.V(1).Infoln("[upgrade/apply] performing upgrade") klog.V(1).Infoln("[upgrade/apply] performing upgrade")
if err := PerformControlPlaneUpgrade(flags, client, waiter, cfg); err != nil { if err := PerformControlPlaneUpgrade(flags, client, waiter, cfg); err != nil {

View File

@ -23,6 +23,7 @@ import (
"io" "io"
"os" "os"
"strings" "strings"
"time"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -228,11 +229,11 @@ func getClient(file string, dryRun bool) (clientset.Interface, error) {
} }
// getWaiter gets the right waiter implementation // getWaiter gets the right waiter implementation
func getWaiter(dryRun bool, client clientset.Interface) apiclient.Waiter { func getWaiter(dryRun bool, client clientset.Interface, timeout time.Duration) apiclient.Waiter {
if dryRun { if dryRun {
return dryrunutil.NewWaiter() return dryrunutil.NewWaiter()
} }
return apiclient.NewKubeWaiter(client, upgrade.UpgradeManifestTimeout, os.Stdout) return apiclient.NewKubeWaiter(client, timeout, os.Stdout)
} }
// InteractivelyConfirmUpgrade asks the user whether they _really_ want to upgrade. // InteractivelyConfirmUpgrade asks the user whether they _really_ want to upgrade.