Skip to content

fix(dependson): fallback to unsorted enqueue on circular dependency - #1725

Open
AruneshDwivedi wants to merge 2 commits into
fluxcd:mainfrom
AruneshDwivedi:fix/dependson-circular-drop-all-reconciles
Open

fix(dependson): fallback to unsorted enqueue on circular dependency#1725
AruneshDwivedi wants to merge 2 commits into
fluxcd:mainfrom
AruneshDwivedi:fix/dependson-circular-drop-all-reconciles

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

fix(dependson): fallback to unsorted enqueue on circular dependency

When two or more Kustomizations referencing the same source form a dependsOn cycle, sortAndEnqueue in kustomization_indexers.go returns nil, which drops ALL reconciliation requests for that source — including Kustomizations not part of the cycle. This silently disables event-driven reconciliation for the entire source, with only a log line as evidence.

The topological ordering in sortAndEnqueue is an optimization. Out-of-order reconciles are already handled correctly by the DependencyNotReady requeue mechanism. Returning nil on sort error provides no correctness guarantee — a graceful fallback to unsorted enqueue loses nothing.

This PR changes sortAndEnqueue to fall back to unsorted enqueue when dependency.Sort returns an error (e.g. circular dependency), instead of dropping all requests.

Fixes #1712

[BUGFIX] Fix circular `dependsOn` silently disabling event-driven reconciliation for all Kustomizations sharing a source.

Arunesh Dwivedi added 2 commits August 30, 2026 04:20
sortAndEnqueue returns nil when dependency.Sort detects a circular
dependency, which drops ALL reconciliation requests for the source —
including Kustomizations not part of the cycle. This silently disables
event-driven reconciliation for the entire source.

Fix by falling back to unsorted enqueue on sort error. The ordering
is an optimization; out-of-order reconciles are handled by the
DependencyNotReady requeue mechanism.

Signed-off-by: Arunesh Dwivedi <arunesh@example.com>
Deferred os.RemoveAll calls in reconcile do not run on SIGKILL or
os.Exit(1), leaving orphaned kustomization-* directories in /tmp.
These accumulate across restarts and can consume significant ephemeral
storage (or memory when /tmp is tmpfs).

Add sweepStaleTmpDirs() called before mgr.Start() to clean leftover
dirs from ungraceful exits.

Signed-off-by: Arunesh Dwivedi <arunesh@example.com>
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.

Circular dependsOn silently disables event-driven reconciliation for all Kustomizations sharing the source

1 participant