-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Don't crash on non-existent path values #1998
Conversation
Don't crash on non-existent path values in CRS. Signed-off-by: Pranshu Srivastava <[email protected]>
This issue is currently awaiting triage. If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cc @mrueg |
@@ -430,6 +430,10 @@ func (c compiledGauge) value(it interface{}) (*eachValue, error) { | |||
Value: 0, | |||
}, nil | |||
} | |||
// no it means no iterables were passed down, meaning that the path resolution never happened |
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.
should this be moved to the beginning of the function so we can return the error early?
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.
That'll fail cases that expect a zero in case of nil
.
kube-state-metrics/pkg/customresourcestate/registry_factory.go
Lines 425 to 439 in c493044
// If `valueFrom` was not resolved, respect `NilIsZero` and return. | |
if got == nil { | |
if c.NilIsZero { | |
return &eachValue{ | |
Labels: labels, | |
Value: 0, | |
}, nil | |
} | |
// no it means no iterables were passed down, meaning that the path resolution never happened | |
if it == nil { | |
return nil, fmt.Errorf("got nil while resolving path") | |
} | |
// Don't error if there was not a type-casting issue (`toFloat64`), but rather a failed lookup. | |
return nil, nil | |
} |
// no it means no iterables were passed down, meaning that the path resolution never happened | ||
if it == nil { | ||
return nil, fmt.Errorf("got nil while resolving path") | ||
} | ||
// Don't error if there was not a type-casting issue (`toFloat64`), but rather a failed lookup. |
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.
The failed lookup is handled now, can you update this comment?
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mrueg, rexagod 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 |
What this PR does / why we need it: Don't crash on non-existent path values in CRS.
How does this change affect the cardinality of KSM: No.
Which issue(s) this PR fixes: Fixes #1992