Rework slave-cleanup

The current approach does not work at all: Every job runs "git clean" as
part of set up of workspace. So, the marker we use is deleted and all
the content as well.

So, what we can do is run the "git clean" also after a run, so that the
workspace is minimal between invocations and the initial "git clean"
becomes a nop. This helps with overall space on the proposal slave
since only the active job will use .tox directories etc. Since there's
no regular cleanup of workspace, this also helps when jobs get retired,
the workspace will continue to exist - but with the cleanup done, it's
much smaller.

Change-Id: I8b17724905634aa2f7cc657de073ee7cfe10f781
This commit is contained in:
Andreas Jaeger 2016-04-13 06:35:13 +02:00
parent e43a820750
commit 16b7c693de
1 changed files with 8 additions and 22 deletions

View File

@ -1,25 +1,11 @@
#!/bin/bash -xe
# Delete some files on slave at most once a day.
# Stores a marker file with date of last deletion.
# Cleanup workspace afterwards so that no extra files are in it.
# This is also done at beginning of each job but let's do it
# afterwards to save space on the workspace between invocations.
MARKER=.marker_CREATED
if [[ -f $MARKER ]] ; then
TODAY=$(date '+%Y%m%d')
# Delete only once a day
if [[ $(date -f $MARKER '+%Y%m%d') != $TODAY ]] ; then
# Let's see how much we delete.
# Let du report sizes each directory.
du -h --max-depth=1 .
git clean -f -x -d
du -h --max-depth=1 .
fi
fi
# Create marker file if it does not exist.
if [[ ! -f $MARKER ]] ; then
date '+%Y%m%d' > $MARKER
fi
# Let's see how much we delete.
# Let du report sizes each directory.
du -h --max-depth=1 .
git clean -f -x -d
du -h --max-depth=1 .