Skip to content

Commit

Permalink
get_error_message should also propagate pipeline timeout error
Browse files Browse the repository at this point in the history
* CLOUDBLD-11193

Signed-off-by: Robert Cerven <[email protected]>
  • Loading branch information
rcerven committed Oct 19, 2022
1 parent be2b46e commit 76807cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 6 additions & 1 deletion osbs/tekton.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ def get_error_message(self):
for plugin, error in plugin_errors.items():
err_message += f"Error in plugin {plugin}: {error};\n"

pipeline_error = data['status']['conditions'][0].get('message')

for _, stats in sorted_tasks:
task_name = stats['pipelineTaskName']
if stats['status']['conditions'][0]['reason'] == 'Succeeded':
Expand All @@ -573,7 +575,10 @@ def get_error_message(self):
continue

if not err_message:
err_message = "pipeline run failed;"
if pipeline_error:
err_message = f"{pipeline_error};"
else:
err_message = "pipeline run failed;"

return err_message

Expand Down
3 changes: 2 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,8 @@ def test_get_build_error_message(self, osbs_binary):
'value': metadata}]},
'pipelineTaskName': 'binary-container-exit'}}

resp = {'metadata': {'name': 'run_name'}, 'status': {'taskRuns': taskruns}}
resp = {'metadata': {'name': 'run_name'},
'status': {'taskRuns': taskruns, 'conditions': [{'message': 'error'}]}}

flexmock(PipelineRun).should_receive('get_info').and_return(resp)

Expand Down
10 changes: 5 additions & 5 deletions tests/test_tekton.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,12 @@ def test_get_info(self, pipeline_run, get_json):
({}, 'pipeline run removed;'),
# no taskRuns in status and no plugins-metadata
({'status': {'conditions': [{'reason': 'reason1', 'message': 'message1'}]},
({'status': {'conditions': [{'reason': 'reason1', 'message': 'pipeline err message1'}]},
'metadata': {}},
"pipeline run failed;"),
"pipeline err message1;"),
# taskRuns in status, without steps
({'status': {'conditions': [{'reason': 'reason1', 'message': 'message1'}],
({'status': {'conditions': [{'reason': 'reason1', 'message': 'pipeline err message1'}],
'taskRuns': {
'task1': {
'pipelineTaskName': 'binary-build-task1',
Expand All @@ -618,10 +618,10 @@ def test_get_info(self, pipeline_run, get_json):
}
}},
'metadata': {}},
"pipeline run failed;"),
"pipeline err message1;"),
# taskRuns in status, with steps and failed without terminated key
({'status': {'conditions': [{'reason': 'reason1', 'message': 'message1'}],
({'status': {'conditions': [{'reason': 'reason1'}],
'taskRuns': {
'task1': {
'pipelineTaskName': 'binary-build-task1',
Expand Down

0 comments on commit 76807cf

Please sign in to comment.