Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker builder prune #642

Merged
merged 2 commits into from
Nov 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion packer/linux/conf/docker/cron.hourly/docker-low-disk-gc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mark_instance_unhealthy() {
killall -QUIT buildkite-agent || true

# mark the instance for termination
echo "Marking instance as unhealthy"
aws autoscaling set-instance-health \
--instance-id "$(curl http://169.254.169.254/latest/meta-data/instance-id)" \
--health-status Unhealthy
Expand All @@ -20,11 +21,13 @@ mark_instance_unhealthy() {
trap mark_instance_unhealthy ERR

## -----------------------------------------------------------------
## Check disk, we only want to prune images/containers if we have to
## Check disk, we only want to prune images/containers/build caches
## if we really need to

if ! /usr/local/bin/bk-check-disk-space.sh ; then
echo "Cleaning up docker resources older than ${DOCKER_PRUNE_UNTIL}"
docker image prune --all --force --filter "until=${DOCKER_PRUNE_UNTIL}"
docker builder prune --all --force --filter "until=${DOCKER_PRUNE_UNTIL}"

if ! /usr/local/bin/bk-check-disk-space.sh ; then
echo "Disk health checks failed" >&2
Expand Down