[addon-operator] Backport 1.15: fix readiness bug #706
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.
Overview
Cherry-pick fix for "multiple readiness hooks found" error that occurs on hook registration retry after a previous failure.
What this PR does / why we need it
Problem:
When
RegisterHooks()fails (e.g., duringAssembleEnvironmentForModule()), thehasReadinessflag remains set totruefrom the search phase, buthooks.registeredstaysfalse. On retry,RegisterHookscallssearchModuleHooks()again, wheresearchModuleBatchHooks()seeshasReadiness=truefrom the previous failed attempt and returns error:"multiple readiness hooks found".Root cause:
searchModuleBatchHooks()was settingbm.hasReadiness = trueas a side effect during the search phase, before the registration could complete successfully.Solution:
searchModuleBatchHooks()- it now returnshasReadinessas a return value instead of modifying the struct fieldbm.hasReadinessis now only set inRegisterHooks()after successful registrationChanges:
searchModuleBatchHooks()signature changed to return(hooks, hasReadiness, error)instead of(hooks, error)searchModuleHooks()propagateshasReadinessup toRegisterHooks()RegisterHooks()setsbm.hasReadinessonly after successful registrationTestHasReadinessNotSetOnFailedRegistrationto verify the fixCherry-picked from: 8c21eb0
Special notes for your reviewer
This is a backport to
release-1.15branch for Deckhouse 1.73 compatibility. The fix cleanly applies without conflicts and all existing tests pass.