Merge pull request #114532 from pacoxu/fix-dry-run-backup

kubeadm upgrade: fix dry run of backing up kubelet config file
This commit is contained in:
Kubernetes Prow Robot 2022-12-16 02:06:18 -08:00 committed by GitHub
commit e6926831c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,9 +78,13 @@ func runKubeletConfigPhase() func(c workflow.RunData) error {
} }
src := filepath.Join(kubeletDir, constants.KubeletConfigurationFileName) src := filepath.Join(kubeletDir, constants.KubeletConfigurationFileName)
dest := filepath.Join(backupDir, constants.KubeletConfigurationFileName) dest := filepath.Join(backupDir, constants.KubeletConfigurationFileName)
fmt.Printf("[upgrade] backing up kubelet config file to %s\n", dest) if !dryRun {
if err := os.Rename(src, dest); err != nil { fmt.Printf("[upgrade] Backing up kubelet config file to %s\n", dest)
return errors.Wrap(err, "error backing up the kubelet config file") if err := os.Rename(src, dest); err != nil {
return errors.Wrap(err, "error backing up the kubelet config file")
}
} else {
fmt.Printf("[dryrun] Would back up kubelet config file to %s\n", dest)
} }
// Store the kubelet component configuration. // Store the kubelet component configuration.
if err = kubeletphase.WriteConfigToDisk(&cfg.ClusterConfiguration, kubeletDir, data.PatchesDir(), data.OutputWriter()); err != nil { if err = kubeletphase.WriteConfigToDisk(&cfg.ClusterConfiguration, kubeletDir, data.PatchesDir(), data.OutputWriter()); err != nil {