Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #52477 #53262 #53346 #53996

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions test/e2e/framework/nodes_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"
"strings"
"time"

Expand All @@ -45,6 +46,8 @@ func MasterUpgrade(v string) error {
return masterUpgradeGCE(v)
case "gke":
return masterUpgradeGKE(v)
case "kubernetes-anywhere":
return masterUpgradeKubernetesAnywhere(v)
default:
return fmt.Errorf("MasterUpgrade() is not implemented for provider %s", TestContext.Provider)
}
Expand Down Expand Up @@ -96,6 +99,43 @@ func masterUpgradeGKE(v string) error {
return nil
}

func masterUpgradeKubernetesAnywhere(v string) error {
Logf("Upgrading master to %q", v)

kaPath := TestContext.KubernetesAnywherePath
originalConfigPath := filepath.Join(kaPath, ".config")
backupConfigPath := filepath.Join(kaPath, ".config.bak")
updatedConfigPath := filepath.Join(kaPath, fmt.Sprintf(".config-%s", v))

// modify config with specified k8s version
if _, _, err := RunCmd("sed",
"-i.bak", // writes original to .config.bak
fmt.Sprintf(`s/kubernetes_version=.*$/kubernetes_version=%q/`, v),
originalConfigPath); err != nil {
return err
}

defer func() {
// revert .config.bak to .config
if err := os.Rename(backupConfigPath, originalConfigPath); err != nil {
Logf("Could not rename %s back to %s", backupConfigPath, originalConfigPath)
}
}()

// invoke ka upgrade
if _, _, err := RunCmd("make", "-C", TestContext.KubernetesAnywherePath,
"WAIT_FOR_KUBECONFIG=y", "upgrade-master"); err != nil {
return err
}

// move .config to .config.<version>
if err := os.Rename(originalConfigPath, updatedConfigPath); err != nil {
return err
}

return nil
}

func NodeUpgrade(f *Framework, v string, img string) error {
// Perform the upgrade.
var err error
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/framework/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ type TestContextType struct {
// Whether configuration for accessing federation member clusters should be sourced from the host cluster
FederationConfigFromCluster bool

// Indicates what path the kubernetes-anywhere is installed on
KubernetesAnywherePath string

// Viper-only parameters. These will in time replace all flags.

// Example: Create a file 'e2e.json' with the following:
Expand Down Expand Up @@ -183,6 +186,7 @@ func RegisterCommonFlags() {
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker/rkt/remote).")
flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "", "The container runtime endpoint of cluster VM instances.")
flag.StringVar(&TestContext.ImageServiceEndpoint, "image-service-endpoint", "", "The image service endpoint of cluster VM instances.")
flag.StringVar(&TestContext.KubernetesAnywherePath, "kubernetes-anywhere-path", "/workspace/kubernetes-anywhere", "Which directory kubernetes-anywhere is installed to.")
}

// Register flags specific to the cluster e2e test suite.
Expand Down