mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
Merge pull request #114719 from chendave/cleanup_copy
kubeadm: return the output from stdout and stderr
This commit is contained in:
commit
1edbb8cf1a
@ -280,8 +280,9 @@ func performEtcdStaticPodUpgrade(certsRenewMgr *renewal.Manager, client clientse
|
||||
// Backing up etcd data store
|
||||
backupEtcdDir := pathMgr.BackupEtcdDir()
|
||||
runningEtcdDir := cfg.Etcd.Local.DataDir
|
||||
if err := kubeadmutil.CopyDir(runningEtcdDir, backupEtcdDir); err != nil {
|
||||
return true, errors.Wrap(err, "failed to back up etcd data")
|
||||
output, err := kubeadmutil.CopyDir(runningEtcdDir, backupEtcdDir)
|
||||
if err != nil {
|
||||
return true, errors.Wrapf(err, "failed to back up etcd data, output: %q", output)
|
||||
}
|
||||
|
||||
// Get the desired etcd version. That's either the one specified by the user in cfg.Etcd.Local.ImageTag
|
||||
@ -531,9 +532,10 @@ func rollbackEtcdData(cfg *kubeadmapi.InitConfiguration, pathMgr StaticPodPathMa
|
||||
backupEtcdDir := pathMgr.BackupEtcdDir()
|
||||
runningEtcdDir := cfg.Etcd.Local.DataDir
|
||||
|
||||
if err := kubeadmutil.CopyDir(backupEtcdDir, runningEtcdDir); err != nil {
|
||||
output, err := kubeadmutil.CopyDir(backupEtcdDir, runningEtcdDir)
|
||||
if err != nil {
|
||||
// Let the user know there we're problems, but we tried to reçover
|
||||
return errors.Wrapf(err, "couldn't recover etcd database with error, the location of etcd backup: %s ", backupEtcdDir)
|
||||
return errors.Wrapf(err, "couldn't recover etcd database with error, the location of etcd backup: %s, output: %q", backupEtcdDir, output)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -24,7 +24,6 @@ import (
|
||||
)
|
||||
|
||||
// CopyDir copies the content of a folder
|
||||
func CopyDir(src string, dst string) error {
|
||||
cmd := exec.Command("cp", "-r", src, dst)
|
||||
return cmd.Run()
|
||||
func CopyDir(src string, dst string) ([]byte, error) {
|
||||
return exec.Command("cp", "-r", src, dst).CombinedOutput()
|
||||
}
|
||||
|
@ -24,9 +24,8 @@ import (
|
||||
)
|
||||
|
||||
// CopyDir copies the content of a folder
|
||||
func CopyDir(src string, dst string) error {
|
||||
func CopyDir(src string, dst string) ([]byte, error) {
|
||||
// /E Copies directories and subdirectories, including empty ones.
|
||||
// /H Copies hidden and system files also.
|
||||
cmd := exec.Command("xcopy", "/E", "/H", src, dst)
|
||||
return cmd.Run()
|
||||
return exec.Command("xcopy", "/E", "/H", src, dst).CombinedOutput()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user