
This adds periodic cleanup of the directory which zun uses to temporarily cache images loaded from Glance to avoid it becoming too large. Docker image cleanup is adjusted to make it less aggressive as the 'until' filtering has been seen to clear images which were created more recently than one hour. The network pruning is removed as this causes zun to become out of sync with Docker which can prevent creation of new containers on pruned networks. Finally, the default is to leave cleanup disabled so that it can be enabled purely based upon user preference. As Systemd timers cannot be disabled, this is achieved via a file presence check with can be overridden for manual execution. Change-Id: I4532d9975a2e68a12a7755ca3798a59f4928593c
16 lines
475 B
Django/Jinja
16 lines
475 B
Django/Jinja
#!/bin/bash
|
|
|
|
# If the disabled file is present, don't allow the script
|
|
# to run unless it is forced.
|
|
if [ -e "/var/tmp/zun-docker-cleanup.disabled" ] && [ "$1" != "--force" ]; then
|
|
echo "Timed cleanup of Docker data is disabled"
|
|
echo "To force a cleanup, re-run this script with '--force'"
|
|
exit 0
|
|
fi
|
|
|
|
# Clear dangling images from Docker
|
|
docker image prune -f
|
|
|
|
# Clear old images from Zun cache directory
|
|
find /var/cache/zun -amin +1440 -type f -exec rm -fv {} \;
|