fix(dependson): fallback to unsorted enqueue on circular dependency - #1725
fix(dependson): fallback to unsorted enqueue on circular dependency#1725AruneshDwivedi wants to merge 2 commits into
Conversation
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>
Karthik-Chowdary
left a comment
There was a problem hiding this comment.
The sortAndEnqueue fallback is directionally sound, but this PR currently includes a second, unrelated startup cleanup commit in main.go. That sweep deletes every directory matching $TMPDIR/kustomization-* without establishing ownership by this controller instance or checking whether another controller process is actively using it. Multiple controller instances can share /tmp (for example with a hostPath or other shared volume), and a newly starting instance could remove another live instance’s checkout. It is also unrelated to #1712 and has no tests here. Please drop the main.go commit from this PR and keep the circular-dependency fix focused; add a regression test that proves a sort error returns all original reconciliation requests rather than silently dropping them.
fix(dependson): fallback to unsorted enqueue on circular dependency
When two or more Kustomizations referencing the same source form a
dependsOncycle,sortAndEnqueueinkustomization_indexers.goreturnsnil, 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
sortAndEnqueueis an optimization. Out-of-order reconciles are already handled correctly by theDependencyNotReadyrequeue mechanism. Returningnilon sort error provides no correctness guarantee — a graceful fallback to unsorted enqueue loses nothing.This PR changes
sortAndEnqueueto fall back to unsorted enqueue whendependency.Sortreturns an error (e.g. circular dependency), instead of dropping all requests.Fixes #1712