saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.21k stars 5.48k forks source link

[FEATURE REQUEST] Run garbage collection on cached git repos #61056

Open OrangeDog opened 3 years ago

OrangeDog commented 3 years ago

Is your feature request related to a problem? Please describe. When using gitfs and git_pillar, the cached repos will grow as more changes are pulled, but storage is never optimised and unreachable commits are never removed,

Describe the solution you'd like Runner function(s) to run git gc on all cached repos, and ideally a built-in schedule to run it. It could be tied to existing pillar/filesystem refresh rather than a separate call.

Describe alternatives you've considered Creating a periodic schedule to run find /var/cache/salt/ -type d -name '.git' -exec git --git-dir '{}' gc \;

Additional context I just saved over a GB of disk space doing this manually for the first time.

OrangeDog commented 3 years ago

There's also a lot of obsolete entries in /var/cache/salt/master/gitfs/{hash,refs}, and no obvious way to safely remove them.

s0undt3ch commented 3 years ago

It's a valid feature request.

tacerus commented 1 year ago

We frequently have these directories eating up to 20GB disk space (which was already increase from 10GB), it seems to grow continuously if not cleaned up. Thanks for the tip about git gc - this might be a bit less intrusive than stopping the Salt master, removing /var/cache/salt/master/*, and starting it again.

niklasteichmann commented 11 months ago

We have observed in our environment that the git garbage collector does clear up some disk space, but the salt master keeps some file handles open indefinitely. This leads to a slow creep of zombie files that are nominally deleted, but are actually still allocated on the disk.

The only solution we found was regularly restarting the salt master.

Has anyone experienced something similar and/or an alternative solution?