[Qa-jenkins-scm] [jenkins.debian.net] 01/01: lvc: discard snapshots if target volume is missing
Holger Levsen
holger at layer-acht.org
Sat May 14 21:05:06 UTC 2016
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch master
in repository jenkins.debian.net.
commit 183047ae67b06004bdef17561678e5021c9b5a19
Author: Philip Hands <phil at hands.com>
Date: Sat May 14 22:03:14 2016 +0200
lvc: discard snapshots if target volume is missing
---
bin/lvc.sh | 12 ++++++++++++
hosts/jenkins-test-vm/etc/sudoers.d/jenkins | 1 +
hosts/jenkins/etc/sudoers.d/jenkins | 1 +
3 files changed, 14 insertions(+)
diff --git a/bin/lvc.sh b/bin/lvc.sh
index 5b1e5b3..c58c7aa 100755
--- a/bin/lvc.sh
+++ b/bin/lvc.sh
@@ -30,6 +30,13 @@ fetch_if_newer() {
curl $curlopts -o $file $url
}
+discard_snapshots() {
+ domain=$1
+ for snap in $(sudo /usr/bin/virsh snapshot-list $domain --name) ; do
+ sudo /usr/bin/virsh snapshot-delete $domain $snap
+ done
+}
+
#
# define workspace + results
#
@@ -43,6 +50,11 @@ 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
+
trap cleanup_all INT TERM EXIT
#
diff --git a/hosts/jenkins-test-vm/etc/sudoers.d/jenkins b/hosts/jenkins-test-vm/etc/sudoers.d/jenkins
index 96d501e..1f45753 100644
--- a/hosts/jenkins-test-vm/etc/sudoers.d/jenkins
+++ b/hosts/jenkins-test-vm/etc/sudoers.d/jenkins
@@ -28,6 +28,7 @@ jenkins ALL= \
/usr/bin/qemu-system-x86_64 *, \
/usr/bin/qemu-img *, \
/sbin/lvcreate *, /sbin/lvremove *, \
+ /usr/bin/virsh snapshot-list *, /usr/bin/virsh snapshot-delete *, \
/bin/mkdir -p /media/*, \
/usr/bin/guestmount *, \
/bin/cp -rv /media/*, \
diff --git a/hosts/jenkins/etc/sudoers.d/jenkins b/hosts/jenkins/etc/sudoers.d/jenkins
index 96d501e..c1ad0ff 100644
--- a/hosts/jenkins/etc/sudoers.d/jenkins
+++ b/hosts/jenkins/etc/sudoers.d/jenkins
@@ -28,6 +28,7 @@ jenkins ALL= \
/usr/bin/qemu-system-x86_64 *, \
/usr/bin/qemu-img *, \
/sbin/lvcreate *, /sbin/lvremove *, \
+ /usr/vib/virsh *, \
/bin/mkdir -p /media/*, \
/usr/bin/guestmount *, \
/bin/cp -rv /media/*, \
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git
More information about the Qa-jenkins-scm
mailing list