[Qa-jenkins-scm] [jenkins.debian.net] 01/01: refactor: move cleanup_schroot_sessions() to common_functions.sh
Holger Levsen
holger at moszumanska.debian.org
Tue Oct 6 17:10:40 UTC 2015
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 8db1d9365cca524838495a4736513637cd870c99
Author: Holger Levsen <holger at layer-acht.org>
Date: Tue Oct 6 19:10:00 2015 +0200
refactor: move cleanup_schroot_sessions() to common_functions.sh
---
bin/common-functions.sh | 21 +++++++++++++++++++++
bin/reproducible_maintenance.sh | 7 +------
bin/schroot-create.sh | 18 ------------------
3 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/bin/common-functions.sh b/bin/common-functions.sh
index 043ef5e..8118812 100755
--- a/bin/common-functions.sh
+++ b/bin/common-functions.sh
@@ -127,3 +127,24 @@ publish_changes_to_userContent(){
fi
}
+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:
+ pgrep -f "schroot --directory" || for i in $(schroot --all-sessions -l ) ; do
+ # then, check that schroot is still not run, and then delete the session
+ pgrep -f "schroot --directory" || schroot -e -c $i
+ done
+ RESULT=$(schroot --all-sessions -l)
+ 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
+}
+
diff --git a/bin/reproducible_maintenance.sh b/bin/reproducible_maintenance.sh
index 156e6b7..0b2d9aa 100755
--- a/bin/reproducible_maintenance.sh
+++ b/bin/reproducible_maintenance.sh
@@ -114,12 +114,7 @@ fi
# remove old and unused schroot sessions
echo "$(date -u) - Removing unused schroot sessions."
-pgrep -f "schroot --directory" || for i in $(schroot --all-sessions -l ) ; do pgrep -f "schroot --directory" || schroot -e -c $i ; done
-# to explain this:
-# first, check if no process using "schroot" is running...
-# then loop through all schroot sessions
-# for each session
-# check that schroot is still not run, and then, delete the session
+cleanup_schroot_sessions
# find old schroots
echo "$(date -u) - Removing old schroots."
diff --git a/bin/schroot-create.sh b/bin/schroot-create.sh
index 9999ca6..befd694 100755
--- a/bin/schroot-create.sh
+++ b/bin/schroot-create.sh
@@ -182,24 +182,6 @@ bootstrap() {
fi
}
-cleanup_schroot_sessions() {
- echo
- # FIXME: if this works well, move to _common.sh and use the same function from _maintenance.sh
- local RESULT=""
- for loop in $(seq 0 40) ; do
- pgrep -f "schroot --directory" || for i in $(schroot --all-sessions -l ) ; do pgrep -f "schroot --directory" || schroot -e -c $i ; done
- RESULT=$(schroot --all-sessions -l)
- 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() {
if [ -d $SCHROOT_TARGET ]; then
sudo rm -rf --one-file-system $SCHROOT_TARGET || ( echo "Warning: $SCHROOT_TARGET could not be fully removed on forced cleanup." ; ls $SCHROOT_TARGET -la )
--
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