Skip to content

Commit

Permalink
Wait VolumeSnapshot's asscociated snapshot handle is created for data…
Browse files Browse the repository at this point in the history
… mover PVC BIA.

Continue to retry in VolumeSnapshot's BIA progress, when VS.Status reporting error,
because external-snapshotter treats the error as interim, and will retry continually.

Signed-off-by: Xun Jiang <[email protected]>
  • Loading branch information
Xun Jiang committed Aug 10, 2023
1 parent 8fff955 commit f312e5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions internal/backup/pvc_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func (p *PVCBackupItemAction) Execute(item runtime.Unstructured, backup *velerov
var itemToUpdate []velero.ResourceIdentifier

if boolptr.IsSetToTrue(backup.Spec.SnapshotMoveData) {

operationID = label.GetValidName(string(velerov1api.AsyncOperationIDPrefixDataUpload) + string(backup.UID) + "." + string(pvc.UID))
dataUploadLog := p.Log.WithFields(logrus.Fields{
"Source PVC": fmt.Sprintf("%s/%s", pvc.Namespace, pvc.Name),
Expand All @@ -183,6 +184,16 @@ func (p *PVCBackupItemAction) Execute(item runtime.Unstructured, backup *velerov
"Backup": backup.Name,
})

// Wait until VS associated VSC snapshot handle created before returning with
// the Async operation for data mover.
_, err := util.GetVolumeSnapshotContentForVolumeSnapshot(upd, p.SnapshotClient.SnapshotV1(),
dataUploadLog, true, backup.Spec.CSISnapshotTimeout.Duration)
if err != nil {
dataUploadLog.Errorf("Fail to wait VolumeSnapshot snapshot handle created: %s", err.Error())
util.CleanupVolumeSnapshot(upd, p.SnapshotClient.SnapshotV1(), p.Log)
return nil, nil, "", nil, errors.WithStack(err)
}

dataUploadLog.Info("Starting data upload of backup")

dataUpload, err := createDataUpload(context.Background(), backup, p.VeleroClient, upd, &pvc, operationID)
Expand Down
5 changes: 3 additions & 2 deletions internal/backup/volumesnapshot_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,11 @@ func (p *VolumeSnapshotBackupItemAction) Progress(operationID string, backup *ve
if boolptr.IsSetToTrue(vs.Status.ReadyToUse) {
progress.Completed = true
} else if vs.Status.Error != nil {
progress.Completed = true
errorMessage := ""
if vs.Status.Error.Message != nil {
progress.Err = *vs.Status.Error.Message
errorMessage = *vs.Status.Error.Message
}
p.Log.Warnf("VolumeSnapshot has a temporary error %s. Snapshot controller will retry later.", errorMessage)
}

return progress, nil
Expand Down

0 comments on commit f312e5d

Please sign in to comment.