Repository navigation
[addon-operator] fix: prevent batch hook name collisions - #878
Merged
Merged
Conversation
Signed-off-by: Ruslan Gorbunov <ruslan.gorbunov@flant.com>
Signed-off-by: Ruslan Gorbunov <ruslan.gorbunov@flant.com>
Signed-off-by: Ruslan Gorbunov <ruslan.gorbunov@flant.com>
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
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.<metadata.Name>:<key>instead ofhooks/go-hooks:<metadata.Name>:<key>(global hooks werehooks/go-hooks-<metadata.Name>-<key>). The readiness hook is namedreadinessinstead ofhooks/go-hooks-readiness.duplicate batch hook nameerror. Before, one of the hooks was silently dropped.readykey, sohook readyran twice on every trigger.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 printsModuleName, 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
modulemetric label.Hook names only need to be unique within a module, since
HooksStorageis per module. The binary path used to guarantee that uniqueness across binaries. Now that the path is gone,HooksStorage.AddHookwould 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.
remapSDKConfigToConfigalso stores the readiness config inHooks["ready"], becauseGetConfigForModulelooks up the config by hook ID. The loop overHooksthen registered that entry as a second hook with the same ID.