-
Notifications
You must be signed in to change notification settings - Fork 50
/
upload_controller.go
568 lines (509 loc) · 20.4 KB
/
upload_controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
/*
Copyright 2020 the Velero contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package controller
import (
"context"
"fmt"
backupdriverapi "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/apis/backupdriver/v1alpha1"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/backuprepository"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/constants"
"k8s.io/apimachinery/pkg/util/wait"
"math"
"time"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/vmware-tanzu/astrolabe/pkg/astrolabe"
pluginv1api "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/apis/datamover/v1alpha1"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/dataMover"
pluginv1client "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/generated/clientset/versioned/typed/datamover/v1alpha1"
informers "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/generated/informers/externalversions/datamover/v1alpha1"
listers "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/generated/listers/datamover/v1alpha1"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/snapshotmgr"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/utils"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/leaderelection"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/utils/clock"
)
type uploadController struct {
*genericController
kubeClient kubernetes.Interface
uploadClient pluginv1client.UploadsGetter
uploadLister listers.UploadLister
nodeName string
dataMover *dataMover.DataMover
snapMgr *snapshotmgr.SnapshotManager
clock clock.Clock
processUploadFunc func(*pluginv1api.Upload) error
externalDataMgr bool
}
func NewUploadController(
logger logrus.FieldLogger,
uploadInformer informers.UploadInformer,
uploadClient pluginv1client.UploadsGetter,
kubeClient kubernetes.Interface,
dataMover *dataMover.DataMover,
snapMgr *snapshotmgr.SnapshotManager,
nodeName string,
externalDataMgr bool,
) Interface {
c := &uploadController{
genericController: newGenericController("upload", logger),
kubeClient: kubeClient,
uploadClient: uploadClient,
uploadLister: uploadInformer.Lister(),
nodeName: nodeName,
dataMover: dataMover,
snapMgr: snapMgr,
clock: &clock.RealClock{},
externalDataMgr: externalDataMgr,
}
c.syncHandler = c.processUploadItem
c.retryHandler = c.exponentialBackoffHandler
c.cacheSyncWaiters = append(
c.cacheSyncWaiters,
uploadInformer.Informer().HasSynced,
)
c.processUploadFunc = c.processUpload
uploadInformer.Informer().AddEventHandler(
cache.ResourceEventHandlerFuncs{
AddFunc: c.enqueueUploadItem,
UpdateFunc: func(_, obj interface{}) { c.enqueueUploadItem(obj) },
},
)
return c
}
func (c *uploadController) enqueueUploadItem(obj interface{}) {
req := obj.(*pluginv1api.Upload)
log := loggerForUpload(c.logger, req)
switch req.Status.Phase {
case "", pluginv1api.UploadPhaseNew, pluginv1api.UploadPhaseInProgress, pluginv1api.UploadPhaseUploadError, pluginv1api.UploadPhaseCleanupFailed, pluginv1api.UploadPhaseCanceling:
// Process New and InProgress and UploadError and UploadCanceling Uploads
case pluginv1api.UploadPhaseCanceled:
// The upload was canceled, nothing to do.
log.Debug("The upload request was canceled")
return
case pluginv1api.UploadPhaseCompleted:
// If Upload CR status reaches terminal state, Upload CR should be deleted after clean up window
now := c.clock.Now()
if now.After(req.Status.CompletionTimestamp.Add(constants.DefaultCRCleanUpWindow * time.Hour)) {
log.Infof("Upload CR %s has been in phase %v more than %v hours, deleting this CR.", req.Name, req.Status.Phase, constants.DefaultCRCleanUpWindow)
err := c.uploadClient.Uploads(req.Namespace).Delete(context.TODO(), req.Name, metav1.DeleteOptions{})
if err != nil {
log.WithError(err).Errorf("Failed to delete Upload CR which is in %v phase.", req.Status.Phase)
}
}
return
default:
log.Debug("Upload CR is not New or InProgress or UploadError or UploadCanceling, skipping")
return
}
// Check if the upload was canceled and trigger cancellation.
if req.Spec.UploadCancel {
err := c.triggerUploadCancellation(req)
if err != nil {
log.Error("Received error during upload cancellation.")
}
return
}
log.Debugf("Filtering out the retry upload request which comes in before next retry time")
now := c.clock.Now()
if now.Unix() < req.Status.NextRetryTimestamp.Unix() {
log.WithFields(logrus.Fields{
"nextRetryTime": req.Status.NextRetryTimestamp,
"currentTime": now,
}).Debugf("Ignore retry upload request which comes in before next retry time, upload CR: %s", req.Name)
return
}
// Check if current node is the expected upload node only if data manager is not remote.
if !c.externalDataMgr {
log.Debugf("Filtering out the upload request from nodes other than %v", c.nodeName)
peID, err := astrolabe.NewProtectedEntityIDFromString(req.Spec.SnapshotID)
if err != nil {
log.WithError(err).Errorf("Failed to extract volume ID from snapshot ID, %v", req.Spec.SnapshotID)
return
}
uploadNodeName, err := utils.RetrievePodNodesByVolumeId(peID.GetID())
if err != nil {
_, ok := err.(utils.NotFoundError)
if ok {
log.Infof("Trying to back independent PV from volume ID, %v", peID.String())
uploadNodeName = c.nodeName
} else {
log.WithError(err).Errorf("Failed to retrieve pod nodes from volume ID, %v", peID.String())
return
}
}
log.Infof("Current node: %v. Expected node for uploading the upload CR: %v", c.nodeName, uploadNodeName)
if c.nodeName != uploadNodeName {
return
}
}
log.Debugf("Enqueueing upload")
c.enqueue(obj)
}
func (c *uploadController) processUploadItem(key string) error {
log := c.logger.WithField("key", key)
log.Debug("Running processUploadItem")
ns, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
log.WithError(err).Error("Failed to split the key of queue item")
return nil
}
req, err := c.uploadLister.Uploads(ns).Get(name)
if apierrors.IsNotFound(err) {
log.Error("Upload is not found")
return nil
}
if err != nil {
return errors.Wrap(err, "Failed to get Upload")
}
// only process new items
switch req.Status.Phase {
case "", pluginv1api.UploadPhaseNew, pluginv1api.UploadPhaseInProgress, pluginv1api.UploadPhaseUploadError, pluginv1api.UploadPhaseCleanupFailed:
// Process new items
// For UploadPhaseInProgress, the resource lease logic will process the Upload if the lease is not held by
// another DataManager. If the DataManager holding the lease has died and/or lease has expired the current node
// will pick such record in UploadPhaseInProgress status for processing.
case pluginv1api.UploadPhaseCanceling:
log.Infof("The upload request is being canceled")
case pluginv1api.UploadPhaseCanceled:
log.Infof("The upload request has been canceled, skipping")
return nil
default:
return nil
}
// Check if the upload was canceled and trigger cancellation if needed.
if req.Spec.UploadCancel {
err := c.triggerUploadCancellation(req)
if err != nil {
log.Error("Received error during upload cancellation, skipping.")
}
return nil
}
leaseLockName := "upload-lease." + name
// Acquire lease for processing Upload.
lock := &resourcelock.LeaseLock{
LeaseMeta: metav1.ObjectMeta{
Name: leaseLockName,
Namespace: ns,
},
Client: c.kubeClient.CoordinationV1(),
LockConfig: resourcelock.ResourceLockConfig{
Identity: c.nodeName,
},
}
// use a Go context so we can tell the leaderelection code when we
// want to step down
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var processErr error
// start the leader election code loop
leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{
Lock: lock,
ReleaseOnCancel: false,
LeaseDuration: constants.LeaseDuration,
RenewDeadline: constants.RenewDeadline,
RetryPeriod: constants.RetryPeriod,
Callbacks: leaderelection.LeaderCallbacks{
OnStartedLeading: func(ctx context.Context) {
// Current node got the lease process request.
// Don't mutate the shared cache
log.Infof("Lock is acquired by current node - %s to process Upload %s.", c.nodeName, req.Name)
reqCopy := req.DeepCopy()
processErr = c.processUploadFunc(reqCopy)
cancel()
},
OnStoppedLeading: func() {
log.Info("Processed Upload")
},
OnNewLeader: func(identity string) {
if identity == c.nodeName {
// Same node is trying to acquire or renew the lease, ignore.
return
}
log.Infof("Lock is acquired by another node %s. Current node - %s need not process the Upload %s.", identity, c.nodeName, req.Name)
cancel()
},
},
})
return processErr
}
func (c *uploadController) processUpload(req *pluginv1api.Upload) error {
log := loggerForUpload(c.logger, req)
log.Infof("Upload starting")
var err error
// retrieve upload request for its updated status from k8s api server and filter out completed one
req, err = c.uploadClient.Uploads(req.Namespace).Get(context.TODO(), req.Name, metav1.GetOptions{})
if err != nil {
log.WithError(err).Error("Failed to retrieve upload CR from kubernetes API server")
return errors.WithStack(err)
}
// update req with the one retrieved from k8s api server
log.WithFields(logrus.Fields{
"phase": req.Status.Phase,
"generation": req.Generation,
}).Debug("Upload request updated by retrieving from kubernetes API server")
if req.Status.Phase == pluginv1api.UploadPhaseCanceled {
log.WithField("phase", req.Status.Phase).WithField("generation", req.Generation).Debug("The status of upload CR in kubernetes API server is canceled. Skipping it")
return nil
}
if req.Status.Phase == pluginv1api.UploadPhaseCanceling {
log.WithField("phase", req.Status.Phase).WithField("generation", req.Generation).Debug("The status of upload CR in kubernetes API server is canceling. Skipping it")
return nil
}
if req.Status.Phase == pluginv1api.UploadPhaseCompleted {
log.WithField("phase", req.Status.Phase).WithField("generation", req.Generation).Debug("The status of upload CR in kubernetes API server is completed. Skipping it")
return nil
}
// update status to InProgress
if req.Status.Phase != pluginv1api.UploadPhaseInProgress && req.Status.Phase != pluginv1api.UploadPhaseCleanupFailed {
// update status to InProgress
req, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseInProgress, "")
if err != nil {
return errors.WithStack(err)
}
}
// Call data mover API to do the remote copy
peID, err := astrolabe.NewProtectedEntityIDFromString(req.Spec.SnapshotID)
if err != nil {
errMsg := fmt.Sprintf("Failed to get PEID from SnapshotID, %v. %v", req.Spec.SnapshotID, errors.WithStack(err))
_, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseUploadError, errMsg)
if err != nil {
errMsg = fmt.Sprintf("%v. %v", errMsg, errors.WithStack(err))
}
log.Error(errMsg)
return errors.New(errMsg)
}
// If upload phase is UploadPhaseCleanupFailed, manually call DeleteLocalSnapshot to retry on deleting local snapshot
if req.Status.Phase == pluginv1api.UploadPhaseCleanupFailed {
err = c.snapMgr.DeleteLocalSnapshot(peID)
if err != nil {
errMsg := fmt.Sprintf("Failed to clean up local snapshot, %s, error: %v. will retry.", peID.String(), errors.WithStack(err))
_, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseCleanupFailed, errMsg)
if err != nil {
errMsg = fmt.Sprintf("Failed to patch upload status with retry, errror: %v", errors.WithStack(err))
log.Error(errMsg)
}
return errors.New(errMsg)
} else {
msg := fmt.Sprintf("Successfully deleted local snapshot, %v", peID.String())
_, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseCompleted, msg)
if err != nil {
log.Error(err)
}
return nil
}
}
if req.Spec.BackupRepositoryName != "" && req.Spec.BackupRepositoryName != constants.WithoutBackupRepository {
var backupRepositoryCR *backupdriverapi.BackupRepository
backupRepositoryCR, err = backuprepository.GetBackupRepositoryFromBackupRepositoryName(req.Spec.BackupRepositoryName)
if err != nil {
log.WithError(err).Errorf("Failed to get BackupRepository from BackupRepositoryName %s", req.Spec.BackupRepositoryName)
return err
}
_, err = c.dataMover.CopyToRepoWithBackupRepository(peID, backupRepositoryCR)
} else {
_, err = c.dataMover.CopyToRepo(peID)
}
if err != nil {
log.Infof("CopyToRepo Error Received: %v", err.Error())
// Check if the request was canceled.
if errors.Is(err, context.Canceled) {
log.Infof("The upload of PE %v upload was canceled.", peID.String())
_, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseCanceled, "The upload was canceled.")
if err != nil {
return err
}
log.Infof("Upload Cancellation complete.")
return nil
} else {
errMsg := fmt.Sprintf("Failed to upload snapshot, %v, to durable object storage. %v", peID.String(), errors.WithStack(err))
_, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseUploadError, errMsg)
if err != nil {
errMsg = fmt.Sprintf("%v. %v", errMsg, errors.WithStack(err))
}
log.Error(errMsg)
return errors.New(errMsg)
}
}
// Unregister on-going upload
c.dataMover.UnregisterOngoingUpload(peID)
// Call snapshot manager API to cleanup the local snapshot
err = c.snapMgr.DeleteLocalSnapshot(peID)
if err != nil {
errMsg := fmt.Sprintf("Failed to clean up local snapshot after uploading snapshot, %v. %v", peID.String(), errors.WithStack(err))
// TODO: Change the upload CRD definition to add one more phase, such as, UploadPhaseFailedLocalCleanup
_, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseCleanupFailed, errMsg)
if err != nil {
errMsg = fmt.Sprintf("%v. %v", errMsg, errors.WithStack(err))
}
log.Error(errMsg)
return errors.New(errMsg)
}
// update status to Completed with path & snapshot id
req, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseCompleted, "Upload completed")
if err != nil {
return errors.WithStack(err)
}
log.Info("Upload Completed")
return nil
}
func (c *uploadController) patchUpload(req *pluginv1api.Upload, mutate func(*pluginv1api.Upload)) (*pluginv1api.Upload, error) {
log := loggerForUpload(c.logger, req)
return utils.PatchUpload(req, mutate, c.uploadClient.Uploads(req.Namespace), log)
}
func (c *uploadController) patchUploadByStatusWithRetry(req *pluginv1api.Upload, newPhase pluginv1api.UploadPhase, msg string) (*pluginv1api.Upload, error) {
var updatedUpload *pluginv1api.Upload
var err error
log := loggerForUpload(c.logger, req)
log.Debugf("Ready to call patchUploadByStatus API. Will retry on patch failure of Upload status every %d seconds up to %d seconds.", constants.RetryInterval, constants.RetryMaximum)
err = wait.PollImmediate(constants.RetryInterval*time.Second, constants.RetryInterval*constants.RetryMaximum*time.Second, func() (bool, error) {
updatedUpload, err = c.patchUploadByStatus(req, newPhase, msg)
if err != nil {
return false, nil
}
return true, nil
})
log.Debugf("Return from patchUploadByStatus with retry %v times.", constants.RetryMaximum)
if err != nil {
log.WithError(err).Errorf("Failed to patch Upload, retry time exceeds maximum %d.", constants.RetryMaximum)
}
return updatedUpload, err
}
func (c *uploadController) patchUploadByStatus(req *pluginv1api.Upload, newPhase pluginv1api.UploadPhase, msg string) (*pluginv1api.Upload, error) {
// update status to Failed
log := loggerForUpload(c.logger, req)
oldPhase := req.Status.Phase
var err error
switch newPhase {
case pluginv1api.UploadPhaseCompleted:
req, err = c.patchUpload(req, func(r *pluginv1api.Upload) {
r.Status.Phase = newPhase
r.Status.CompletionTimestamp = &metav1.Time{Time: c.clock.Now()}
r.Status.Message = msg
})
case pluginv1api.UploadPhaseUploadError, pluginv1api.UploadPhaseCleanupFailed:
var retry int32
req, err = c.patchUpload(req, func(r *pluginv1api.Upload) {
r.Status.Phase = newPhase
r.Status.CompletionTimestamp = &metav1.Time{Time: c.clock.Now()}
r.Status.Message = msg
r.Status.RetryCount = r.Status.RetryCount + 1
log.Debugf("Retry for %d times", r.Status.RetryCount)
retry = r.Status.RetryCount
currentBackOff := math.Exp2(float64(retry - 1))
if currentBackOff >= constants.UPLOAD_MAX_BACKOFF {
currentBackOff = constants.UPLOAD_MAX_BACKOFF
}
r.Status.CurrentBackOff = int32(currentBackOff)
r.Status.NextRetryTimestamp = &metav1.Time{Time: c.clock.Now().Add(time.Duration(currentBackOff) * time.Minute)}
})
if retry > constants.RETRY_WARNING_COUNT {
errMsg := fmt.Sprintf("Please fix the network issue on the work node, %s", c.nodeName)
log.Warningf(errMsg)
}
case pluginv1api.UploadPhaseInProgress:
req, err = c.patchUpload(req, func(r *pluginv1api.Upload) {
if r.Status.Phase == pluginv1api.UploadPhaseNew {
r.Status.StartTimestamp = &metav1.Time{Time: c.clock.Now()}
r.Status.RetryCount = constants.MIN_RETRY
}
r.Status.Phase = newPhase
r.Status.ProcessingNode = c.nodeName
})
case pluginv1api.UploadPhaseCanceled:
req, err = c.patchUpload(req, func(r *pluginv1api.Upload) {
r.Status.Phase = newPhase
r.Status.CompletionTimestamp = &metav1.Time{Time: c.clock.Now()}
r.Status.Message = msg
})
case pluginv1api.UploadPhaseCanceling:
req, err = c.patchUpload(req, func(r *pluginv1api.Upload) {
r.Status.Phase = newPhase
r.Status.CompletionTimestamp = &metav1.Time{Time: c.clock.Now()}
r.Status.Message = msg
})
default:
err = errors.New("Unexpected upload phase")
}
if err != nil {
log.WithError(err).Errorf("Failed to patch Upload from %v to %v", oldPhase, newPhase)
} else {
log.Infof("Upload status updated from %v to %v", oldPhase, newPhase)
}
return req, err
}
func loggerForUpload(baseLogger logrus.FieldLogger, req *pluginv1api.Upload) logrus.FieldLogger {
log := baseLogger.WithFields(logrus.Fields{
"namespace": req.Namespace,
"name": req.Name,
"snapshotID": req.Spec.SnapshotID,
"phase": req.Status.Phase,
"generation": req.Generation,
})
if len(req.OwnerReferences) == 1 {
log = log.WithField("upload", fmt.Sprintf("%s/%s", req.Namespace, req.OwnerReferences[0].Name))
}
return log
}
func (c *uploadController) exponentialBackoffHandler(key string) error {
log := c.logger.WithField("key", key)
log.Debug("Running exponentialBackoffHandler")
ns, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
log.WithError(err).Error("Failed to split the key of queue item")
c.queue.Forget(key)
return nil
}
req, err := c.uploadLister.Uploads(ns).Get(name)
if apierrors.IsNotFound(err) {
log.Error("Upload is not found")
c.queue.Forget(key)
return nil
}
if err != nil {
return errors.Wrap(err, "Failed to get Upload")
}
log.Infof("Re-adding failed upload to the queue")
c.queue.AddAfter(key, time.Duration(req.Status.CurrentBackOff)*time.Minute)
return nil
}
func (c *uploadController) triggerUploadCancellation(req *pluginv1api.Upload) error {
log := loggerForUpload(c.logger, req)
cancelPeId, err := astrolabe.NewProtectedEntityIDFromString(req.Spec.SnapshotID)
if err != nil {
log.Errorf("Error received when processing cancel")
return err
}
uploadStatus := c.dataMover.IsUploading(cancelPeId)
if !uploadStatus {
log.Infof("Current node: %v is not processing the upload, skipping", c.nodeName)
return nil
}
_, err = c.patchUploadByStatusWithRetry(req, pluginv1api.UploadPhaseCanceling, "Canceling on-going upload to repository.")
if err != nil {
log.WithError(err).Error("Failed to patch ongoing Upload to Canceling state")
return err
}
log.Infof("Current node: %v is processing the upload for PE %v, triggering cancel", c.nodeName, cancelPeId.String())
err = c.dataMover.CancelUpload(cancelPeId)
if err != nil {
return err
}
log.Infof("Upload cancellation trigger on current node: %v for PE %v is complete.", c.nodeName, cancelPeId.String())
return nil
}