[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] schroot-create: properly fail when apt fails

Mattia Rizzolo gitlab at salsa.debian.org
Wed Jun 26 19:01:19 BST 2019



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


Commits:
2da5844d by Mattia Rizzolo at 2019-06-26T18:00:07Z
schroot-create: properly fail when apt fails

no need to mess with set -e/set +e, because the return code of apt-get
is shadowed by `tee` (unless -o pipefail is used, which is not the case
here).

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

- - - - -


1 changed file:

- bin/schroot-create.sh


Changes:

=====================================
bin/schroot-create.sh
=====================================
@@ -75,11 +75,9 @@ fi
 
 
 robust_chroot_apt() {
-	set +e
 	sudo chroot $SCHROOT_TARGET apt-get $@ | tee $TMPLOG
 	local RESULT=$(egrep 'Failed to fetch.*(Unable to connect to|Connection failed|Size mismatch|Cannot initiate the connection to|Bad Gateway|Service Unavailable)' $TMPLOG || true)
-	set -e
-	if [ ! -z "$RESULT" ] ; then
+	if [ ! -z "$RESULT" ] || [ "${PIPESTATUS[0]}" -ne 0 ] ; then
 		echo "$(date -u) - 'apt-get $@' failed, sleeping 5min before retrying..."
 		sleep 5m
 		sudo chroot $SCHROOT_TARGET apt-get $@ || ( echo "$(date -u ) - 2nd 'apt-get $@' failed, giving up..." ; exit 1 )
@@ -92,11 +90,9 @@ bootstrap() {
 	echo force-unsafe-io > "$SCHROOT_TARGET/etc/dpkg/dpkg.cfg.d/02dpkg-unsafe-io"
 
 	echo "Bootstraping $SUITE into $SCHROOT_TARGET now."
-	set +e
 	sudo debootstrap $SUITE $SCHROOT_TARGET $MIRROR | tee $TMPLOG
 	local RESULT=$(egrep "E: (Couldn't download packages|Invalid Release signature)" $TMPLOG || true)
-	set -e
-	if [ ! -z "$RESULT" ] ; then
+	if [ ! -z "$RESULT" ] || [ "${PIPESTATUS[0]}" -ne 0 ] ; then
 		echo "$(date -u) - initial debootstrap failed, sleeping 5min before retrying..."
 		sudo rm -rf --one-file-system $SCHROOT_TARGET
 		sleep 5m



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/commit/2da5844d157f8cabcd0137835a5a878dce029ee6

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/commit/2da5844d157f8cabcd0137835a5a878dce029ee6
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/20190626/22270082/attachment-0001.html>


More information about the Qa-jenkins-scm mailing list