From e599e95f25ddb9518ba1960001eeb5698f0d87d6 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 11 May 2021 15:05:05 +0200 Subject: [PATCH] ci: in case of a failure, return error after logging system status It seems that it is required to re-throw the error after a catch{..} block. Without this, and a successful execution of system-status.sh, the CI jobs get marked as SUCCESS, even when there was a failure. Fixes: e36155283 "ci: run system-status.sh in case a job fails" Signed-off-by: Niels de Vos --- k8s-e2e-external-storage.groovy | 7 +++++++ mini-e2e-helm.groovy | 7 +++++++ mini-e2e.groovy | 7 +++++++ upgrade-tests.groovy | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/k8s-e2e-external-storage.groovy b/k8s-e2e-external-storage.groovy index 865da47be..1ec57c2cb 100644 --- a/k8s-e2e-external-storage.groovy +++ b/k8s-e2e-external-storage.groovy @@ -10,6 +10,7 @@ def doc_change = 0 def k8s_release = 'latest' def namespace = 'k8s-e2e-storage-' + UUID.randomUUID().toString().split('-')[-1] def ci_registry = 'registry-ceph-csi.apps.ocp.ci.centos.org' +def failure = null def ssh(cmd) { sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} '${cmd}'" @@ -182,6 +183,8 @@ node('cico-workspace') { } catch (err) { + failure = err + stage('log system status') { ssh './system-status.sh' } @@ -191,5 +194,9 @@ node('cico-workspace') { stage('return bare-metal machine') { sh 'cico node done ${CICO_SSID}' } + + if (failure) { + throw failure + } } } diff --git a/mini-e2e-helm.groovy b/mini-e2e-helm.groovy index a1e98c569..67c23b205 100644 --- a/mini-e2e-helm.groovy +++ b/mini-e2e-helm.groovy @@ -10,6 +10,7 @@ def doc_change = 0 def k8s_release = 'latest' def ci_registry = 'registry-ceph-csi.apps.ocp.ci.centos.org' def namespace = 'cephcsi-e2e-' + UUID.randomUUID().toString().split('-')[-1] +def failure = null // ssh executes a given command on the reserved bare-metal machine // NOTE: do not pass " symbols on the command line, use ' only. @@ -189,6 +190,8 @@ node('cico-workspace') { } catch (err) { + failure = err + stage('log system status') { ssh './system-status.sh' } @@ -198,5 +201,9 @@ node('cico-workspace') { stage('return bare-metal machine') { sh 'cico node done ${CICO_SSID}' } + + if (failure) { + throw failure + } } } diff --git a/mini-e2e.groovy b/mini-e2e.groovy index aeba2b361..8143fa578 100644 --- a/mini-e2e.groovy +++ b/mini-e2e.groovy @@ -9,6 +9,7 @@ def skip_e2e = 0 def doc_change = 0 def k8s_release = 'latest' def ci_registry = 'registry-ceph-csi.apps.ocp.ci.centos.org' +def failure = null def ssh(cmd) { sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} '${cmd}'" @@ -172,6 +173,8 @@ node('cico-workspace') { } catch (err) { + failure = err + stage('log system status') { ssh './system-status.sh' } @@ -181,5 +184,9 @@ node('cico-workspace') { stage('return bare-metal machine') { sh 'cico node done ${CICO_SSID}' } + + if (failure) { + throw failure + } } } diff --git a/upgrade-tests.groovy b/upgrade-tests.groovy index 2acd77984..322f9eb3d 100644 --- a/upgrade-tests.groovy +++ b/upgrade-tests.groovy @@ -9,6 +9,7 @@ def skip_e2e = 0 def doc_change = 0 def k8s_release = 'latest' def ci_registry = 'registry-ceph-csi.apps.ocp.ci.centos.org' +def failure = null def ssh(cmd) { sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} '${cmd}'" @@ -176,6 +177,8 @@ node('cico-workspace') { } catch (err) { + failure = err + stage('log system status') { ssh './system-status.sh' } @@ -185,5 +188,9 @@ node('cico-workspace') { stage('return bare-metal machine') { sh 'cico node done ${CICO_SSID}' } + + if (failure) { + throw failure + } } }