Skip to content

Conversation

@timmilesdw
Copy link
Contributor

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., during AssembleEnvironmentForModule()), the hasReadiness flag remains set to true from the search phase, but hooks.registered stays false. On retry, RegisterHooks calls searchModuleHooks() again, where searchModuleBatchHooks() sees hasReadiness=true from the previous failed attempt and returns error: "multiple readiness hooks found".

Root cause:
searchModuleBatchHooks() was setting bm.hasReadiness = true as a side effect during the search phase, before the registration could complete successfully.

Solution:

  • Remove side effects from searchModuleBatchHooks() - it now returns hasReadiness as a return value instead of modifying the struct field
  • bm.hasReadiness is now only set in RegisterHooks() after successful registration
  • This ensures that failed registration attempts don't leave stale state

Changes:

  • searchModuleBatchHooks() signature changed to return (hooks, hasReadiness, error) instead of (hooks, error)
  • searchModuleHooks() propagates hasReadiness up to RegisterHooks()
  • RegisterHooks() sets bm.hasReadiness only after successful registration
  • Added test TestHasReadinessNotSetOnFailedRegistration to verify the fix

Cherry-picked from: 8c21eb0

Special notes for your reviewer

This is a backport to release-1.15 branch for Deckhouse 1.73 compatibility. The fix cleanly applies without conflicts and all existing tests pass.

@timmilesdw timmilesdw added the enhancement New feature or request label Dec 1, 2025
Signed-off-by: Timur Tuktamyshev <[email protected]>
@timmilesdw timmilesdw force-pushed the cherry-pick-readiness-fix-1.15.12 branch from 8c32641 to 796fd4e Compare December 1, 2025 11:55
@ldmonster ldmonster changed the title fix readiness bug [addon-operator] Backport 1.15: fix readiness bug Dec 1, 2025
@ldmonster ldmonster merged commit b238283 into release-1.15 Dec 1, 2025
5 of 6 checks passed
@ldmonster ldmonster deleted the cherry-pick-readiness-fix-1.15.12 branch December 1, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants