From a0a4e65eac8cea26727779ff172c63b149468dd8 Mon Sep 17 00:00:00 2001 From: Attila Darazs Date: Wed, 11 Jan 2017 17:48:57 +0100 Subject: [PATCH] collect-logs: rename text files to txt.gz Add the artcl_txt_rename option. When enabled, the publishing step renames known text file extension to end in txt.gz which is directly displayed by upstream log servers. Also simplify the way we handle the stackviz and tempest results. Change-Id: I793088995ca5a945738c5b04c1cefdd974e5f2d1 --- roles/collect-logs/README.md | 3 +++ roles/collect-logs/defaults/main.yml | 2 ++ roles/collect-logs/tasks/collect.yml | 34 ---------------------------- roles/collect-logs/tasks/publish.yml | 19 ++++++++++++++++ 4 files changed, 24 insertions(+), 34 deletions(-) diff --git a/roles/collect-logs/README.md b/roles/collect-logs/README.md index 3538e271d..ef0ff3b0e 100644 --- a/roles/collect-logs/README.md +++ b/roles/collect-logs/README.md @@ -77,6 +77,9 @@ artcl_create_docs_payload: to the target specified by `artcl_rsync_url`. Uses `BUILD_URL`, `BUILD_TAG` vars from the environment (set during a Jenkins job run) and requires the next to variables to be set. +* `artcl_txt_rename`: false/true -- rename text based file to end in .txt.gz to + make upstream log servers display them in the browser instead of offering + them to download * `artcl_publish_timeout`: the maximum seconds the role can spend uploading the logs, the default is 1800 (30 minutes) * `artcl_use_rsync`: false/true -- use rsync to upload the logs diff --git a/roles/collect-logs/defaults/main.yml b/roles/collect-logs/defaults/main.yml index da31f1fd0..7a3f0c999 100644 --- a/roles/collect-logs/defaults/main.yml +++ b/roles/collect-logs/defaults/main.yml @@ -37,8 +37,10 @@ artcl_gzip_only: true ## publishing related vars artcl_publish: false +artcl_txt_rename: false # give up log upload after 30 minutes artcl_publish_timeout: 1800 +artcl_artifact_url: "file://{{ lookup('env', 'PWD') }}" artcl_full_artifact_url: "{{ artcl_artifact_url }}/{{ lookup('env', 'BUILD_TAG') }}/" artcl_use_rsync: false artcl_rsync_use_daemon: false diff --git a/roles/collect-logs/tasks/collect.yml b/roles/collect-logs/tasks/collect.yml index 1a5f3a76c..725101875 100644 --- a/roles/collect-logs/tasks/collect.yml +++ b/roles/collect-logs/tasks/collect.yml @@ -210,37 +210,3 @@ file: path: "{{ artcl_collect_dir }}/{{ inventory_hostname }}.tar" state: absent - - - name: Check for stackviz report data - stat: path="{{ artcl_collect_dir }}/undercloud/var/log/extra/stackviz/data" - register: stackviz - - - name: Copy stackviz to root level - command: cp -r "{{ artcl_collect_dir }}/undercloud/var/log/extra/stackviz/" {{ artcl_collect_dir }}/stackviz - when: stackviz.stat.exists - - - name: Unzip stackviz files - command: gzip -d -r "{{ artcl_collect_dir }}/stackviz" - when: stackviz.stat.exists - - # Collect the tempest artifacts for reporting - - name: check for tempest html results - stat: path="{{ artcl_collect_dir }}/undercloud/home/stack/tempest/tempest.html.gz" - register: st_tempest_html - - - name: unzip the tempest html file - command: gzip -d "{{ artcl_collect_dir }}/undercloud/home/stack/tempest/tempest.html.gz" - when: st_tempest_html.stat.exists - - - name: check for tempest xml results - stat: path="{{ artcl_collect_dir }}/undercloud/home/stack/tempest/tempest.xml.gz" - register: st_tempest_xml - - - name: unzip the tempest xml file - command: gzip -d "{{ artcl_collect_dir }}/undercloud/home/stack/tempest/tempest.xml.gz" - when: st_tempest_xml.stat.exists - - - name: Copy the tempest html to the base dir of the logs - command: cp -r "{{ artcl_collect_dir }}/undercloud/home/stack/tempest/tempest.html" {{ artcl_collect_dir }}/tempest.html - when: st_tempest_html.stat.exists - diff --git a/roles/collect-logs/tasks/publish.yml b/roles/collect-logs/tasks/publish.yml index 2a72a037b..917fd8770 100644 --- a/roles/collect-logs/tasks/publish.yml +++ b/roles/collect-logs/tasks/publish.yml @@ -13,6 +13,25 @@ command: cp -a {{ local_working_dir }}/ara {{ artcl_collect_dir }}/ara ignore_errors: "yes" +- name: fetch stackviz results to the root of the collect_dir + shell: > + if [ -d {{ artcl_collect_dir }}/undercloud/var/log/extra/stackviz/data ]; then + cp -r {{ artcl_collect_dir }}/undercloud/var/log/extra/stackviz {{ artcl_collect_dir }}; + gunzip -r {{ artcl_collect_dir }}/stackviz; + fi; + +- name: fetch tempest results to the root of the collect_dir + shell: > + cp {{ artcl_collect_dir }}/undercloud/home/stack/tempest/tempest.{xml,html}{,.gz} {{ artcl_collect_dir }} || true; + gunzip {{ artcl_collect_dir }}/tempest.{xml,html}.gz || true; + +- name: Rename text based files to end with txt.gz extension + shell: > + find {{ artcl_collect_dir }} -type f | + awk '/\.(conf|ini|json|sh|log|yaml|yml)\.gz$/ { + renamed=$0; sub(/\.gz$/, ".txt.gz", renamed); system("mv " $0 " " renamed) }'; + when: artcl_txt_rename|bool + - name: upload to the artifact server using pubkey auth shell: rsync -av --quiet -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" {{ artcl_collect_dir }}/ {{ artcl_rsync_path }}/{{ lookup('env', 'BUILD_TAG') }} async: "{{ artcl_publish_timeout }}"