vgdp ms pvb controller

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
pull/9015/head
Lyndon-Li 2025-06-11 09:30:20 +00:00
parent 5b9904832d
commit c3a8c89ae3
5 changed files with 8 additions and 13 deletions

View File

@ -0,0 +1 @@
Fix issue #8958, add VGDP MS PVB controller

File diff suppressed because one or more lines are too long

View File

@ -247,7 +247,7 @@ func (r *PodVolumeBackupReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}
if pvb.Spec.Cancel {
log.Info("Prepared PVB is being cancelled")
log.Info("Prepared PVB is being canceled")
r.OnDataPathCancelled(ctx, pvb.GetNamespace(), pvb.GetName())
return ctrl.Result{}, nil
}
@ -345,7 +345,7 @@ func (r *PodVolumeBackupReconciler) Reconcile(ctx context.Context, req ctrl.Requ
// Update status to Canceling
if err := UpdatePVBWithRetry(ctx, r.client, types.NamespacedName{Namespace: pvb.Namespace, Name: pvb.Name}, log, func(pvb *velerov1api.PodVolumeBackup) bool {
if isPVBInFinalState(pvb) {
log.Warnf("PVB %s is terminated, abort setting it to cancelling", pvb.Name)
log.Warnf("PVB %s is terminated, abort setting it to canceling", pvb.Name)
return false
}

View File

@ -624,7 +624,6 @@ func TestOnPVBProgress(t *testing.T) {
r.OnDataPathProgress(ctx, namespace, pvbName, progress)
if len(test.needErrs) != 0 && !test.needErrs[0] {
updatedPvb := &velerov1api.PodVolumeBackup{}
assert.NoError(t, r.client.Get(ctx, types.NamespacedName{Name: pvbName, Namespace: namespace}, updatedPvb))
assert.Equal(t, test.progress.TotalBytes, updatedPvb.Status.Progress.TotalBytes)
@ -740,18 +739,13 @@ func TestAcceptPvb(t *testing.T) {
}{
{
name: "update fail",
pvb: pvbBuilder().Result(),
pvb: pvbBuilder().Node("test-node").Result(),
needErrs: []error{nil, nil, fmt.Errorf("fake-update-error"), nil},
expectedErr: "fake-update-error",
},
{
name: "accepted by others",
pvb: pvbBuilder().Result(),
needErrs: []error{nil, nil, &fakeAPIStatus{metav1.StatusReasonConflict}, nil},
expectedErr: "error updating PVB with error velero/pvb-1: fake-update-error",
},
{
name: "succeed",
pvb: pvbBuilder().Result(),
pvb: pvbBuilder().Node("test-node").Result(),
needErrs: []error{nil, nil, nil, nil},
},
}

View File

@ -181,7 +181,7 @@ func newBackupper(
// the PVB in the indexer is already in final status, no need to call WaitGroup.Done()
if ok && (existPVB.Status.Phase == velerov1api.PodVolumeBackupPhaseCompleted ||
existPVB.Status.Phase == velerov1api.PodVolumeBackupPhaseFailed ||
pvb.Status.Phase != velerov1api.PodVolumeBackupPhaseCanceled) {
pvb.Status.Phase == velerov1api.PodVolumeBackupPhaseCanceled) {
statusChangedToFinal = false
}
}