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 // Backing up etcd data store
backupEtcdDir := pathMgr.BackupEtcdDir() backupEtcdDir := pathMgr.BackupEtcdDir()
runningEtcdDir := cfg.Etcd.Local.DataDir runningEtcdDir := cfg.Etcd.Local.DataDir
if err := kubeadmutil.CopyDir(runningEtcdDir, backupEtcdDir); err != nil { output, err := kubeadmutil.CopyDir(runningEtcdDir, backupEtcdDir)
return true, errors.Wrap(err, "failed to back up etcd data") 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 // 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() backupEtcdDir := pathMgr.BackupEtcdDir()
runningEtcdDir := cfg.Etcd.Local.DataDir 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 // 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 return nil

View File

@ -24,7 +24,6 @@ import (
) )
// CopyDir copies the content of a folder // CopyDir copies the content of a folder
func CopyDir(src string, dst string) error { func CopyDir(src string, dst string) ([]byte, error) {
cmd := exec.Command("cp", "-r", src, dst) return exec.Command("cp", "-r", src, dst).CombinedOutput()
return cmd.Run()
} }

View File

@ -24,9 +24,8 @@ import (
) )
// CopyDir copies the content of a folder // 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. // /E Copies directories and subdirectories, including empty ones.
// /H Copies hidden and system files also. // /H Copies hidden and system files also.
cmd := exec.Command("xcopy", "/E", "/H", src, dst) return exec.Command("xcopy", "/E", "/H", src, dst).CombinedOutput()
return cmd.Run()
} }