fix: prevent reconciler hook from skipping later plugins when an earlier one returns a continue result#9978
Merged
leonardoce merged 4 commits intocloudnative-pg:mainfrom Feb 19, 2026
Conversation
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
0340c6a to
60118b4
Compare
fd7350d to
fcdcbfb
Compare
fcdcbfb to
21069de
Compare
Member
|
/test |
Contributor
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/22066547149 |
armru
approved these changes
Feb 17, 2026
…ier one returns a continue result Signed-off-by: Sharif Shaker <[email protected]>
Signed-off-by: Sharif Shaker <[email protected]>
Signed-off-by: Sharif Shaker <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
21069de to
3b77f4e
Compare
leonardoce
approved these changes
Feb 19, 2026
cnpg-bot
pushed a commit
that referenced
this pull request
Feb 19, 2026
… result (#9978) When a plugin returned BEHAVIOR_CONTINUE, the reconcilerHook function incorrectly returned early, causing subsequent plugins to be skipped. This fix removes the early return, allowing the loop to properly iterate through all registered plugins. Assisted-by: Claude Opus 4.6 Signed-off-by: Sharif Shaker <[email protected]> Signed-off-by: Armando Ruocco <[email protected]> Co-authored-by: Armando Ruocco <[email protected]> (cherry picked from commit abe8a01)
cnpg-bot
pushed a commit
that referenced
this pull request
Feb 19, 2026
… result (#9978) When a plugin returned BEHAVIOR_CONTINUE, the reconcilerHook function incorrectly returned early, causing subsequent plugins to be skipped. This fix removes the early return, allowing the loop to properly iterate through all registered plugins. Assisted-by: Claude Opus 4.6 Signed-off-by: Sharif Shaker <[email protected]> Signed-off-by: Armando Ruocco <[email protected]> Co-authored-by: Armando Ruocco <[email protected]> (cherry picked from commit abe8a01)
This file contains hidden or 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
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.
Description
Fixes a bug where only the first plugin with
ReconcilerHookscapability is executed during cluster/backup reconciliation. When a plugin returnsBEHAVIOR_CONTINUE,the reconciler loop returns immediately instead of continuing to process remaining plugins.
It is not clear that there is another type of
reconciler.ReconcilerHooksResultthat should be returned to allow processing of subsequent plugins, unless plugins are expected to useReconcilerHooksResult_BEHAVIOR_UNSPECIFIED, but this seems inconsistent with the documentation.Root Cause
In
internal/cnpi/plugin/client/reconciler.go, thereconcilerHookfunction's switch statement forBEHAVIOR_CONTINUEreturns immediately:This breaks what I suspect is the intended behavior based on this definition
where I would imagine BEHAVIOR_CONTINUE should allow the loop to proceed to the next plugin before continuing with the operator's core reconciliation.
Solution
Changed the BEHAVIOR_CONTINUE case to continue the loop instead of returning:
Now all plugins that return the BEHAVIOR_CONTINUE cause the reconciler hook to iterate to the next plugin.
Testing
Deployed a cluster with two plugins:
Before Fix
The reconciler Pre hook on the second plugin (index 1) never executed
After Fix
The reconciler Pre hook for both plugins executed
Impact
I tested this with the latest version of the operator as of the time of the creation of this ticket at 1bf4584. The logic skipping plugins seems to present ever since
internal/cnpi/plugin/client/reconciler.gowas introduced a couple years ago and looks to be in v1.28x and v1.27.x.Assisted-by: Claude Opus 4.6