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

fix: Check if resp is nil in capi metrics and continue #3299

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/apiserver/apic_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@
if err != nil {
log.Errorf("unable to send usage metrics: %s", err)

if resp.Response.StatusCode >= http.StatusBadRequest && resp.Response.StatusCode != http.StatusUnprocessableEntity {
if resp == nil || resp.Response.StatusCode >= http.StatusBadRequest && resp.Response.StatusCode != http.StatusUnprocessableEntity {

Check warning on line 371 in pkg/apiserver/apic_metrics.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/apic_metrics.go#L371

Added line #L371 was not covered by tests
// In case of 422, mark the metrics as sent anyway, the API did not like what we sent,
// and it's unlikely we'll be able to fix it
// also if resp is nil, we should'nt mark the metrics as sent could be network issue

Check warning on line 374 in pkg/apiserver/apic_metrics.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/apic_metrics.go#L374

Added line #L374 was not covered by tests
continue
}
}
Expand Down
Loading