summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorPhilip Hands <phil@hands.com>2016-06-02 17:23:50 +0200
committerPhilip Hands <phil@hands.com>2016-06-03 00:02:26 +0200
commit5e6bee5e9acfea7242298f4cb5e7e6a5a49a423c (patch)
treed6295a705495b57b213a4ffa761ec1bcbe6b35cc /bin
parent3d2cbb8c58953a39237f9af2c854e75edd61c32d (diff)
downloadjenkins.debian.net-5e6bee5e9acfea7242298f4cb5e7e6a5a49a423c.tar.xz
lvc: discard only outdated snapshots
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lvc.sh18
1 files changed, 10 insertions, 8 deletions
diff --git a/bin/lvc.sh b/bin/lvc.sh
index 902ace00..6f801e65 100755
--- a/bin/lvc.sh
+++ b/bin/lvc.sh
@@ -39,10 +39,15 @@ fetch_if_newer() {
fi
}
-discard_snapshots() {
- domain=$1
- for snap in $(sudo /usr/bin/virsh snapshot-list $domain --name) ; do
+discard_stale_snapshots() {
+ domain=$1
+ netboot=$2
+
+ sudo /usr/bin/virsh -q snapshot-list $domain | \
+ while read snap date time tz state ; do
+ if [ "$(find /srv/jenkins/cucumber /srv/jenkins/bin/lvc.sh $netboot -newermt "$date $time $tz" -print -quit)" ] ; then
sudo /usr/bin/virsh snapshot-delete $domain $snap
+ fi
done
}
@@ -59,10 +64,7 @@ mkdir -p $RESULTS
mkdir -p $WORKSPACE/DebianToasterStorage
-# FIXME this should discover the 'target' bit of the path, probably via: virsh vol-list
-if [ ! -e "$WORKSPACE/DebianToasterStorage/target" ] ; then
- discard_snapshots DebianToaster
-fi
+discard_stale_snapshots DebianToaster $NETBOOT
trap cleanup_all INT TERM EXIT
@@ -117,7 +119,7 @@ fi
echo "Debug log available at runtime at https://jenkins.debian.net/view/lvc/job/$JOB_NAME/ws/results/debug.log"
-/srv/jenkins/cucumber/bin/run_test_suite --capture-all --vnc-server-only --iso $IMAGE --tmpdir $PWD --old-iso $IMAGE -- --format pretty /srv/jenkins/cucumber/features/step_definitions /srv/jenkins/cucumber/features/support "${@}"
+/srv/jenkins/cucumber/bin/run_test_suite --capture-all --keep-snapshots --vnc-server-only --iso $IMAGE --tmpdir $PWD --old-iso $IMAGE -- --format pretty /srv/jenkins/cucumber/features/step_definitions /srv/jenkins/cucumber/features/support "${@}"
cleanup_all