From 28d636bd71d7f859c15cec1f1475b5497f96ac71 Mon Sep 17 00:00:00 2001 From: Lyndon-Li Date: Wed, 8 Mar 2023 09:25:43 +0800 Subject: [PATCH] fix client wait problem Signed-off-by: Lyndon-Li --- changelogs/unreleased/5964-Lyndon-Li | 1 + pkg/cmd/cli/backup/create.go | 3 ++- pkg/cmd/cli/restore/create.go | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/5964-Lyndon-Li diff --git a/changelogs/unreleased/5964-Lyndon-Li b/changelogs/unreleased/5964-Lyndon-Li new file mode 100644 index 000000000..f9e47ad6c --- /dev/null +++ b/changelogs/unreleased/5964-Lyndon-Li @@ -0,0 +1 @@ +Fix client wait problem after async operation change, velero backup/restore --wait should check a full list of the terminal status \ No newline at end of file diff --git a/pkg/cmd/cli/backup/create.go b/pkg/cmd/cli/backup/create.go index ee16a0852..1d7a8f53f 100644 --- a/pkg/cmd/cli/backup/create.go +++ b/pkg/cmd/cli/backup/create.go @@ -277,7 +277,8 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error { return nil } - if backup.Status.Phase != velerov1api.BackupPhaseNew && backup.Status.Phase != velerov1api.BackupPhaseInProgress { + if backup.Status.Phase == velerov1api.BackupPhaseFailedValidation || backup.Status.Phase == velerov1api.BackupPhaseCompleted || + backup.Status.Phase == velerov1api.BackupPhasePartiallyFailed || backup.Status.Phase == velerov1api.BackupPhaseFailed { fmt.Printf("\nBackup completed with status: %s. You may check for more information using the commands `velero backup describe %s` and `velero backup logs %s`.\n", backup.Status.Phase, backup.Name, backup.Name) return nil } diff --git a/pkg/cmd/cli/restore/create.go b/pkg/cmd/cli/restore/create.go index 7625c1f76..71229b673 100644 --- a/pkg/cmd/cli/restore/create.go +++ b/pkg/cmd/cli/restore/create.go @@ -355,7 +355,8 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error { return nil } - if restore.Status.Phase != api.RestorePhaseNew && restore.Status.Phase != api.RestorePhaseInProgress { + if restore.Status.Phase == api.RestorePhaseFailedValidation || restore.Status.Phase == api.RestorePhaseCompleted || + restore.Status.Phase == api.RestorePhasePartiallyFailed || restore.Status.Phase == api.RestorePhaseFailed { fmt.Printf("\nRestore completed with status: %s. You may check for more information using the commands `velero restore describe %s` and `velero restore logs %s`.\n", restore.Status.Phase, restore.Name, restore.Name) return nil }