Skip to content

Commit

Permalink
Merge pull request #642 from buildkite/docker-builder-prune
Browse files Browse the repository at this point in the history
Docker builder prune
  • Loading branch information
lox committed Nov 1, 2019
2 parents dec685e + fa71f0d commit 04a16e7
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 04a16e7

Please sign in to comment.