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

Use predicate in finalizer controllers to only process update events. #7941

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kaovilai
Copy link
Contributor

Signed-off-by: Tiger Kaovilai tkaovila@redhat.com

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Fixes #7868

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.

/kind changelog-not-required

@kaovilai
Copy link
Contributor Author

/kind changelog-not-required

@kaovilai kaovilai force-pushed the finalizerControllerPredicates branch from 9261b6f to 9307517 Compare June 27, 2024 03:50
@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 Jun 27, 2024
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.

Project coverage is 58.79%. Comparing base (c827fd0) to head (e62d4a8).
Report is 28 commits behind head on main.

Files Patch % Lines
pkg/controller/restore_finalizer_controller.go 0.00% 10 Missing ⚠️
pkg/controller/backup_finalizer_controller.go 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7941      +/-   ##
==========================================
- Coverage   58.79%   58.79%   -0.01%     
==========================================
  Files         345      346       +1     
  Lines       28766    28917     +151     
==========================================
+ Hits        16914    17002      +88     
- Misses      10423    10483      +60     
- Partials     1429     1432       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

if !ok {
return false
}
return backup.Status.Phase == velerov1api.BackupPhaseFinalizing || backup.Status.Phase == velerov1api.BackupPhaseFinalizingPartiallyFailed
Copy link
Contributor

Choose a reason for hiding this comment

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

We should return the opposite result here.
Restore reconciler should also be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

	// Update returns true if the Update event should be processed
	UpdateFunc func(event.UpdateEvent) bool

Don't we want events to be processed if CR was updated to finalizing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kaovilai so there are 2 cases where we want to process backups in this controller:

  1. backups updated to Finalizing or FinalizingPartiallyFailed phase
  2. backups already in finalizing phase that returned err from prior reconcile (i.e. requeueing)

Does this predicate change affect requeue behavior?

Copy link
Collaborator

Choose a reason for hiding this comment

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

But yes, for the predicate, it looks like we want to return true for backups in these two phases.

if !ok {
return false
}
return backup.Status.Phase == velerov1api.BackupPhaseFinalizing || backup.Status.Phase == velerov1api.BackupPhaseFinalizingPartiallyFailed
Copy link
Collaborator

Choose a reason for hiding this comment

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

@kaovilai so there are 2 cases where we want to process backups in this controller:

  1. backups updated to Finalizing or FinalizingPartiallyFailed phase
  2. backups already in finalizing phase that returned err from prior reconcile (i.e. requeueing)

Does this predicate change affect requeue behavior?

if !ok {
return false
}
return backup.Status.Phase == velerov1api.BackupPhaseFinalizing || backup.Status.Phase == velerov1api.BackupPhaseFinalizingPartiallyFailed
Copy link
Collaborator

Choose a reason for hiding this comment

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

But yes, for the predicate, it looks like we want to return true for backups in these two phases.

pkg/controller/backup_finalizer_controller.go Outdated Show resolved Hide resolved
pkg/controller/restore_finalizer_controller.go Outdated Show resolved Hide resolved
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
@kaovilai kaovilai force-pushed the finalizerControllerPredicates branch from 9307517 to e62d4a8 Compare July 12, 2024 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes
Projects
None yet
3 participants