Merge pull request #38891 from krousey/gceimageupgrade

Automatic merge from submit-queue (batch tested with PRs 38426, 38917, 38891, 38935)

Support different image during GCE node upgrade

**What this PR does / why we need it**: It lets GCE upgrade tests upgrade to a GCI node image.

**Which issue this PR fixes**: fixes #37855
This commit is contained in:
Kubernetes Submit Queue 2016-12-19 18:18:25 -08:00 committed by GitHub
commit db5887aa83
2 changed files with 16 additions and 3 deletions

View File

@ -18,6 +18,7 @@ package framework
import (
"fmt"
"os"
"path"
"strings"
"time"
@ -66,8 +67,7 @@ var NodeUpgrade = func(f *Framework, v string, img string) error {
var err error
switch TestContext.Provider {
case "gce":
// TODO(maisem): add GCE support for upgrading to different images.
err = nodeUpgradeGCE(v)
err = nodeUpgradeGCE(v, img)
case "gke":
err = nodeUpgradeGKE(v, img)
default:
@ -88,8 +88,13 @@ var NodeUpgrade = func(f *Framework, v string, img string) error {
return nil
}
func nodeUpgradeGCE(rawV string) error {
func nodeUpgradeGCE(rawV, img string) error {
v := "v" + rawV
if img != "" {
env := append(os.Environ(), "KUBE_NODE_OS_DISTRIBUTION="+img)
_, _, err := RunCmdEnv(env, path.Join(TestContext.RepoRoot, "cluster/gce/upgrade.sh"), "-N", "-o", v)
return err
}
_, _, err := RunCmd(path.Join(TestContext.RepoRoot, "cluster/gce/upgrade.sh"), "-N", v)
return err
}

View File

@ -4869,6 +4869,13 @@ func GetPodsInNamespace(c clientset.Interface, ns string, ignoreLabels map[strin
// RunCmd runs cmd using args and returns its stdout and stderr. It also outputs
// cmd's stdout and stderr to their respective OS streams.
func RunCmd(command string, args ...string) (string, string, error) {
return RunCmdEnv(nil, command, args...)
}
// RunCmdEnv runs cmd with the provided environment and args and
// returns its stdout and stderr. It also outputs cmd's stdout and
// stderr to their respective OS streams.
func RunCmdEnv(env []string, command string, args ...string) (string, string, error) {
Logf("Running %s %v", command, args)
var bout, berr bytes.Buffer
cmd := exec.Command(command, args...)
@ -4879,6 +4886,7 @@ func RunCmd(command string, args ...string) (string, string, error) {
// newlines.
cmd.Stdout = io.MultiWriter(os.Stdout, &bout)
cmd.Stderr = io.MultiWriter(os.Stderr, &berr)
cmd.Env = env
err := cmd.Run()
stdout, stderr := bout.String(), berr.String()
if err != nil {