-
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
Do not expose ingress path metric when service is nil #1841
Do not expose ingress path metric when service is nil #1841
Conversation
|
Welcome @evir35! |
/easycla |
10647b6
to
d7a079e
Compare
LabelValues: []string{rule.Host, path.Path, path.Backend.Service.Name, strconv.Itoa(int(path.Backend.Service.Port.Number))}, | ||
Value: 1, | ||
}) | ||
if path.Backend.Service != 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.
Thanks for this PR. I wonder if we can just set service_name
and service_port
to blank values instead of not adding exporting a metric at all.
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.
Thanks for your comment! 🙇♂️
I updated it to return blank values("<none>") refer to other code.
Please tell me if I don't understand correctly.
And I added test code to the ingress_test.go
file.
7e663e9
to
242cea3
Compare
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.
Just one small suggestion
internal/store/ingress.go
Outdated
} else { | ||
ms = append(ms, &metric.Metric{ | ||
LabelKeys: []string{"host", "path", "service_name", "service_port"}, | ||
LabelValues: []string{rule.Host, path.Path, "<none>", "<none>"}, |
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.
Thanks, this should be sufficient:
LabelValues: []string{rule.Host, path.Path, "<none>", "<none>"}, | |
LabelValues: []string{rule.Host, path.Path, "", ""}, |
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.
Oh, I updated.
Thank you!
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.
Thanks 👍
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: evir35, fpetkovski 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 |
…ress-path-metric-when-service-is-nil Do not expose ingress path metric when service is nil
…ress-path-metric-when-service-is-nil Do not expose ingress path metric when service is nil
What this PR does / why we need it:
Currently, the kube-state-metrics can down suddenly when an ingress without backend service is created.
https://github.com/kubernetes/api/blob/79091dac6a32a1365edbc6de9576ffa74768a75c/networking/v1/types.go#L484-L496
The
Service
ofIngressBackend
is a nullable variable. But, the current code doesn't check theService
is nil or not.So, I created PR to solve this using an additional if statement that checks
Service
is nil or not.And I checked both
path.Backend.Service.Name
andpath.Backend.Service.Port.Number
variables can't be nil.How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
This PR doesn't affect the cardinality of KSM.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #1660