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 nil-pointer dereference of BuildSpec Strategy #710

Merged
merged 1 commit into from
Apr 2, 2021
Merged

Fix nil-pointer dereference of BuildSpec Strategy #710

merged 1 commit into from
Apr 2, 2021

Conversation

HeavyWombat
Copy link
Contributor

Changes

There were cases in which the Build had a nil Strategy, which is copied into
the BuildRun Status.BuildSpec and later used internally, for example the
metrics code is using the Strategy field. In case it is nil, the function
call for the metrics failed with a nil-pointer dereference.

Introduce BuildSpec convenience function called StrategyName to return the
name of the strategy, which includes a nil safety check.

Replace all occurrences of BuildSpec.Strategy.Name with the newly introduced
function to avoid panics.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

Fix nil-pointer dereference with panic in case Build spec Strategy field was not set.

There were cases in which the Build had a `nil` Strategy, which is copied into
the BuildRun `Status.BuildSpec` and later used internally, for example the
metrics code is using the `Strategy` field. In case it is `nil`, the function
call for the metrics failed with a nil-pointer dereference.

Introduce `BuildSpec` convenience function called `StrategyName` to return the
name of the strategy, which includes a `nil` safety check.

Replace all occurrences of `BuildSpec.Strategy.Name` with the newly introduced
function to avoid panics.
@openshift-ci-robot openshift-ci-robot added the release-note Label for when a PR has specified a release note label Apr 1, 2021
@HeavyWombat HeavyWombat added the kind/bug Categorizes issue or PR as related to a bug. label Apr 1, 2021
@HeavyWombat
Copy link
Contributor Author

/retest

@SaschaSchwarze0
Copy link
Member

Let me try to reopen to re-trigger the test.

Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2021
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SaschaSchwarze0

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2021
@openshift-merge-robot openshift-merge-robot merged commit 75cdae1 into shipwright-io:master Apr 2, 2021
@HeavyWombat HeavyWombat deleted the fix/nil-pointer-buildrun-reconciler branch April 3, 2021 13:25
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 Label for when a PR has specified a release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants