Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check parent task's status when calculating pipelinerun status #1178

Merged
merged 2 commits into from
Aug 9, 2019

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Aug 8, 2019

Changes

Before conditionals, a pipelinerun was marked successful only
if all tasks were successfully run. Now, a pipelinerun is successful
if all tasks were either successfully run or skipped due to a condition
check failure.

Currently while updating status, we only see if a task's own condition
check failed. This is not sufficient if that task (B) is dependent on another
task (A) using from or runAfter. If A is skipped due to a condition failure,
task B is not scheduled to be execute, and there are no other tasks left to run.
However, the pipeline status is never updated from Running to Successful.

To fix this, this commit changes the GetPipelineConditionStatus function to
recursively look at a task's parent tasks to see if they are skipped. If any single
parent task is skipped, we skip the task. If all tasks in a pipeline are either
successful or skipped, we update the pipeline run status to successful.

Fixes #1173

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2019
@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Aug 8, 2019
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 8, 2019
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipelinerun_types.go 92.9% 59.1% -33.8
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go Do not exist 82.4%
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 90.5% 75.9% -14.6

@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipelinerun_types.go 92.9% 59.1% -33.8
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go Do not exist 82.4%
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 90.5% 92.9% 2.4

This logic is currently embedded inside the large
`GetPipelineConditionStatus` function. Extracting it
will help simplify it.

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
@dibyom dibyom changed the title WIP: Check parent task's status when calculating pipelinerun status Check parent task's status when calculating pipelinerun status Aug 9, 2019
@dibyom dibyom marked this pull request as ready for review August 9, 2019 04:40
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 9, 2019
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipelinerun_types.go 92.9% 95.5% 2.6
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go Do not exist 82.4%
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 90.5% 94.5% 4.0

@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipelinerun_types.go 92.9% 95.5% 2.6
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go Do not exist 82.4%
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 90.5% 94.5% 4.0

@vdemeester vdemeester added this to the Pipelines 0.6 🐱 milestone Aug 9, 2019
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipelinerun_types.go 92.9% 95.5% 2.6
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go Do not exist 82.4%
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 90.5% 94.5% 4.0

@dibyom
Copy link
Member Author

dibyom commented Aug 9, 2019

/test pull-tekton-pipeline-integration-tests

@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipelinerun_types.go 92.9% 95.5% 2.6
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go Do not exist 82.4%
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 90.5% 94.5% 4.0

Before conditionals, a pipelinerun was marked successful only
if all tasks were successfully run. Now, a pipelinerun is successful
if all tasks were either successfully run or skipped due to a condition
check failure.

Currently while updating status, we only see if a task's own condition
check failed. This is not sufficient if that task (B) is dependent on another
task (A) using `from` or `runAfter`. If A is skipped due to a condition failure,
task B is not scheduled to be execute, and there are no other tasks left to run.
However, the pipeline status is never updated from `Running` to `Successful`.

To fix this, this commit changes the `GetPipelineConditionStatus` function to
recursively look at a task's parent tasks to see if they are skipped. If any single
parent task is skipped, we skip the task. If all tasks in a pipeline are either
successful or skipped, we update the pipeline run status to successful.

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipelinerun_types.go 92.9% 95.5% 2.6
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go Do not exist 82.4%
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 90.5% 94.5% 4.0

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

logger.Infof("TaskRun %s has failed, so PipelineRun %s has failed, retries done: %b", rprt.TaskRunName, prName, len(rprt.TaskRun.Status.RetriesStatus))
// A single failed task mean we fail the pipeline
for _, rprt := range state {
if rprt.IsFailure() { //IsDone ensures we have crossed the retry limit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit unclear what the IsDone comment is referring to here. Did you mean IsFailure ensures we have crossed...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah old comment. Will fix

@tekton-robot tekton-robot assigned ghost Aug 9, 2019
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 9, 2019
@tekton-robot tekton-robot merged commit 4b16f17 into tektoncd:master Aug 9, 2019
@dibyom dibyom deleted the cond-bug branch August 9, 2019 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pipeline status not updated when runAfter is used with a condition`
4 participants