Skip to content

Commit

Permalink
enhance: Check if resp is nil in capi metrics and continue (#3299)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceJJones authored Oct 25, 2024
1 parent 128328b commit d00a6a6
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 {
// 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

0 comments on commit d00a6a6

Please sign in to comment.