[addon-operator] fix dedupe one startup - #837
Merged
Merged
Conversation
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@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.
Overview
PushRunModuleTaskis supposed to skip pushing amoduleRuntask when the main queue already holds one for the same module. The guard behind it only answeredtruefor pending tasks carryingDoModuleStartup, so it never fired for the way callers actually push — withdoModuleStartup=false. This PR makes the guard consider the flag of the push itself, and fixes the pending-task scan that feeds it.What this PR does / why we need it
Two related fixes in
pkg/module_manager/module_manager.go:The dedup guard ignored non-startup pushes.
queueHasPendingModuleRunTaskWithStartup(q, moduleName)returnedmeta.doStartup, i.e. it only reported a duplicate when the pending task ran the startup sequence. Every caller pushes withdoModuleStartup=false, so the guard returnedfalsefor all of them andPushRunModuleTaskappended a task every time it was called. The main queue filled up with identicalmoduleRuntasks and the module was rerun — and re-released — once per duplicate.It is now
queueHasPendingModuleRunTask(q, moduleName, doModuleStartup)and answers whether a pending task covers this push:The last row is the asymmetry worth keeping: a pending task that does strictly less work must not swallow a push that needs the startup, otherwise the startup is silently dropped.
modulesWithPendingTaskslet the last task seen decide for the module. The scan assignedmodules[hm.ModuleName] = struct{...}{doStartup: hm.DoModuleStartup}per task, so when a module had several pending tasks, a later one without the flag overwrote an earlier one with it — and a queued startup looked absent. It now ORs the flag across all pending tasks for the module.