mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
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
This commit is contained in:
commit
ba2e899221
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user