Repository navigation
Purge stale tmp dirs at startup - #2176
Merged
Merged
Conversation
Closed
When the controller exits without running its deferred cleanup, after losing its leader lease or being OOM killed, the temporary directories of the reconciles in flight stay behind. They survive container restarts on an emptyDir volume, so a controller that restarts often fills the node. The controller now keeps its temporary files in a directory of its own under the system temp dir and points TMPDIR at it, so the files created by the Helm and Git libraries land there too. At startup, whatever a previous process left in that directory is moved aside and removed in the background, the same way kustomize-controller purges its tmp dirs. Signed-off-by: Andrii Bryndzak <abryndzak@datum.net>
stefanprodan
force-pushed
the
fix-purge-stale-tmp
branch
from
October 22, 2026 22:31
91484bd to
4cce931
Compare
Log tmp dir setup failures and keep the default TMPDIR instead of exiting. Empty stale roots one entry at a time so the purge timeout applies between entries. Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
stefanprodan
force-pushed
the
fix-purge-stale-tmp
branch
from
October 22, 2026 22:32
4cce931 to
54bdf3e
Compare
stefanprodan
approved these changes
Oct 22, 2026
stefanprodan
left a comment
Member
There was a problem hiding this comment.
LGTM
Thanks @andrewb3000
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.
Fixes #1793
When source-controller exits without running its deferred cleanup, after losing its leader lease or being OOM killed, the temporary directories of the reconciles in flight stay behind. On an emptyDir
/tmpthey survive container restarts, so a controller that restarts often slowly fills the node's disk.This is the source-controller counterpart of fluxcd/kustomize-controller#1729.
kustomize-controller's fix matches a fixed name prefix. That doesn't carry over here: temp paths are named after the object (
<kind>-<namespace>-<name>-*, orKind-...in the Bucket reconciler), and the Helm code addschart-index-*,chart-build-*and*.tgzpaths of its own. So instead:$TMPDIR/source-controllerand pointsTMPDIRat it, so every temp path, including the ones created by the Helm and Git libraries, lands in one directory.source-controller.stale-<ts>) and removed in the background, with a two minute budget, so startup isn't delayed. A purge cut short by a later crash is picked up on the next start.Only the controller's own subdirectory is touched, so this is safe when
TMPDIRis shared, for example when running the binary locally.