Apex: Enable overcloud log collection 99/54999/3
authorTim Rozet <trozet@redhat.com>
Thu, 5 Apr 2018 14:45:25 +0000 (10:45 -0400)
committerTim Rozet <trozet@redhat.com>
Thu, 5 Apr 2018 14:54:37 +0000 (10:54 -0400)
With this commit:
https://gerrit.opnfv.org/gerrit/#/c/47875/

We can now gather logs from after at the end of a deploy/test job and
upload them to artifacts.  This patch enables that behavior on verify
and daily jobs.

Change-Id: If7af4cf1363e4bbcee78d98850af7c0e20250f3f
Signed-off-by: Tim Rozet <trozet@redhat.com>
jjb/apex/apex-fetch-logs.sh [new file with mode: 0755]
jjb/apex/apex-verify-jobs.yml
jjb/apex/apex.yml
jjb/apex/apex.yml.j2

diff --git a/jjb/apex/apex-fetch-logs.sh b/jjb/apex/apex-fetch-logs.sh
new file mode 100755 (executable)
index 0000000..f25f456
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+set -o errexit
+set -o nounset
+set -o pipefail
+
+# log info to console
+echo "Fetching logs from overcloud. This could take some time..."
+echo "--------------------------------------------------------"
+echo
+
+if sudo opnfv-pyutil --fetch-logs; then
+  LOG_LOCATION=$(cat apex_util.log | grep 'Log retrieval complete' | grep -Eo '/tmp/.+$')
+  if [ -z "$LOG_LOCATION" ]; then
+      echo "WARNING: Unable to determine log location.  Logs will not be uploaded"
+      exit 0
+  else
+    UPLOAD_LOCATION="${GS_URL}/logs/${JOB_NAME}/${BUILD_NUMBER}/"
+    gsutil cp -r ${LOG_LOCATION} gs://${UPLOAD_LOCATION} > gsutil.latest_logs.log
+    echo "Logs available at https://${UPLOAD_LOCATION}/$(basename $LOG_LOCATION)"
+  fi
+else
+  echo "WARNING: Log retrieval failed.  No logs will be uploaded"
+  exit 0
+fi
index 3a693c8..689f68f 100644 (file)
               kill-phase-on: NEVER
               abort-all-job: true
               git-revision: false
+      - multijob:
+          name: apex-fetch-logs
+          condition: ALWAYS
+          projects:
+            - name: 'apex-fetch-logs-{stream}'
+              current-parameters: true
+              predefined-parameters: |
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+              node-parameters: true
+              kill-phase-on: NEVER
+              abort-all-job: true
+              git-revision: false
 
 ########################
 # builder macros
index a4c6860..ed7ba75 100644 (file)
       - 'pike'
       - 'queens'
       - 'master'
+
+
+# Fetch Logs Job
+- job-template:
+    name: 'apex-fetch-logs-{stream}'
+
+    concurrent: true
+
+    disabled: false
+    scm:
+      - git-scm-gerrit
+    parameters:
+      - '{project}-{platform}-{stream}-defaults'
+      - project-parameter:
+          project: '{project}'
+          branch: '{branch}'
+      - apex-parameter:
+          gs-pathname: '{gs-pathname}'
+    # yamllint enable rule:line-length
+    properties:
+      - logrotate-default
+      - throttle:
+          max-per-node: 1
+          max-total: 10
+          option: 'project'
+
+    builders:
+      - 'apex-fetch-logs'
+
 - job-template:
     name: 'apex-runner-cperf-{stream}'
 
               kill-phase-on: NEVER
               abort-all-job: true
               git-revision: false
+      - multijob:
+          name: apex-fetch-logs
+          condition: ALWAYS
+          projects:
+            - name: 'apex-fetch-logs-{stream}'
+              current-parameters: false
+              predefined-parameters: |
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+                GERRIT_CHANGE_COMMIT_MESSAGE=$GERRIT_CHANGE_COMMIT_MESSAGE
+              node-parameters: true
+              kill-phase-on: NEVER
+              abort-all-job: true
+              git-revision: false
 
 # Baremetal Deploy and Test
 - job-template:
               kill-phase-on: NEVER
               abort-all-job: true
               git-revision: false
-
+      - multijob:
+          name: apex-fetch-logs
+          condition: ALWAYS
+          projects:
+            - name: 'apex-fetch-logs'
+              current-parameters: true
+              predefined-parameters: |
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=
+              node-parameters: true
+              kill-phase-on: NEVER
+              abort-all-job: true
+              git-revision: false
     publishers:
       - groovy-postbuild:
           script:
       - shell:
           !include-raw: ./apex-deploy.sh
 
+- builder:
+    name: 'apex-fetch-logs'
+    builders:
+      - shell:
+          !include-raw: ./apex-fetch-logs.sh
+
 #######################
 # trigger macros
 ########################
index 25b9cd9..b0fc0d4 100644 (file)
       - 'pike'
       - 'queens'
       - 'master'
+
+
+# Fetch Logs Job
+- job-template:
+    name: 'apex-fetch-logs-{stream}'
+
+    concurrent: true
+
+    disabled: false
+    scm:
+      - git-scm-gerrit
+    parameters:
+      - '{project}-{platform}-{stream}-defaults'
+      - project-parameter:
+          project: '{project}'
+          branch: '{branch}'
+      - apex-parameter:
+          gs-pathname: '{gs-pathname}'
+    # yamllint enable rule:line-length
+    properties:
+      - logrotate-default
+      - throttle:
+          max-per-node: 1
+          max-total: 10
+          option: 'project'
+
+    builders:
+      - 'apex-fetch-logs'
+
 - job-template:
     name: 'apex-runner-cperf-{stream}'
 
               kill-phase-on: NEVER
               abort-all-job: true
               git-revision: false
+      - multijob:
+          name: apex-fetch-logs
+          condition: ALWAYS
+          projects:
+            - name: 'apex-fetch-logs-{stream}'
+              current-parameters: false
+              predefined-parameters: |
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+                GERRIT_CHANGE_COMMIT_MESSAGE=$GERRIT_CHANGE_COMMIT_MESSAGE
+              node-parameters: true
+              kill-phase-on: NEVER
+              abort-all-job: true
+              git-revision: false
 
 # Baremetal Deploy and Test
 - job-template:
               kill-phase-on: NEVER
               abort-all-job: true
               git-revision: false
-
+      - multijob:
+          name: apex-fetch-logs
+          condition: ALWAYS
+          projects:
+            - name: 'apex-fetch-logs'
+              current-parameters: true
+              predefined-parameters: |
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=
+              node-parameters: true
+              kill-phase-on: NEVER
+              abort-all-job: true
+              git-revision: false
     publishers:
       - groovy-postbuild:
           script:
       - shell:
           !include-raw: ./apex-deploy.sh
 
+- builder:
+    name: 'apex-fetch-logs'
+    builders:
+      - shell:
+          !include-raw: ./apex-fetch-logs.sh
+
 #######################
 # trigger macros
 ########################