-
Notifications
You must be signed in to change notification settings - Fork 232
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
Don't force requeuing after adding finalizer in GitRepo controller #3284
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change is meant to avoid an extra `Reconcile` call when adding the finalizer to `GitRepo`. The reconciler will get called anyway because generation changes and, also because generation changes, we'll avoid an extra call to the polling function. See below the difference of with and without the change. I've added a new extra log lines to show the difference (that are not part of this pull request) **without change** ```bash 2025-01-30T13:45:49Z INFO gitjob TESTFINALIZER Reconciling GitRepo {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "5517b2f5-2d4e-415b-b0e5-859cc070d9af"} 2025-01-30T13:45:49Z INFO gitjob TESTFINALIZER -- finalizer added {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "5517b2f5-2d4e-415b-b0e5-859cc070d9af"} 2025-01-30T13:45:49Z INFO gitjob TESTFINALIZER Reconciling GitRepo {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "94d228b5-c018-46af-9b69-b04b17ed976a"} 2025-01-30T13:45:49Z INFO gitjob TESTFINALIZER --- GitRepo polled {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "94d228b5-c018-46af-9b69-b04b17ed976a", "generation": 2, "commit": "", "conditions": null} 2025-01-30T13:45:49Z INFO gitjob TESTFINALIZER Reconciling GitRepo {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "1c71ae46-ea6b-452c-8896-704293f24584"} 2025-01-30T13:45:49Z INFO gitjob TESTFINALIZER --- GitRepo polled {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "1c71ae46-ea6b-452c-8896-704293f24584", "generation": 2, "commit": "", "conditions": [{"type":"Ready","status":"True","lastUpdateTime":"2025-01-30T13:45:49Z"}]} ``` `GitRepo` is polled twice. 1 time with generation=1 and the second with generation=2 **with change** ```bash 2025-01-30T13:54:19Z INFO gitjob TESTFINALIZER Reconciling GitRepo {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "4cb52a70-d552-4cda-85f7-058a9d129e1f"} 2025-01-30T13:54:19Z INFO gitjob TESTFINALIZER -- finalizer added {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "4cb52a70-d552-4cda-85f7-058a9d129e1f"} 2025-01-30T13:54:19Z INFO gitjob TESTFINALIZER Reconciling GitRepo {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "52cce150-c17c-4242-acb8-6b05ba3ecd58"} 2025-01-30T13:54:19Z INFO gitjob TESTFINALIZER --- GitRepo polled {"controller": "gitrepo", "controllerGroup": "fleet.cattle.io", "controllerKind": "GitRepo", "GitRepo": {"name":"simple","namespace":"fleet-local"}, "namespace": "fleet-local", "name": "simple", "reconcileID": "52cce150-c17c-4242-acb8-6b05ba3ecd58", "generation": 2, "commit": "", "conditions": null} ``` `GitRepo` is only polled 1 time when generation=2 Signed-off-by: Xavi Garcia <[email protected]>
Signed-off-by: Xavi Garcia <[email protected]>
Signed-off-by: Xavi Garcia <[email protected]>
51d989d
to
8e84d54
Compare
Changes ImageScanCommit to a pointer because otherwise default values are stored on the first time a `GitRepo` is updated and generation is changed, which means another call to the reconciler. This creates a double call to fetch for new commits (poll the `GitRepo`) when a `GitRepo` is added. On the first time it will poll because `LastPollingTime` in Status is not set yet. And the second time it will fetch for new commits is when generations changes from 1 to 2 (which is almost immediate after the `GitRepo` is updated to add the finalizer. Signed-off-by: Xavi Garcia <[email protected]>
Closing for clarity and following in: #3302 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change is meant to avoid an extra
Reconcile
call when adding the finalizer toGitRepo
. The reconciler will get called anyway because generation changes and, also because generation changes, we'll avoid an extra call to the polling function.See below the difference of with and without the change. I've added a new extra log lines to show the difference (that are not part of this pull request)
without change
GitRepo
is polled twice.with change
GitRepo
is only polled 1 time