From 0206d6671a2a4c7b05f3072968df369c9a1d1fe4 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 8 Dec 2021 09:01:49 -0800 Subject: [PATCH] Try to fix broken stestr command discovery When processing subunit streams we attempt to discover where the (s)testr commands are located. For some reason the output of our scripts that do this very occasionally emit a newline before the command path. When this happens we were using the blank line as the command path which fails as that empty command results in our command arguments being interpreted as the command path. Attempt to address this by trimming the stdout instead of taking the first line. This should remove the leading and trailing newlines and give us only the command itself. Change-Id: Id651e019cf3d0b7ab37fdf9df04be249ea7f7af6 --- roles/fetch-subunit-output/tasks/find-subunit-html.yaml | 7 +++++-- roles/fetch-subunit-output/tasks/main.yaml | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/roles/fetch-subunit-output/tasks/find-subunit-html.yaml b/roles/fetch-subunit-output/tasks/find-subunit-html.yaml index e2de203b3..f6922d3b7 100644 --- a/roles/fetch-subunit-output/tasks/find-subunit-html.yaml +++ b/roles/fetch-subunit-output/tasks/find-subunit-html.yaml @@ -6,9 +6,12 @@ - name: Define subunit_html_command fact when: - find_subunit2html_output.rc == 0 - - find_subunit2html_output.stdout_lines + - find_subunit2html_output.stdout set_fact: - subunit_html_command: "{{ find_subunit2html_output.stdout_lines[0] }}" + # We use the trim filter here on all stdout because for some reason + # we occasionally get the command listed with a blank line prefix. + # This should clean that up. + subunit_html_command: "{{ find_subunit2html_output.stdout | trim }}" - name: Emit a debug line so we can search logstash for fallback hits debug: diff --git a/roles/fetch-subunit-output/tasks/main.yaml b/roles/fetch-subunit-output/tasks/main.yaml index df8a4255b..840581601 100644 --- a/roles/fetch-subunit-output/tasks/main.yaml +++ b/roles/fetch-subunit-output/tasks/main.yaml @@ -49,9 +49,9 @@ - when: - testr_command.rc == 0 - - testr_command.stdout_lines + - testr_command.stdout # Here we run steps that only apply when there is a valid subunity stream. - # This is indicated through testr_command.stdout_lines content. + # This is indicated through testr_command.stdout content. block: # The usage an independent target file instead of sending the output # to zuul_work_dir prevents issues related to zuul_work_dir being @@ -65,7 +65,10 @@ - name: Generate subunit file shell: - cmd: "{{ testr_command.stdout_lines[0] }} last --subunit >>{{ temp_subunit_file.path }}" + # We use the trim filter here on all stdout because for some reason + # we occasionally get the command listed with a blank line prefix. + # This should clean that up. + cmd: "{{ testr_command.stdout | trim }} last --subunit >>{{ temp_subunit_file.path }}" chdir: "{{ zj_item }}" loop: "{{ all_subunit_dirs }}" loop_control: