From ae07aecd22b548aa2b9290ab656e002a9bbbf2db Mon Sep 17 00:00:00 2001 From: David Galloway Date: Thu, 3 Sep 2020 12:58:01 -0400 Subject: [PATCH] ceph-api-nightly: Clean up after yourself This job has a bunch of templates. Each one reaches 30-50GB in size which quickly fills up our builder home dirs. Signed-off-by: David Galloway --- ceph-api-nightly/build/cleanup | 15 +++++++++++++++ .../config/definitions/ceph-api-nightly.yml | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 ceph-api-nightly/build/cleanup diff --git a/ceph-api-nightly/build/cleanup b/ceph-api-nightly/build/cleanup new file mode 100644 index 00000000..b02d27af --- /dev/null +++ b/ceph-api-nightly/build/cleanup @@ -0,0 +1,15 @@ +#!/bin/bash +use_percentage=$(df -m ~ | grep -v Filesystem | awk '{ print $5 }' | cut -d '%' -f1) +if [ $use_percentage -gt 90 ]; then + rm -rf ~/.ccache + for dir in $(ls ~/build/workspace/); do + # Used "${var}" instead of ${var+x} here because I also want to check if the string is empty + if [ -z "${dir}" ] || [ -z "${JOB_NAME}" ]; then + echo "Either \$dir or \$JOB_NAME aren't set. Not cleaning up job directories." + else + if [ "$dir" != "$JOB_NAME" ]; then + rm -rf ~/build/workspace/$dir + fi + fi + done +fi diff --git a/ceph-api-nightly/config/definitions/ceph-api-nightly.yml b/ceph-api-nightly/config/definitions/ceph-api-nightly.yml index 94e909cc..e7df93fe 100644 --- a/ceph-api-nightly/config/definitions/ceph-api-nightly.yml +++ b/ceph-api-nightly/config/definitions/ceph-api-nightly.yml @@ -56,6 +56,9 @@ wipe-workspace: true builders: + - shell: + !include-raw-escape: + - ../../build/cleanup - shell: "export NPROC=$(nproc); {ceph_build}" - shell: !include-raw: -- 2.39.5