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

better handle error when sending usage metrics #3333

Merged
merged 1 commit into from
Nov 18, 2024
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
8 changes: 6 additions & 2 deletions pkg/apiserver/apic_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,14 @@
if err != nil {
log.Errorf("unable to send usage metrics: %s", err)

if resp == nil || resp.Response.StatusCode >= http.StatusBadRequest && resp.Response.StatusCode != http.StatusUnprocessableEntity {
if resp == nil || resp.Response == nil {
// Most likely a transient network error, it will be retried later
continue

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

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/apic_metrics.go#L371-L373

Added lines #L371 - L373 were not covered by tests
}

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

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

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/apic_metrics.go#L376

Added line #L376 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
continue
}
}
Expand Down