Skip to content

Commit

Permalink
tekton: allow skipped tasks
Browse files Browse the repository at this point in the history
Intentionally skipped tasks shouldn't be considered as unsuccesfull in
OSBS context. Allow skipped tasks in OSBS.

Signed-off-by: Martin Basti <[email protected]>
  • Loading branch information
MartinBasti committed Nov 20, 2024
1 parent c58a280 commit 5413870
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions osbs/tekton.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ def get_error_message(self):

task_name = task_info['metadata']['labels']['tekton.dev/pipelineTask']
got_task_error = False
if task_info['status']['conditions'][0]['reason'] == 'Succeeded':
if task_info['status']['conditions'][0]['reason'] in ['Succeeded', 'None']:
# tekton: "None" reason means skipped task; yes string
continue

if 'steps' in task_info['status']:
Expand Down Expand Up @@ -581,7 +582,8 @@ def get_final_platforms(self):
def has_succeeded(self):
status_reason = self.status_reason
logger.info("Pipeline run info: '%s'", self.data)
return status_reason == 'Succeeded'
# tekton: completed means succeeded with a skipped task
return status_reason in ['Succeeded', 'Completed']

def has_not_finished(self):
data = self.data
Expand Down
10 changes: 10 additions & 0 deletions tests/test_tekton.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ def test_get_final_platforms(self, pipeline_run, prun_json, taskrun_json, platfo
@pytest.mark.parametrize(('get_json', 'reason', 'succeeded'), [
(deepcopy(PIPELINE_RUN_JSON), 'Running', False),
(deepcopy(PIPELINE_RUN_JSON), 'Succeeded', True),
(deepcopy(PIPELINE_RUN_JSON), 'Completed', True),
({}, None, False),
])
def test_status(self, pipeline_run, get_json, reason, succeeded):
Expand All @@ -873,6 +874,15 @@ def test_status(self, pipeline_run, get_json, reason, succeeded):
("binary-container-prebuild", ("Unknown", "Running", None)),
],
),
# a task runs are skipped or still running
(
False,
False,
[
("clone", ("True", "None", "2022-05-27T08:07:27Z")),
("binary-container-prebuild", ("Unknown", "Running", None)),
],
),
# a task run failed
(
True,
Expand Down

0 comments on commit 5413870

Please sign in to comment.