Merge pull request #114330 from chendave/backup_kubelet

kubeadm: backup the kubelet config file before writting the new one
This commit is contained in:
Kubernetes Prow Robot 2022-12-15 07:27:36 -08:00 committed by GitHub
commit 930271fbd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,8 +71,17 @@ func runKubeletConfigPhase() func(c workflow.RunData) error {
return err
}
// TODO: Checkpoint the current configuration first so that if something goes wrong it can be recovered
// Create a copy of the kubelet config file in the /etc/kubernetes/tmp/ folder.
backupDir, err := constants.CreateTempDirForKubeadm(constants.KubernetesDir, "kubeadm-kubelet-config")
if err != nil {
return err
}
src := filepath.Join(kubeletDir, constants.KubeletConfigurationFileName)
dest := filepath.Join(backupDir, constants.KubeletConfigurationFileName)
fmt.Printf("[upgrade] backing up kubelet config file to %s\n", dest)
if err := os.Rename(src, dest); err != nil {
return errors.Wrap(err, "error backing up the kubelet config file")
}
// Store the kubelet component configuration.
if err = kubeletphase.WriteConfigToDisk(&cfg.ClusterConfiguration, kubeletDir, data.PatchesDir(), data.OutputWriter()); err != nil {
return err