-
Notifications
You must be signed in to change notification settings - Fork 113
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
Validate nil pointer exceptions during BuildRun Reconcile #396
Conversation
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.
e3260a2
to
f082e14
Compare
/assign @qu1queee |
|
||
// taskrun ramp-up duration (time between taskrun creation and taskrun pod creation) | ||
buildmetrics.TaskRunRampUpDurationObserve( | ||
if buildRun.Status.BuildSpec.StrategyRef != nil { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"` |
*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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[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 |
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.