Skip to content

Commit

Permalink
enhance: Check if resp is nil in capi metrics and continue
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceJJones committed Oct 25, 2024
1 parent d8bc17b commit 691ecfb
Showing 1 changed file with 2 additions and 1 deletion.
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 @@ func (a *apic) SendUsageMetrics(ctx context.Context) {
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

0 comments on commit 691ecfb

Please sign in to comment.