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

Validate nil pointer exceptions during BuildRun Reconcile #396

Conversation

qu1queee
Copy link
Contributor

When generating the rampup metrics, we needed to validate for nil
pointers in order to avoid some panic() scenarios. Adding a test
case for this validation.

When metrics are not used, some variables are not initialized, leading
to panic() scenarios when using them later in the reconciliation of the
BuildRun controller. Adding some if conditionals to validate nils.

When generating the rampup metrics, we needed to validate for nil
pointers in order to avoid some panic() scenarios. Adding a test
case for this validation.

When metrics are not used, some variables are not initialized, leading
to panic() scenarios when using them later in the reconciliation of the
BuildRun controller. Adding some if conditionals to validate nils.
@qu1queee
Copy link
Contributor Author

/assign @qu1queee


// taskrun ramp-up duration (time between taskrun creation and taskrun pod creation)
buildmetrics.TaskRunRampUpDurationObserve(
if buildRun.Status.BuildSpec.StrategyRef != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Hm, I think you are uncovering a bug in the BuildSpec. The StrategyRef is not optional and therefore should not be a reference - similar to Source and Output that are also mandatory. Can you change this in build_types.go and remove this nil check here again ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed, thats a good point. Unit tests know nothing about the tags. Also, when you say "Can you change this in build_types.go" , what do you meant?

Copy link
Member

Choose a reason for hiding this comment

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

I mean this loc:

StrategyRef *StrategyRef `json:"strategy"`
. It should not be *StrategyRef but StrategyRef. But, I just looked around, there are more similar problems like the BuildRef in the build run. So, you can also leave it as is and I open an issue to separately address all this problems. If you quickly confirm, I will approve this PR and address the wrong references separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, pls open the issue first. I would like to have the discussion around the pointer or not, interesting.

Copy link
Member

Choose a reason for hiding this comment

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

Issue opened: #397

Let's provide feed back there. This PR is fine then.

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 Sep 17, 2020
@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 Sep 17, 2020
@openshift-merge-robot openshift-merge-robot merged commit ef6a14b into shipwright-io:master Sep 17, 2020
@qu1queee qu1queee deleted the qu1queee/test_cases_metrics branch September 17, 2020 15:20
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants