mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-03 11:45:20 +00:00
Fix issue of fail to get command output for test verification
When running velero backup/restore command, if the command result is "PartiallyFailed", it won't reture error as design, but we do need to know the debug information to figure out the reason, so the command output is needed to get the command result, then further action will be taken. Signed-off-by: danfengl <danfengl@vmware.com>
This commit is contained in:
@@ -431,17 +431,19 @@ func VeleroScheduleCreate(ctx context.Context, veleroCLI string, veleroNamespace
|
||||
|
||||
func VeleroCmdExec(ctx context.Context, veleroCLI string, args []string) error {
|
||||
cmd := exec.CommandContext(ctx, veleroCLI, args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
var errBuf, outBuf bytes.Buffer
|
||||
cmd.Stderr = io.MultiWriter(os.Stderr, &errBuf)
|
||||
cmd.Stdout = io.MultiWriter(os.Stdout, &outBuf)
|
||||
fmt.Printf("velero cmd =%v\n", cmd)
|
||||
err := cmd.Run()
|
||||
if strings.Contains(fmt.Sprint(cmd.Stdout), "Failed") {
|
||||
retAll := outBuf.String() + " " + errBuf.String()
|
||||
if strings.Contains(strings.ToLower(retAll), "failed") {
|
||||
return errors.New(fmt.Sprintf("velero cmd =%v return with failure\n", cmd))
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
func VeleroBackupLogs(ctx context.Context, veleroCLI string, veleroNamespace string, backupName string) error {
|
||||
|
||||
Reference in New Issue
Block a user