From ecb78d5f5d580dda9db9a6e372007410911e66e8 Mon Sep 17 00:00:00 2001 From: Emily McMullan Date: Fri, 16 Sep 2022 13:04:41 -0400 Subject: [PATCH] partially fail backup if vsb fails --- pkg/datamover/datamover.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/datamover/datamover.go b/pkg/datamover/datamover.go index 32ce983147..b15fd57afe 100644 --- a/pkg/datamover/datamover.go +++ b/pkg/datamover/datamover.go @@ -12,6 +12,7 @@ import ( "github.com/pkg/errors" velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "golang.org/x/sync/errgroup" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" kbclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" @@ -21,6 +22,8 @@ const ( // Env vars VolumeSnapshotMoverEnv = "VOLUME_SNAPSHOT_MOVER" DatamoverTimeout = "DATAMOVER_TIMEOUT" + ReconciledReasonError = "Error" + ConditionReconciled = "Reconciled" ) // We expect VolumeSnapshotMoverEnv to be set once when container is started. @@ -73,11 +76,19 @@ func CheckIfVolumeSnapshotBackupsAreComplete(ctx context.Context, volumesnapshot if err != nil { return false, errors.Wrapf(err, fmt.Sprintf("failed to get volumesnapshotbackup %s/%s", volumesnapshotbackup.Namespace, volumesnapshotbackup.Name)) } + // check for a failed VSB + for _, cond := range currentVSB.Status.Conditions { + if cond.Status == metav1.ConditionFalse && cond.Reason == ReconciledReasonError && cond.Type == ConditionReconciled { + return false, errors.Errorf("volumesnapshotbackup %s has failed status", currentVSB.Name) + } + } + if len(currentVSB.Status.Phase) == 0 || currentVSB.Status.Phase != snapmoverv1alpha1.SnapMoverBackupPhaseCompleted { log.Infof("Waiting for volumesnapshotbackup status.phase to change from %s to complete %s/%s. Retrying in %ds", currentVSB.Status.Phase, volumesnapshotbackup.Namespace, volumesnapshotbackup.Name, interval/time.Second) return false, nil } + log.Infof("volumesnapshotbackup %s completed", volumesnapshotbackup.Name) return true, nil }) if err == wait.ErrWaitTimeout {