From 1b88dcf23ea750880dd2ed70d07f66546a8dd41c Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 21 Feb 2018 10:12:11 +0000 Subject: [PATCH] jjb: xci: Add postbuild publisher script to remove clean VM The clean VM normally stays around after the job is completed or killed due to timeout. Unless a job for the same distro is scheduled on the same node, that VM will state around for a while consuming valuable system resources. As such, we should remove it after the job finishes to free up resources for the new jobs. Change-Id: I88b5e32797969d9378588199a7ddb013bbe740c9 Signed-off-by: Markos Chandras --- jjb/xci/bifrost-verify-jobs.yml | 7 +++++++ jjb/xci/xci-cleanup.sh | 8 ++++++-- jjb/xci/xci-daily-jobs.yml | 6 ++++++ jjb/xci/xci-merge-jobs.yml | 8 ++++++++ jjb/xci/xci-verify-jobs.yml | 9 +++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/jjb/xci/bifrost-verify-jobs.yml b/jjb/xci/bifrost-verify-jobs.yml index 7e0117565..2fb7c2167 100644 --- a/jjb/xci/bifrost-verify-jobs.yml +++ b/jjb/xci/bifrost-verify-jobs.yml @@ -162,6 +162,13 @@ recipients: fatih.degirmenci@ericsson.com yroblamo@redhat.com mchandras@suse.de jack.morgan@intel.com julienjut@gmail.com # yamllint enable rule:line-length - email-jenkins-admins-on-failure + - postbuildscript: + script-only-if-succeeded: false + script-only-if-failed: false + builders: + - shell: + !include-raw: ./xci-cleanup.sh + # ------------------------------- # trigger macros # ------------------------------- diff --git a/jjb/xci/xci-cleanup.sh b/jjb/xci/xci-cleanup.sh index ce84830aa..51a863da2 100755 --- a/jjb/xci/xci-cleanup.sh +++ b/jjb/xci/xci-cleanup.sh @@ -14,11 +14,15 @@ # what you are doing. #---------------------------------------------------------------------- +# Need to cover macros with and without parameters +VM_NAME=$DISTRO +VM_NAME+=_xci_vm + # skip the deployment if the patch doesn't impact the deployment if [[ "$GERRIT_TOPIC" =~ 'skip-verify' ]]; then echo "Skipping the deployment!" exit 0 fi -sudo virsh destroy ${DISTRO}_xci_vm || true -sudo virsh undefine ${DISTRO}_xci_vm || true +sudo virsh destroy $VM_NAME || true +sudo virsh undefine $VM_NAME || true diff --git a/jjb/xci/xci-daily-jobs.yml b/jjb/xci/xci-daily-jobs.yml index a92e49085..11db4e168 100644 --- a/jjb/xci/xci-daily-jobs.yml +++ b/jjb/xci/xci-daily-jobs.yml @@ -154,6 +154,12 @@ recipients: fatih.degirmenci@ericsson.com yroblamo@redhat.com mchandras@suse.de jack.morgan@intel.com julienjut@gmail.com # yamllint enable rule:line-length - email-jenkins-admins-on-failure + - postbuildscript: + script-only-if-succeeded: false + script-only-if-failed: false + builders: + - shell: + !include-raw: ./xci-cleanup.sh - job-template: name: 'xci-{phase}-{pod}-{distro}-daily-{stream}' diff --git a/jjb/xci/xci-merge-jobs.yml b/jjb/xci/xci-merge-jobs.yml index 492348d63..7a5ef7475 100644 --- a/jjb/xci/xci-merge-jobs.yml +++ b/jjb/xci/xci-merge-jobs.yml @@ -167,6 +167,14 @@ kill-phase-on: NEVER abort-all-job: true + publishers: + - postbuildscript: + script-only-if-succeeded: false + script-only-if-failed: false + builders: + - shell: + !include-raw: ./xci-cleanup.sh + - job-template: name: 'xci-{phase}-{type}-{distro}-merge-{stream}' diff --git a/jjb/xci/xci-verify-jobs.yml b/jjb/xci/xci-verify-jobs.yml index c54a1b941..82ca5abbc 100644 --- a/jjb/xci/xci-verify-jobs.yml +++ b/jjb/xci/xci-verify-jobs.yml @@ -188,6 +188,15 @@ kill-phase-on: NEVER abort-all-job: true + publishers: + - postbuildscript: + script-only-if-succeeded: false + script-only-if-failed: false + builders: + - shell: + !include-raw: ./xci-cleanup.sh + + - job-template: name: 'xci-verify-{distro}-{phase}-{type}-{stream}' -- 2.16.6