diff --git a/changelogs/unreleased/6914-shubham-pampattiwar b/changelogs/unreleased/6914-shubham-pampattiwar new file mode 100644 index 00000000000..c95688b397f --- /dev/null +++ b/changelogs/unreleased/6914-shubham-pampattiwar @@ -0,0 +1 @@ +Fix issue 6913: Velero Built-in Datamover: Backup stucks in phase WaitingForPluginOperations when Node Agent pod gets restarted \ No newline at end of file diff --git a/pkg/controller/data_upload_controller.go b/pkg/controller/data_upload_controller.go index 8bc650f5f9f..710577da6d2 100644 --- a/pkg/controller/data_upload_controller.go +++ b/pkg/controller/data_upload_controller.go @@ -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 } diff --git a/pkg/controller/data_upload_controller_test.go b/pkg/controller/data_upload_controller_test.go index 34bc4a6aaed..2b6a3404072 100644 --- a/pkg/controller/data_upload_controller_test.go +++ b/pkg/controller/data_upload_controller_test.go @@ -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{}, }, {