Skip to content

[addon-operator] fix dedupe one startup - #837

Merged
ldmonster merged 1 commit into
mainfrom
fix/dedupe-on-startup
Sep 16, 2026
Merged

ldmonster merged 1 commit into
mainfrom
fix/dedupe-on-startup

Conversation

@ldmonster

@ldmonster ldmonster commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Overview

PushRunModuleTask is supposed to skip pushing a moduleRun task when the main queue already holds one for the same module. The guard behind it only answered true for pending tasks carrying DoModuleStartup, so it never fired for the way callers actually push — with doModuleStartup=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:

  1. The dedup guard ignored non-startup pushes. queueHasPendingModuleRunTaskWithStartup(q, moduleName) returned meta.doStartup, i.e. it only reported a duplicate when the pending task ran the startup sequence. Every caller pushes with doModuleStartup=false, so the guard returned false for all of them and PushRunModuleTask appended a task every time it was called. The main queue filled up with identical moduleRun tasks 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:

    pending task push covered
    with startup with startup yes
    with startup without startup yes
    without startup without startup yes (the fixed case)
    without startup with startup no

    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.

  2. modulesWithPendingTasks let the last task seen decide for the module. The scan assigned modules[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.

Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
@ldmonster ldmonster self-assigned this Sep 16, 2026
@ldmonster ldmonster added the bug Something isn't working label Sep 16, 2026
@ldmonster
ldmonster merged commit 523ecb6 into main Sep 16, 2026
11 of 12 checks passed
@ldmonster
ldmonster deleted the fix/dedupe-on-startup branch September 16, 2026 15:04
ldmonster added a commit that referenced this pull request Sep 16, 2026
(cherry picked from commit 523ecb6)

Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant