[Qa-jenkins-scm] [jenkins.debian.net] 02/03: reproducible debian: maintenance: rewrite the schroot session cleanup thing
Mattia Rizzolo
mattia at debian.org
Thu Apr 5 09:40:56 UTC 2018
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch master
in repository jenkins.debian.net.
commit cfc1c8b2bc42aec619244d2c4b4d9bcf88a56b3d
Author: Mattia Rizzolo <mattia at debian.org>
Date: Thu Apr 5 11:36:10 2018 +0200
reproducible debian: maintenance: rewrite the schroot session cleanup thing
With schroot session is normal to have schroot sessions lying around
with no `schroot --directory` process, so let's just remove those
sessions that are clearly stale (i.e. too old).
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
---
bin/reproducible_maintenance.sh | 52 ++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/bin/reproducible_maintenance.sh b/bin/reproducible_maintenance.sh
index 94f5e2f..5708f8f 100755
--- a/bin/reproducible_maintenance.sh
+++ b/bin/reproducible_maintenance.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+# vim: set noexpandtab:
# Copyright 2014-2017 Holger Levsen <holger at layer-acht.org>
# © 2015-2018 Mattia Rizzolo <mattia at debian.org>
@@ -185,33 +186,30 @@ if [ "$HOSTNAME" = "$MAINNODE" ] ; then
fi
fi
-# remove old and unused schroot sessions
-echo "$(date -u) - Removing unused schroot sessions."
-cleanup_schroot_sessions() {
- echo
- local RESULT=""
- for loop in $(seq 0 40) ; do
- # first, check if no process using "schroot" is running, if thats the case, loop through all schroot sessions:
- # arch sessions are ignored, because they are handled properly
- pgrep -f "schroot --directory" || for i in $(schroot --all-sessions -l |grep -v "session:archlinux"||true) ; do
- # then, check that schroot is still not run, and then delete the session
- if [ -z $i ] ; then
- continue
- fi
- pgrep -f "schroot --directory" || schroot -e -c $i
- done
- RESULT=$(schroot --all-sessions -l|grep -v "session:archlinux"||true)
- if [ -z "$RESULT" ] ; then
- echo "No schroot sessions in use atm..."
- echo
- break
- fi
- echo "$(date -u) - schroot session cleanup loop $loop"
- sleep 15
- done
- echo
-}
-cleanup_schroot_sessions
+# remove too old schroot sessions
+echo "$(date -u) - Removing schroot sessions older than 2 days."
+dir=/var/lib/schroot/unpack/
+OLDSTUFF=$(find "$dir" -maxdepth 1 -type d -mtime +2 -exec ls -lad {} \;)
+if [ ! -z "$OLDSTUFF" ]; then
+ echo
+ echo "schroot sessions older than 2 days found, which will be deleted:"
+ echo "$OLDSTUFF"
+ echo
+ set -x
+ for s in $(find "$dir" -mindepth 1 -maxdepth 1 -type d -mtime +2 -print0 | xargs -0 -r basename -a); do
+ echo "$(date -u) - removing schroot session $s..."
+ schroot -c "$s" --end-session
+ done
+ OLDSTUFF=$(find "$dir" -maxdepth 1 -type d -mtime +2 -exec ls -lad {} \;)
+ if [ ! -z "$OLDSTUFF" ]; then
+ echo
+ echo "Warning: Tried, but failed to remove these:"
+ echo "$OLDSTUFF"
+ echo "Manual cleanup needed"
+ fi
+ echo
+ DIRTY=true
+fi
# find old schroots
echo "$(date -u) - Removing schroots older than 3 days."
--
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