Skip to content

Commit

Permalink
fix(godaddy): Handle QUOTA_EXCEEDED error gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstojda committed Nov 12, 2024
1 parent 7343cb9 commit e242c1b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions provider/godaddy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"strconv"
"time"

log "github.com/sirupsen/logrus"
"golang.org/x/time/rate"

"sigs.k8s.io/external-dns/pkg/apis/externaldns"
Expand Down Expand Up @@ -230,6 +231,18 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {
resp, err := c.Client.Do(req)
// In case of several clients behind NAT we still can hit rate limit
for i := 1; i < 3 && err == nil && resp.StatusCode == 429; i++ {
// Parse error response
var apiError GDErrorResponse
if err = c.UnmarshalResponse(resp, &apiError); err != nil {
return nil, fmt.Errorf("parsing 429 response: %w", err)
}

if apiError.Code == "QUOTA_EXCEEDED" {
// Only log an error instead of returning one as it seems that the API has per-endpoint quotas
log.Errorf("monthly quota exceeded for endpoint: %s", req.URL.Path)
break
}

retryAfter, _ := strconv.ParseInt(resp.Header.Get("Retry-After"), 10, 0)

jitter := rand.Int63n(retryAfter)
Expand Down

0 comments on commit e242c1b

Please sign in to comment.