[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] reproducible maintenance: use and allow sudo to cleanup diffoscope schroot sessions

Holger Levsen gitlab at salsa.debian.org
Sat Sep 5 08:18:03 BST 2020



Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net


Commits:
d0a30cf1 by Holger Levsen at 2020-09-05T09:17:52+02:00
reproducible maintenance: use and allow sudo to cleanup diffoscope schroot sessions

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


2 changed files:

- bin/reproducible_maintenance.sh
- hosts/jenkins/etc/sudoers.d/jenkins


Changes:

=====================================
bin/reproducible_maintenance.sh
=====================================
@@ -416,31 +416,33 @@ if [ ! -z "$OLDSTUFF" ]; then
 fi
 
 # remove too old schroot session data from diffoscope
-echo "$(date -u) - Removing diffoscope schroot session data older than 3 days."
-for path in session union/underlay union/overlay ; do
-	dir=/var/lib/schroot/$path/
-	OLDSTUFF=$(find "$dir" -name "jenkins-reproducible-*-diffoscope-*" -mindepth 1 -maxdepth 1 -type d -mtime +2 -exec ls -lad {} \;)
-	if [ ! -z "$OLDSTUFF" ]; then
-		echo
-		echo "data in $dir older than 3 days found, which will be deleted:"
-		echo "$OLDSTUFF"
-		echo
-		if [ "$path" = "session" ] ; then
-			find "$dir" -name "jenkins-reproducible-*-diffoscope-*" -mindepth 1 -maxdepth 1 -type d -mtime +2 -exec rm -v {} \;
-		else
-			find "$dir" -name "jenkins-reproducible-*-diffoscope-*" -mindepth 1 -maxdepth 1 -type d -mtime +2 -exec rmdir -v {} \;
-		fi
+if [ "$HOSTNAME" = "$MAINNODE" ] ; then
+	echo "$(date -u) - Removing diffoscope schroot session data older than 3 days."
+	for path in session union/underlay union/overlay ; do
+		dir=/var/lib/schroot/$path/
 		OLDSTUFF=$(find "$dir" -name "jenkins-reproducible-*-diffoscope-*" -mindepth 1 -maxdepth 1 -type d -mtime +2 -exec ls -lad {} \;)
 		if [ ! -z "$OLDSTUFF" ]; then
 			echo
-			echo "Warning: Tried, but failed to delete these in $dir:"
+			echo "data in $dir older than 3 days found, which will be deleted:"
 			echo "$OLDSTUFF"
-			echo "Manual cleanup needed"
+			echo
+			if [ "$path" = "session" ] ; then
+				find "$dir" -name "jenkins-reproducible-*-diffoscope-*" -mindepth 1 -maxdepth 1 -type d -mtime +2 -exec sudo rm -v {} \;
+			else
+				find "$dir" -name "jenkins-reproducible-*-diffoscope-*" -mindepth 1 -maxdepth 1 -type d -mtime +2 -exec sudo rmdir -v {} \;
+			fi
+			OLDSTUFF=$(find "$dir" -name "jenkins-reproducible-*-diffoscope-*" -mindepth 1 -maxdepth 1 -type d -mtime +2 -exec ls -lad {} \;)
+			if [ ! -z "$OLDSTUFF" ]; then
+				echo
+				echo "Warning: Tried, but failed to delete these in $dir:"
+				echo "$OLDSTUFF"
+				echo "Manual cleanup needed"
+			fi
+			echo
+			DIRTY=true
 		fi
-		echo
-		DIRTY=true
-	fi
-done
+	done
+fi
 
 # find old schroots
 echo "$(date -u) - Removing schroots older than 3 days."


=====================================
hosts/jenkins/etc/sudoers.d/jenkins
=====================================
@@ -22,6 +22,8 @@ jenkins ALL=  \
 	/bin/rm -rf --one-file-system /srv/workspace/pbuilder/*, \
 	/bin/rm -rf --one-file-system /tmp/*, \
 	/bin/rm -rv --one-file-system /tmp/*, \
+	/bin/rm -v /var/lib/schroot/*, \
+	/bin/rmdir -v /var/lib/schroot/*, \
 	/bin/mv /chroots/* /schroots/*, \
 	/bin/mv /schroots/* /schroots/*, \
 	/bin/umount -l /chroots/*, \



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/d0a30cf17cacea364269aaf6feb50cca51af3feb

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/d0a30cf17cacea364269aaf6feb50cca51af3feb
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20200905/80a08430/attachment-0001.html>


More information about the Qa-jenkins-scm mailing list