You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Request]: Clean container root fs and rw-mounted volumes periodically. #2206
Once #1949 is merged, we can implement periodic clean on containers so that filesystem blocks deallocated in Linux filesystems can be freed on the host. Today, the disk image files grow in size (number of allocated host blocks as shown by ls -s) but never decrease.
For short-running containers this is less of a problem, but longer running containers that frequently create and delete files (such as the builder) can consume quite a bit of host capacity.
A simple implementation is all that is necessary for now, something like running clean from a task in container-runtime-linux every hour, serialized such that only one of a scheduled clean and a user's container clean run at once.
@amanmaurya92 sure! I've assigned you. Sorry for the delay, I was gone for most of September.
Before you do a PR, could you write up a brief (if you use AI, tell it to keep it concise :D) proposal here for what you plan to do and what the change would generally look like?
I don't want to be prescriptive about it. The only thing I'd suggest is that we keep the initial feature minimal - we probably don't need a lot of customizable options initially.
Hi @jglogan, thanks! Here is a concise proposal for what the initial change would look like (formatted using gemini since it is a new feature)
Extract Clean Logic:
Refactor the filesystem trim logic from RuntimeService.clean into an internal helper method (performClean()) targeting / (if not read-only) and any non-read-only block mounts.
Periodic Task in RuntimeService:
In RuntimeService.startProcess, once the container enters .running, spawn a background Task that sleeps on a 1-hour interval and runs performClean().
Cancel the task cleanly during container teardown in cleanUpContainer.
Serialization & Fault Tolerance:
Guard performClean() with a lock or active-cleaning state flag so an incoming manual container clean XPC call and the scheduled background task cannot run concurrently.
Catch and log errors in the background loop so filesystem trim errors never disrupt the container workload.
Does this plan look good to you, or would you prefer any adjustments before I start on the PR?
Activity
amanmaurya92 commentedon Sep 3, 2026
@jglogan can i work on this since #1949 is merged?
jglogan commentedon Oct 9, 2026
@amanmaurya92 sure! I've assigned you. Sorry for the delay, I was gone for most of September.
Before you do a PR, could you write up a brief (if you use AI, tell it to keep it concise :D) proposal here for what you plan to do and what the change would generally look like?
I don't want to be prescriptive about it. The only thing I'd suggest is that we keep the initial feature minimal - we probably don't need a lot of customizable options initially.
amanmaurya92 commentedon Oct 11, 2026
Hi @jglogan, thanks! Here is a concise proposal for what the initial change would look like (formatted using gemini since it is a new feature)
Extract Clean Logic:
Refactor the filesystem trim logic from
RuntimeService.cleaninto an internal helper method (performClean()) targeting/(if not read-only) and any non-read-only block mounts.Periodic Task in
RuntimeService:In
RuntimeService.startProcess, once the container enters.running, spawn a backgroundTaskthat sleeps on a 1-hour interval and runsperformClean().Cancel the task cleanly during container teardown in
cleanUpContainer.Serialization & Fault Tolerance:
Guard
performClean()with a lock or active-cleaning state flag so an incoming manualcontainer cleanXPC call and the scheduled background task cannot run concurrently.Catch and log errors in the background loop so filesystem trim errors never disrupt the container workload.
Does this plan look good to you, or would you prefer any adjustments before I start on the PR?
[Runtime] Clean container rootfs and rw volumes periodically
[Runtime] Clean container rootfs and rw volumes periodically
[Runtime] Clean container rootfs and rw volumes periodically