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

Fix panic when pending pipelinerun is failed #4306

Merged
merged 1 commit into from
Oct 13, 2021

Conversation

pritidesai
Copy link
Member

Changes

Cheery picking PR: #4298 (All the credit goes to @sbwsg, thank you Scott 🙏 )

PipelineRuns that are created with status PipelineRunPending
can be placed into a failed state before their execution begins.
For example: a third-party controller may be watching for pending
PipelineRuns to perform some checks on them prior to execution
beginning. If those checks fail the controller might choose to
set the PipelineRun status to failed with a relevant error message
indicating which check failed and why.

Prior to this commit when a pending PR failed our metrics code
could panic because the PR's StartTime is nil.

This commit adds a guard to the metrics code to ensure that StartTime
is not nil before computing the PR's duration. If it is nil then
we assume the duration is 0. A unit test confirming this behaviour
has been added as well.

(cherry picked from commit 0299c6c)

Co-authored-by: sbwsg [email protected]

/kind bug

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in or deleted (only if no user facing changes)

Release Notes

Fixed an issue where the PipelineRun reconciler could panic if a PipelineRun with spec.status set to PipelineRunPending was placed into a failed state before execution was able to begin.

PipelineRuns that are created with status PipelineRunPending
can be placed into a failed state before their execution begins.
For example: a third-party controller may be watching for pending
PipelineRuns to perform some checks on them prior to execution
beginning. If those checks fail the controller might choose to
set the PipelineRun status to failed with a relevant error message
indicating which check failed and why.

Prior to this commit when a pending PR failed our metrics code
could panic because the PR's StartTime is nil.

This commit adds a guard to the metrics code to ensure that StartTime
is not nil before computing the PR's duration. If it is nil then
we assume the duration is 0. A unit test confirming this behaviour
has been added as well.

(cherry picked from commit 0299c6c)
@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Oct 13, 2021
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 13, 2021
@ghost
Copy link

ghost commented Oct 13, 2021

Cheers!

/lgtm

@tekton-robot tekton-robot assigned ghost Oct 13, 2021
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 13, 2021
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 13, 2021
@vdemeester vdemeester added needs-cherry-pick Indicates a PR needs to be cherry-pick to a release branch and removed needs-cherry-pick Indicates a PR needs to be cherry-pick to a release branch labels Oct 13, 2021
@tekton-robot tekton-robot merged commit b5cb387 into tektoncd:release-v0.28.x Oct 13, 2021
@pritidesai pritidesai deleted the release-v0.28.2 branch October 13, 2021 17:38
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. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants