Skip to content

Commit

Permalink
report task error message if no errors were found in steps
Browse files Browse the repository at this point in the history
* CLOUDBLD-12659

Signed-off-by: Robert Cerven <[email protected]>
  • Loading branch information
rcerven committed Apr 12, 2023
1 parent 8d7d7fa commit ad6da58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions osbs/tekton.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ def get_error_message(self):

for _, stats in sorted_tasks:
task_name = stats['pipelineTaskName']
got_task_error = False
if stats['status']['conditions'][0]['reason'] == 'Succeeded':
continue

Expand All @@ -570,13 +571,15 @@ def get_error_message(self):
if message['key'] == 'task_result':
err_message += f"Error in {task_name}: " \
f"{message['value']};\n"
got_task_error = True
continue
except Exception as e:
logger.info("failed to get error message: %s", repr(e))
continue

err_message += f"Error in {task_name}: " \
f"{stats['status']['conditions'][0]['message']};\n"
if not got_task_error:
err_message += f"Error in {task_name}: " \
f"{stats['status']['conditions'][0]['message']};\n"

if not err_message:
if pipeline_error:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tekton.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def test_get_info(self, pipeline_run, get_json):
}
}},
'metadata': {}},
"pipeline err message1;"),
"Error in binary-build-task1: message2;\n"),
# taskRuns in status, with steps and failed without terminated key
({'status': {'conditions': [{'reason': 'reason1'}],
Expand Down

0 comments on commit ad6da58

Please sign in to comment.