[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] 3 commits: reproducible: maintenance: fix output

Mattia Rizzolo (@mattia) gitlab at salsa.debian.org
Tue Oct 5 19:00:56 BST 2021



Mattia Rizzolo pushed to branch master at Debian QA / jenkins.debian.net


Commits:
b30138a6 by Mattia Rizzolo at 2021-10-05T19:59:23+02:00
reproducible: maintenance: fix output

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -
c375e4ff by Mattia Rizzolo at 2021-10-05T19:59:44+02:00
reproducible: maintenance: run the real command now that I saw it's
correct

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -
3537b671 by Mattia Rizzolo at 2021-10-05T20:00:13+02:00
reproducible: maintenance: consider for deletion only underlays that are over 1 month old

Signed-off-by: Mattia Rizzolo <mattia at debian.org>

- - - - -


1 changed file:

- bin/reproducible_maintenance.sh


Changes:

=====================================
bin/reproducible_maintenance.sh
=====================================
@@ -377,7 +377,7 @@ if [ "$HOSTNAME" = "$MAINNODE" ] ; then
 	if [ "${#OLDSTUFF[@]}" -ne 0 ]; then
 		echo
 		echo "Found old schroot (from diffoscope) sessions, which will be terminated now:"
-		echo "${OLDSTUFF[@]}"
+		printf '%s\n' "${OLDSTUFF[@]}"
 		echo
 		for session_path in "${OLDSTUFF[@]}"; do
 			# don't use `basename` because session_path contains the whole output from ls -l, not just the path
@@ -389,14 +389,16 @@ if [ "$HOSTNAME" = "$MAINNODE" ] ; then
 		done
 	fi
 	for path in underlay overlay ; do
-		# give these directories an extra day over the above sessions, in case they have a slightly older mtime.
-		mapfile -t OLDSTUFF < <(find "/var/lib/schroot/union/$path" -name "jenkins-reproducible-*-diffoscope-*" -maxdepth 1 -type d -mtime +2 -exec ls -lad {} \;)
+		# these directories can easily have the mtime of when the base schroot
+		# was created, so be so be very conservative about removing them, else
+		# one risks to delete stuff that is currently in use.
+		mapfile -t OLDSTUFF < <(find "/var/lib/schroot/union/$path" -name "jenkins-reproducible-*-diffoscope-*" -maxdepth 1 -type d -mtime +31 -exec ls -lad {} \;)
 		if [ ${#OLDSTUFF[@]} -ne 0 ]; then
 			echo
 			echo "Found old schroot (from diffoscope) $path, which will be investigated now:"
-			echo "${OLDSTUFF[@]}"
+			printf '%s\n' "${OLDSTUFF[@]}"
 			echo
-			pushd /var/lib/schroot/session
+			pushd /var/lib/schroot/session >/dev/null
 			for dir_ls in "${OLDSTUFF[@]}"; do
 				# don't use `basename`,etc because dir_ls contains the whole output from ls -l, not just the path
 				dir_path="/${dir_ls#*/}"
@@ -404,17 +406,20 @@ if [ "$HOSTNAME" = "$MAINNODE" ] ; then
 				if [ ${#matches[@]} -eq 0 ]; then
 					echo
 					echo "This $path is not referenced by any existing schroot, deleting it now."
-					set -x
-					echo sudo rm -rf --one-file-system "$dir_path"
-					if ! "$DEBUG" ; then set +x ; fi
+					if [ -d "$dir_path" ]; then
+						set -x
+						sudo rm -rf --one-file-system "$dir_path"
+						if ! "$DEBUG" ; then set +x ; fi
+					fi
 				fi
 			done
+			popd >/dev/null
 		fi
-		mapfile -t OLDSTUFF < <(find "/var/lib/schroot/union/$path" -name "jenkins-reproducible-*-diffoscope-*" -maxdepth 1 -type d -mtime +2 -exec ls -lad {} \;)
+		mapfile -t OLDSTUFF < <(find "/var/lib/schroot/union/$path" -name "jenkins-reproducible-*-diffoscope-*" -maxdepth 1 -type d -mtime +31 -exec ls -lad {} \;)
 		if [ ${#OLDSTUFF[@]} -ne 0 ]; then
 			echo
 			echo "Warning: Tried, but failed to delete these in /var/lib/schroot/union/$dir:"
-			echo "${OLDSTUFF[@]}"
+			printf '%s\n' "${OLDSTUFF[@]}"
 			echo "Manual cleanup needed."
 			echo
 			DIRTY=true



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/f831f1a1faccc2443791e9e3a685c68f2bb6347e...3537b671cec64eeb505f03d45a4bfeb2d040f868

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/f831f1a1faccc2443791e9e3a685c68f2bb6347e...3537b671cec64eeb505f03d45a4bfeb2d040f868
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/20211005/a590a73b/attachment-0001.htm>


More information about the Qa-jenkins-scm mailing list