From f1fcec35142cd8cb1574242669051b8c944602c0 Mon Sep 17 00:00:00 2001 From: Shubham Pampattiwar Date: Tue, 3 Oct 2023 14:14:48 -0700 Subject: [PATCH] Fix issue 6913 Signed-off-by: Shubham Pampattiwar add changelog file Signed-off-by: Shubham Pampattiwar keep canceling phase const Signed-off-by: Shubham Pampattiwar fix data download as well Signed-off-by: Shubham Pampattiwar address PR feedback Signed-off-by: Shubham Pampattiwar minor fixes Signed-off-by: Shubham Pampattiwar (cherry picked from commit ee271b7b69171a5be25d0e8bacf03557dac23d13) update changelog filename Signed-off-by: Shubham Pampattiwar --- changelogs/unreleased/7025-shubham-pampattiwar | 1 + pkg/controller/data_download_controller.go | 4 ++-- pkg/controller/data_upload_controller.go | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/7025-shubham-pampattiwar diff --git a/changelogs/unreleased/7025-shubham-pampattiwar b/changelogs/unreleased/7025-shubham-pampattiwar new file mode 100644 index 0000000000..c95688b397 --- /dev/null +++ b/changelogs/unreleased/7025-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_download_controller.go b/pkg/controller/data_download_controller.go index cc60cacef3..0212fa00f3 100644 --- a/pkg/controller/data_download_controller.go +++ b/pkg/controller/data_download_controller.go @@ -287,12 +287,13 @@ func (r *DataDownloadReconciler) Reconcile(ctx context.Context, req ctrl.Request } else if dd.Status.Phase == velerov2alpha1api.DataDownloadPhaseInProgress { log.Info("Data download is in progress") if dd.Spec.Cancel { + log.Info("Data download is being canceled") fsRestore := r.dataPathMgr.GetAsyncBR(dd.Name) if fsRestore == nil { + r.OnDataDownloadCancelled(ctx, dd.GetNamespace(), dd.GetName()) return ctrl.Result{}, nil } - log.Info("Data download is being canceled") // Update status to Canceling. original := dd.DeepCopy() dd.Status.Phase = velerov2alpha1api.DataDownloadPhaseCanceling @@ -300,7 +301,6 @@ func (r *DataDownloadReconciler) Reconcile(ctx context.Context, req ctrl.Request log.WithError(err).Error("error updating data download status") return ctrl.Result{}, err } - fsRestore.Cancel() return ctrl.Result{}, nil } diff --git a/pkg/controller/data_upload_controller.go b/pkg/controller/data_upload_controller.go index 8bc650f5f9..ec3f4d1547 100644 --- a/pkg/controller/data_upload_controller.go +++ b/pkg/controller/data_upload_controller.go @@ -292,13 +292,15 @@ 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 { + log.Info("Data upload is being canceled") + fsBackup := r.dataPathMgr.GetAsyncBR(du.Name) if fsBackup == nil { + r.OnDataUploadCancelled(ctx, du.GetNamespace(), du.GetName()) return ctrl.Result{}, nil } - log.Info("Data upload is being canceled") - // Update status to Canceling. + // Update status to Canceling original := du.DeepCopy() du.Status.Phase = velerov2alpha1api.DataUploadPhaseCanceling if err := r.client.Patch(ctx, du, client.MergeFrom(original)); err != nil {