Skip to content

[addon-operator] fix: prevent batch hook name collisions - #878

Merged
ldmonster merged 3 commits into
mainfrom
fix/batch-hook-name-module
Dec 1, 2026
Merged

ldmonster merged 3 commits into
mainfrom
fix/batch-hook-name-module

Conversation

@fuldaxxx

@fuldaxxx fuldaxxx commented Dec 1, 2026

Copy link
Copy Markdown
Member

Description

  • Module hook task descriptions (queue dump, queue logs) now start with the module name. Before: ModuleHookRun:main:kubernetes:hooks/go-hooks:go/hooks/postgres_credentials_hash:9:password_secrets:Kubernetes. After: ModuleHookRun:main:managed-postgres:kubernetes:go/hooks/postgres_credentials_hash:9:password_secrets:Kubernetes. This applies to shell, Go and batch module hooks. Global hook descriptions are unchanged.
  • Batch hook names no longer include the binary path, for both modules and the global module. A hook is now named <metadata.Name>:<key> instead of hooks/go-hooks:<metadata.Name>:<key> (global hooks were hooks/go-hooks-<metadata.Name>-<key>). The readiness hook is named readiness instead of hooks/go-hooks-readiness.
  • If two batch binaries of the same module report a hook with the same name, hook discovery now fails with a duplicate batch hook name error. Before, one of the hooks was silently dropped.
  • The readiness hook of a batch binary is registered once. Before, it was also registered as a regular hook under the ready key, so hook ready ran twice on every trigger.
  • Errors from reading a batch hook config now name the module and no longer repeat the binary path.

Why do we need it, and what problem does it solve?

The main queue was flooded with batch hook tasks, and the queue dump showed no module name: every module ships its hooks as hooks/go-hooks, so the entries were impossible to tell apart.

The root cause is in HookMetadata.GetDescription(). The module-run branch prints ModuleName, but the module-hook branch omits it, even though the field is set. Batch hook names made it worse: they start with the binary path, which is the same in every module.

The module name is added to the task description, not to the hook name. The description is only used for display (queue dump and logs), and putting the module there covers all module hook types at once, shell hooks included. Prefixing the hook name with the module instead was rejected: it would only fix batch hooks, and it would duplicate the existing module metric label.

Hook names only need to be unique within a module, since HooksStorage is per module. The binary path used to guarantee that uniqueness across binaries. Now that the path is gone, HooksStorage.AddHook would silently replace a hook with the same name. Hence the explicit duplicate check.

The readiness duplicate is a separate bug that was found along the way. remapSDKConfigToConfig also stores the readiness config in Hooks["ready"], because GetConfigForModule looks up the config by hook ID. The loop over Hooks then registered that entry as a second hook with the same ID.

Signed-off-by: Ruslan Gorbunov <ruslan.gorbunov@flant.com>
@fuldaxxx
fuldaxxx requested a review from ldmonster December 1, 2026 07:34
@fuldaxxx fuldaxxx self-assigned this Dec 1, 2026
@fuldaxxx fuldaxxx added the enhancement New feature or request label Dec 1, 2026
Signed-off-by: Ruslan Gorbunov <ruslan.gorbunov@flant.com>
Signed-off-by: Ruslan Gorbunov <ruslan.gorbunov@flant.com>
@fuldaxxx
fuldaxxx marked this pull request as ready for review December 1, 2026 08:40
@ldmonster
ldmonster merged commit 8dd5610 into main Dec 1, 2026
9 of 11 checks passed
@ldmonster
ldmonster deleted the fix/batch-hook-name-module branch December 1, 2026 08:42
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.

2 participants