From c24c09e82c9bc5028b2f0fd371060b7b8d448c39 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 24 Jul 2020 11:50:38 -0700 Subject: [PATCH] Allow ara-report to run on any node This role had some assumptions that it would run only on the zuul-executor. If we remove those assumptions, it can run on any worker node, which allows it to be used in untrusted playbooks. Note that this is backwards compatible only in the case that the user did not provide a non-default value for ara_report_path. If a user overrode that (eg, to put the report in a directory other than "ara" under the executor log dir), this will break. Change-Id: I3a28368a049fa583398ece8a66f90783f53098f4 --- roles/ara-report/README.rst | 4 +--- roles/ara-report/defaults/main.yaml | 3 +-- roles/ara-report/tasks/main.yaml | 14 +++++--------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/roles/ara-report/README.rst b/roles/ara-report/README.rst index 3bfcd1389..c8504107b 100644 --- a/roles/ara-report/README.rst +++ b/roles/ara-report/README.rst @@ -51,9 +51,7 @@ If ARA is enabled, generates a report or saves a copy of the ARA database. .. _mimetypes: https://opendev.org/opendev/puppet-openstackci/src/commit/5fe1f3d2d5e40c2458721e7dcf8631d62ea2525f/templates/logs.vhost.erb#L24 .. zuul:rolevar:: ara_report_path - :default: ``ara`` - - This path is relative to the root of the log directory. + :default: ``{{ zuul.executor.log_root }}/ara`` When report_type is 'html' directory where the HTML report will be generated. When report_type is 'database', directory where the database is saved. diff --git a/roles/ara-report/defaults/main.yaml b/roles/ara-report/defaults/main.yaml index 6e83c0649..e420b378c 100644 --- a/roles/ara-report/defaults/main.yaml +++ b/roles/ara-report/defaults/main.yaml @@ -19,8 +19,7 @@ ara_report_type: 'html' # Note that when using 'database', an ARA web application can load the database # dynamically. See the ARA documentation for details: # https://ara.readthedocs.io/en/latest/advanced.html#serving-ara-sqlite-databases-over-http -# This path is relative to the root of the log directory. -ara_report_path: 'ara' +ara_report_path: '{{ zuul.executor.log_root }}/ara' # When report_type is 'html', whether to compress the ARA HTML output or not ara_compress_html: true diff --git a/roles/ara-report/tasks/main.yaml b/roles/ara-report/tasks/main.yaml index 8e5742d27..b0463f091 100644 --- a/roles/ara-report/tasks/main.yaml +++ b/roles/ara-report/tasks/main.yaml @@ -7,7 +7,7 @@ - name: Warn if ARA is not installed debug: msg: | - ARA is not installed on the executor node, no report will be available. + ARA is not installed, no report will be available. when: ara_installed.rc != 0 - name: Check that the ARA database exists @@ -36,10 +36,6 @@ It is likely that no report will be available, please verify the execution and the parameters of the role for details. -- name: Prefix the log path with the log root - set_fact: - final_ara_report_path: "{{ zuul.executor.log_root }}/{{ ara_report_path }}" - - when: - ara_installed.rc == 0 - ara_db.stat.exists @@ -48,7 +44,7 @@ # Always generate (true), never (false) or only on failure ('failure') # Additionally cover for edge cases where zuul_success might be undefined - name: Generate ARA HTML output - command: "{{ ara_report_executable }} generate html {{ final_ara_report_path }}" + command: "{{ ara_report_executable }} generate html {{ ara_report_path }}" environment: ARA_DATABASE: "sqlite:///{{ ara_database_path }}" when: ara_report_run | bool or @@ -56,7 +52,7 @@ register: ara_generated - name: Compress ARA HTML output - command: gzip --recursive --best {{ final_ara_report_path }} + command: gzip --recursive --best {{ ara_report_path }} when: - ara_compress_html | bool - not ara_generated is skipped @@ -83,11 +79,11 @@ block: - name: Create the ARA database report directory file: - path: "{{ final_ara_report_path }}" + path: "{{ ara_report_path }}" state: directory - name: Save the ARA database - command: cp {{ ara_database_path }} {{ final_ara_report_path }} + command: cp {{ ara_database_path }} {{ ara_report_path }} - name: Return ARA report zuul_return: data: