Skip to content

manager: keep OCM AddOn manager running until context cancelled#28

Merged
tamalsaha merged 1 commit into
masterfrom
fix-manager-blocking
Jun 21, 2026
Merged

manager: keep OCM AddOn manager running until context cancelled#28
tamalsaha merged 1 commit into
masterfrom
fix-manager-blocking

Conversation

@tamalsaha

Copy link
Copy Markdown
Contributor

Problem

fargocd manager exits immediately instead of staying running:

go run cmd/fargocd/*.go manager --kubeconfig ~/.kube/config

Root cause

addonManager.Start(ctx) from the addon-framework only launches its
informers in background goroutines and returns nil immediately — it is
not a blocking call. runManagerController returned that value directly,
and the cmdfactory runner does return c.startFunc(...) when leader
election is disabled (the default for a local --kubeconfig run). With
nothing left to keep the process alive, it exited cleanly the moment
Start returned.

(With leader election enabled, the same premature return would instead
trip the "controllers terminated prematurely" path and os.Exit(1).)

Fix

Block on <-ctx.Done() after Start succeeds — the standard OCM addon
pattern. The context is the signal-aware context wired by the cmdfactory,
so the manager now runs until SIGTERM/SIGINT.

addonManager.Start only launches the informers in background goroutines
and returns nil immediately. With leader election disabled (the default
for a local --kubeconfig run), the command runner returns that value
directly, so the process exited as soon as Start returned instead of
staying up. Block on ctx.Done() after Start so the manager keeps running
until SIGTERM/SIGINT.

Signed-off-by: Tamal Saha <tamal@appscode.com>
@tamalsaha tamalsaha merged commit bdf0891 into master Jun 21, 2026
4 checks passed
@tamalsaha tamalsaha deleted the fix-manager-blocking branch June 21, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant