Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Backup.Status.CSIVolumeSnapshotsCompleted during finalize #7046

Merged
merged 8 commits into from
Nov 15, 2023

Conversation

kaovilai
Copy link
Member

@kaovilai kaovilai commented Nov 1, 2023

Signed-off-by: Tiger Kaovilai [email protected]

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Fixes #7047

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

@kaovilai
Copy link
Member Author

kaovilai commented Nov 1, 2023

/kind changelog-not-required

@kaovilai kaovilai force-pushed the backup-patch-status-unittest branch from a249fd6 to f8444e1 Compare November 1, 2023 17:16
@github-actions github-actions bot added the kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes label Nov 1, 2023
@kaovilai kaovilai force-pushed the backup-patch-status-unittest branch from f8444e1 to ca5c3d2 Compare November 1, 2023 17:17
@kaovilai kaovilai force-pushed the backup-patch-status-unittest branch from ca5c3d2 to 886e074 Compare November 1, 2023 19:29
@kaovilai kaovilai marked this pull request as draft November 1, 2023 21:15
@kaovilai kaovilai force-pushed the backup-patch-status-unittest branch from de3ea52 to 7efe36b Compare November 2, 2023 19:12
@kaovilai kaovilai changed the title Add PatchResource unit test for backup status Update Backup.Status.CSIVolumeSnapshotsCompleted during finalize Nov 2, 2023
@kaovilai kaovilai force-pushed the backup-patch-status-unittest branch from 7efe36b to 60a0232 Compare November 2, 2023 19:20
@kaovilai kaovilai changed the title Update Backup.Status.CSIVolumeSnapshotsCompleted during finalize Update and wait for Backup.Status.CSIVolumeSnapshotsCompleted during finalize Nov 2, 2023
@kaovilai kaovilai force-pushed the backup-patch-status-unittest branch from 60a0232 to 3209650 Compare November 2, 2023 19:21
@kaovilai kaovilai marked this pull request as ready for review November 2, 2023 19:22
@sseago
Copy link
Collaborator

sseago commented Nov 2, 2023

@kaovilai I think we'd want a changelog here since this fixes a regression introduced in 1.12

@@ -186,7 +191,16 @@ func (r *backupFinalizerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}
backup.Status.CompletionTimestamp = &metav1.Time{Time: r.clock.Now()}
recordBackupMetrics(log, backup, outBackupFile, r.metrics, true)

CSISnapshotsNotReady := errors.New("CSI snapshots not ready")
retry.OnError(retry.DefaultBackoff, func(err error) bool {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question here is how long do we wanna wait for CSI to complete.

At this phase it is also probably safe to unblock a new backup, not sure if that's the case already.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaovilai no reason to wait here. All the waiting happens during WaitingForPluginOperations phase in the backup operations controller. By the time finalizer controller reconciles a backup, we're no longer waiting for snapshot completion. They're all either completed, failed explicitly, or marked failed via timeout.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to just check status a single time like we've always done in the backup controller.

@kaovilai kaovilai force-pushed the backup-patch-status-unittest branch from 3209650 to 1dbcd1f Compare November 2, 2023 19:27
…tus() and run in backup_finalizer_controller

Signed-off-by: Tiger Kaovilai <[email protected]>
@kaovilai kaovilai force-pushed the backup-patch-status-unittest branch from 1dbcd1f to 9311a42 Compare November 2, 2023 19:30
Copy link

codecov bot commented Nov 2, 2023

Codecov Report

Merging #7046 (8c72742) into main (705a3bc) will decrease coverage by 0.10%.
Report is 17 commits behind head on main.
The diff coverage is 4.54%.

@@            Coverage Diff             @@
##             main    #7046      +/-   ##
==========================================
- Coverage   61.14%   61.04%   -0.10%     
==========================================
  Files         252      256       +4     
  Lines       26916    27076     +160     
==========================================
+ Hits        16457    16528      +71     
- Misses       9295     9373      +78     
- Partials     1164     1175      +11     
Files Coverage Δ
pkg/backup/request.go 100.00% <ø> (ø)
pkg/controller/backup_controller.go 61.96% <100.00%> (+0.91%) ⬆️
pkg/controller/backup_finalizer_controller.go 58.26% <100.00%> (+0.33%) ⬆️
pkg/controller/backup_operations_controller.go 46.09% <ø> (ø)
pkg/cmd/server/server.go 22.03% <0.00%> (ø)
pkg/backup/snapshots.go 0.00% <0.00%> (ø)

... and 6 files with indirect coverage changes

@kaovilai
Copy link
Member Author

kaovilai commented Nov 2, 2023

/kind changelog-not-required
does this undo changelog required label?

@@ -186,7 +191,16 @@ func (r *backupFinalizerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}
backup.Status.CompletionTimestamp = &metav1.Time{Time: r.clock.Now()}
recordBackupMetrics(log, backup, outBackupFile, r.metrics, true)

CSISnapshotsNotReady := errors.New("CSI snapshots not ready")
retry.OnError(retry.DefaultBackoff, func(err error) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaovilai no reason to wait here. All the waiting happens during WaitingForPluginOperations phase in the backup operations controller. By the time finalizer controller reconciles a backup, we're no longer waiting for snapshot completion. They're all either completed, failed explicitly, or marked failed via timeout.

@@ -186,7 +191,16 @@ func (r *backupFinalizerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}
backup.Status.CompletionTimestamp = &metav1.Time{Time: r.clock.Now()}
recordBackupMetrics(log, backup, outBackupFile, r.metrics, true)

CSISnapshotsNotReady := errors.New("CSI snapshots not ready")
retry.OnError(retry.DefaultBackoff, func(err error) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to just check status a single time like we've always done in the backup controller.

pkg/controller/backup_controller.go Show resolved Hide resolved
pkg/controller/backup_controller.go Show resolved Hide resolved
backup.Status.CSIVolumeSnapshotsAttempted = len(volumeSnapshots)
for _, vs := range volumeSnapshots {
if vs.Status != nil && boolptr.IsSetToTrue(vs.Status.ReadyToUse) {
backup.Status.CSIVolumeSnapshotsCompleted++
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is now run both during initial processing and finalizing, instead of incrementing the field directly, we should increment a local var and set the Spec field to this value at the end of the loop. Otherwise we'll end up double counting things.

@sseago sseago removed the kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes label Nov 2, 2023
@sseago
Copy link
Collaborator

sseago commented Nov 2, 2023

@kaovilai I removed the changelog-not-required label.

@kaovilai kaovilai requested a review from sseago November 2, 2023 20:21
@kaovilai kaovilai changed the title Update and wait for Backup.Status.CSIVolumeSnapshotsCompleted during finalize Update Backup.Status.CSIVolumeSnapshotsCompleted during finalize Nov 2, 2023
sseago
sseago previously approved these changes Nov 2, 2023
Signed-off-by: Tiger Kaovilai <[email protected]>
Signed-off-by: Tiger Kaovilai <[email protected]>
@ywk253100 ywk253100 merged commit 2a533d0 into vmware-tanzu:main Nov 15, 2023
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backup.Status.CSIVolumeSnapshotsCompleted < CSIVolumeSnapshotsAttempted or nil when backup phase is completed
3 participants