Add background cleanup process
When given the "run" argument, in addition to launching `podman system service` in the background, also start a small periodic maintenance script. It's only job is to clean up stale images, containers, and volumes from old jobs. Currently hard-coded to trigger every 2 days, this could be tweaked via build-args or env. var. Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
19
podman-in-podman-maintenance
Normal file
19
podman-in-podman-maintenance
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script is intended to be called by the entrypoint for
|
||||
# a podman-in-podman gitlab runner container. Any usage
|
||||
# outside that context is not supported and may cause harm.
|
||||
|
||||
set -e
|
||||
|
||||
maintain_podman() {
|
||||
# Two days seems to be a good happy-medium beween filling up
|
||||
# about 40gig of storage space from moderate CI activity,
|
||||
# and maintaining a useful level of caching.
|
||||
while sleep 2d; do
|
||||
if [[ -n "$PODMAN_RUNNER_DEBUG" ]]; then
|
||||
echo "$(date --iso-8601=second) ${BASH_SOURCE[0] performing podman maintenance}"
|
||||
fi
|
||||
podman system prune --all --force
|
||||
done
|
||||
}
|
||||
Reference in New Issue
Block a user