From 449b39a4500d00ed8815609bffcad31cfb1012c8 Mon Sep 17 00:00:00 2001 From: SataQiu <1527062125@qq.com> Date: Tue, 21 Apr 2020 16:35:04 +0800 Subject: [PATCH] kubeadm: ensure image-pull-timeout flag is respected during upgrade phase Signed-off-by: SataQiu <1527062125@qq.com> --- cmd/kubeadm/app/cmd/upgrade/apply.go | 5 ++++- cmd/kubeadm/app/cmd/upgrade/common.go | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/kubeadm/app/cmd/upgrade/apply.go b/cmd/kubeadm/app/cmd/upgrade/apply.go index 11f3c49d114..671115cfae1 100644 --- a/cmd/kubeadm/app/cmd/upgrade/apply.go +++ b/cmd/kubeadm/app/cmd/upgrade/apply.go @@ -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 // 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") } + waiter = getWaiter(flags.dryRun, client, upgrade.UpgradeManifestTimeout) + // Now; perform the upgrade procedure klog.V(1).Infoln("[upgrade/apply] performing upgrade") if err := PerformControlPlaneUpgrade(flags, client, waiter, cfg); err != nil { diff --git a/cmd/kubeadm/app/cmd/upgrade/common.go b/cmd/kubeadm/app/cmd/upgrade/common.go index 6eb9e4d34dd..a2e988ccea0 100644 --- a/cmd/kubeadm/app/cmd/upgrade/common.go +++ b/cmd/kubeadm/app/cmd/upgrade/common.go @@ -23,6 +23,7 @@ import ( "io" "os" "strings" + "time" "github.com/pkg/errors" @@ -228,11 +229,11 @@ func getClient(file string, dryRun bool) (clientset.Interface, error) { } // 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 { 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.