Commit ba2e8992 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #53262 from krousey/upgrade_failure

Automatic merge from submit-queue (batch tested with PRs 53263, 52967, 53262, 52654, 53187). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix sed command to not try shell redirection RunCmd uses Go's os/exec library to run commands directly. Since these are not run through a shell, we can't use shell syntax for piping or file redirection. The proper way to do that is to create a Command object and set the Std{in,out,err} pipes appropriately. Luckily sed can handle the behavior we need without having to manually set this up. fixes https://github.com/kubernetes/kubeadm/issues/472
parents b5029308 8e4bc73a
......@@ -114,10 +114,14 @@ func masterUpgradeKubernetesAnywhere(v string) error {
backupConfigPath := filepath.Join(kaPath, ".config.bak")
updatedConfigPath := filepath.Join(kaPath, fmt.Sprintf(".config-%s", v))
// backup .config to .config.bak
if err := os.Rename(originalConfigPath, backupConfigPath); err != nil {
// modify config with specified k8s version
if _, _, err := RunCmd("sed",
"-i.bak", // writes original to .config.bak
fmt.Sprintf(`s/kubernetes_version=.*$/kubernetes_version=%s/`, v),
originalConfigPath); err != nil {
return err
}
defer func() {
// revert .config.bak to .config
if err := os.Rename(backupConfigPath, originalConfigPath); err != nil {
......@@ -125,13 +129,6 @@ func masterUpgradeKubernetesAnywhere(v string) error {
}
}()
// modify config with specified k8s version
if _, _, err := RunCmd("sed",
fmt.Sprintf(`s/kubernetes_version=.*$/kubernetes_version=%s/`, v),
backupConfigPath, ">", originalConfigPath); err != nil {
return err
}
// invoke ka upgrade
if _, _, err := RunCmd("make", "-C", TestContext.KubernetesAnywherePath,
"WAIT_FOR_KUBECONFIG=y", "upgrade-master"); err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment