[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] 2 commits: refactoring

Holger Levsen gitlab at salsa.debian.org
Fri Nov 20 14:23:52 GMT 2020



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


Commits:
a9b0c6e7 by Holger Levsen at 2020-11-20T15:20:40+01:00
refactoring

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

- - - - -
79ce39e6 by Holger Levsen at 2020-11-20T15:23:39+01:00
reproducible Debian: delete old bullseye and unstable schroot sooner than others

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

- - - - -


1 changed file:

- bin/reproducible_maintenance.sh


Changes:

=====================================
bin/reproducible_maintenance.sh
=====================================
@@ -448,31 +448,37 @@ if [ "$HOSTNAME" = "$MAINNODE" ] ; then
 	done
 fi
 
-# find old schroots
-echo "$(date -u) - Removing schroots older than 31 days."
-regex="/schroots/(reproducible-.+-[0-9]{1,5}|schroot-install-.+)"
-OLDSTUFF=$(find /schroots/ -maxdepth 1 -type d -regextype posix-extended -regex "$regex" -mtime +31 -exec ls -lad {} \; || true)
-if [ ! -z "$OLDSTUFF" ] ; then
-	# try to unmount mounts first
-	for MP in $(find /schroots/ -maxdepth 1 -type d -regextype posix-extended -regex "$regex" -mtime +31 ) ; do
-		if [ -d $MP/proc ] ; then
-			sudo umount -l $MP/proc 2>/dev/null || echo "umount -l $MP/proc failed, continueing."
-		fi
-	done
-	echo
-	echo "schroots older than 31 days found in /schroots, which will be deleted:"
-	find /schroots/ -maxdepth 1 -type d -regextype posix-extended -regex "$regex" -mtime +31 -exec sudo rm -rf --one-file-system {} \; || true
-	echo "$OLDSTUFF"
-	OLDSTUFF=$(find /schroots/ -maxdepth 1 -type d -regextype posix-extended -regex "$regex" -mtime +31 -exec ls -lad {} \; || true)
+# cleanup old schroots
+cleanup_old_schroots() {
+	local OBJECTS="$1"
+	local AGE="$2"
+	local regex="$3"
+	echo "$(date -u) - Removing $OBJECTS older than $AGE days."
+	OLDSTUFF=$(find /schroots/ -maxdepth 1 -type d -regextype posix-extended -regex "$regex" -mtime +$AGE -exec ls -lad {} \; || true)
 	if [ ! -z "$OLDSTUFF" ] ; then
+		# try to unmount mounts first
+		for MP in $(find /schroots/ -maxdepth 1 -type d -regextype posix-extended -regex "$regex" -mtime +$AGE ) ; do
+			if [ -d $MP/proc ] ; then
+				sudo umount -l $MP/proc 2>/dev/null || echo "umount -l $MP/proc failed, continueing."
+			fi
+		done
 		echo
-		echo "Warning: Tried, but failed to delete these schroots:"
+		echo "$OBJECTS older than 31 $AGE found in /schroots, which will be deleted:"
+		find /schroots/ -maxdepth 1 -type d -regextype posix-extended -regex "$regex" -mtime +$AGE -exec sudo rm -rf --one-file-system {} \; || true
 		echo "$OLDSTUFF"
-		echo "Manual cleanup needed!"
+		OLDSTUFF=$(find /schroots/ -maxdepth 1 -type d -regextype posix-extended -regex "$regex" -mtime +$AGE -exec ls -lad {} \; || true)
+		if [ ! -z "$OLDSTUFF" ] ; then
+			echo
+			echo "Warning: Tried, but failed to delete these $OBJECTS:"
+			echo "$OLDSTUFF"
+			echo "Manual cleanup needed!"
+		fi
+		echo
+		DIRTY=true
 	fi
-	echo
-	DIRTY=true
-fi
+}
+cleanup_old_schroots "schroots" 31 "/schroots/(reproducible-.+-[0-9]{1,5}|schroot-install-.+)"
+cleanup_old_schroots "unstable and bullseye schroots" 15 "/schroots/reproducible-(unstable|bullseye)-diffoscope-.+-[0-9]{1,5}"
 
 # find very old schroots
 echo "$(date -u) - Detecting schroots older than 1 month"



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/db782ca229a85d096b03fe4ebc6b88d477405613...79ce39e6f1162b3f4854b9e0955987145ef0015d

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/db782ca229a85d096b03fe4ebc6b88d477405613...79ce39e6f1162b3f4854b9e0955987145ef0015d
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/20201120/12982780/attachment-0001.html>


More information about the Qa-jenkins-scm mailing list