Skip to content

Commit

Permalink
Fix issue 6913
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
  • Loading branch information
shubham-pampattiwar committed Oct 3, 2023
1 parent 5ab6672 commit 87a8a6b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion pkg/apis/velero/v2alpha1/data_upload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const (
DataUploadPhaseAccepted DataUploadPhase = "Accepted"
DataUploadPhasePrepared DataUploadPhase = "Prepared"
DataUploadPhaseInProgress DataUploadPhase = "InProgress"
DataUploadPhaseCanceling DataUploadPhase = "Canceling"
DataUploadPhaseCanceled DataUploadPhase = "Canceled"
DataUploadPhaseCompleted DataUploadPhase = "Completed"
DataUploadPhaseFailed DataUploadPhase = "Failed"
Expand Down
13 changes: 7 additions & 6 deletions pkg/controller/data_upload_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,20 @@ func (r *DataUploadReconciler) Reconcile(ctx context.Context, req ctrl.Request)
} else if du.Status.Phase == velerov2alpha1api.DataUploadPhaseInProgress {
log.Info("Data upload is in progress")
if du.Spec.Cancel {
fsBackup := r.dataPathMgr.GetAsyncBR(du.Name)
if fsBackup == nil {
return ctrl.Result{}, nil
}
log.Info("Data upload is being canceled")

// Update status to Canceling.
// Update status to Canceled
original := du.DeepCopy()
du.Status.Phase = velerov2alpha1api.DataUploadPhaseCanceling
du.Status.Phase = velerov2alpha1api.DataUploadPhaseCanceled
if err := r.client.Patch(ctx, du, client.MergeFrom(original)); err != nil {
log.WithError(err).Error("error updating data upload into canceling status")
return ctrl.Result{}, err
}

fsBackup := r.dataPathMgr.GetAsyncBR(du.Name)
if fsBackup == nil {
return ctrl.Result{}, nil
}
fsBackup.Cancel()
return ctrl.Result{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/data_upload_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func TestReconcile(t *testing.T) {
pod: builder.ForPod(velerov1api.DefaultNamespace, dataUploadName).Volumes(&corev1.Volume{Name: "dataupload-1"}).Result(),
du: dataUploadBuilder().Phase(velerov2alpha1api.DataUploadPhaseInProgress).SnapshotType(fakeSnapshotType).Cancel(true).Result(),
expectedProcessed: false,
expected: dataUploadBuilder().Phase(velerov2alpha1api.DataUploadPhaseCanceling).Result(),
expected: dataUploadBuilder().Phase(velerov2alpha1api.DataUploadPhaseCanceled).Result(),
expectedRequeue: ctrl.Result{},
},
{
Expand Down

0 comments on commit 87a8a6b

Please sign in to comment.