-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix panic in hubble http v2 metrics #24350
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
Conversation
Since #23385 isn't in a release yet, what release note label is appropriate? misc? |
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!
The new ListMetricVec didn't differentiate between v1 and v2 and incorrectly used a nil metric: h.responses which isn't registered in http v2 metrics. Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
http metrics has v1 and v2 plugins handled by the same httpHandler and registers different metrics depending on v1 vs v2. This resulted in a bug in ListMetricVec which didn't handle the v2 case. Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
fc3e560
to
92bb9f1
Compare
This includes a new unit test, and the remaining tests won't test this functionality (they don't enable hubble metrics, nor do they enable http v2 metrics, otherwise it would have been caught) so I think we can skip the remaining required tests. @gandro What do you think? Also, we really should add some kind of integration/e2e tests for Hubble metrics. |
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 @chancez!
@@ -82,7 +86,7 @@ func (h *httpHandler) Context() *api.ContextOptions { | |||
} | |||
|
|||
func (h *httpHandler) ListMetricVec() []*prometheus.MetricVec { | |||
return []*prometheus.MetricVec{h.requests.MetricVec, h.responses.MetricVec, h.duration.MetricVec} |
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.
this change is ok since the only caller of this function doesn't mutate the returned value.
I personally am fine with merging this just based on unit tests. But we have been discussing being more strict about running CI even if we think it's not really needed. Better safe than sorry. |
/test |
k8s-1.26-kernel-net-next failed on the VM setup:
|
/test-1.26-net-next |
@michi-covalent @chancez this PR was marked for backporting to 1.13 but I don't see the relevant commits that add ListMetricVec() there and quickly looking over that code don't see anything that does it currently in 1.13. |
@kaworu found a bug when testing another PR based on master when using httpV2 metrics:
This was introduced in #23385 which seems to have handled all the other metrics correctly, but http is a bit special and it didn't handle the v2 metrics option.
I wrote a new test (second commit) which reproduces the panic:
And the first commit fixes this by properly handling the difference between http v2 metrics and v1.