Merge pull request #114719 from chendave/cleanup_copy

kubeadm: return the output from stdout and stderr
This commit is contained in:
Kubernetes Prow Robot 2023-01-02 19:49:31 -08:00 committed by GitHub
commit 1edbb8cf1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -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

View File

@ -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()
}

View File

@ -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()
}