mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 10:06:57 +02:00
Extract check for retryable error into function
This commit is contained in:
parent
e8e5d5c359
commit
a88cae299a
@ -182,7 +182,7 @@ func (p WebhookProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, err
|
|||||||
recordsErrorsGauge.Inc()
|
recordsErrorsGauge.Inc()
|
||||||
log.Debugf("Failed to get records with code %d", resp.StatusCode)
|
log.Debugf("Failed to get records with code %d", resp.StatusCode)
|
||||||
err := fmt.Errorf("failed to get records with code %d", resp.StatusCode)
|
err := fmt.Errorf("failed to get records with code %d", resp.StatusCode)
|
||||||
if resp.StatusCode >= http.StatusInternalServerError {
|
if isRetryableError(resp.StatusCode) {
|
||||||
return nil, provider.NewSoftError(err)
|
return nil, provider.NewSoftError(err)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -230,7 +230,7 @@ func (p WebhookProvider) ApplyChanges(ctx context.Context, changes *plan.Changes
|
|||||||
applyChangesErrorsGauge.Inc()
|
applyChangesErrorsGauge.Inc()
|
||||||
log.Debugf("Failed to apply changes with code %d", resp.StatusCode)
|
log.Debugf("Failed to apply changes with code %d", resp.StatusCode)
|
||||||
err := fmt.Errorf("failed to apply changes with code %d", resp.StatusCode)
|
err := fmt.Errorf("failed to apply changes with code %d", resp.StatusCode)
|
||||||
if resp.StatusCode >= http.StatusInternalServerError {
|
if isRetryableError(resp.StatusCode) {
|
||||||
return provider.NewSoftError(err)
|
return provider.NewSoftError(err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@ -280,7 +280,7 @@ func (p WebhookProvider) AdjustEndpoints(e []*endpoint.Endpoint) ([]*endpoint.En
|
|||||||
adjustEndpointsErrorsGauge.Inc()
|
adjustEndpointsErrorsGauge.Inc()
|
||||||
log.Debugf("Failed to AdjustEndpoints with code %d", resp.StatusCode)
|
log.Debugf("Failed to AdjustEndpoints with code %d", resp.StatusCode)
|
||||||
err := fmt.Errorf("failed to AdjustEndpoints with code %d", resp.StatusCode)
|
err := fmt.Errorf("failed to AdjustEndpoints with code %d", resp.StatusCode)
|
||||||
if resp.StatusCode >= http.StatusInternalServerError {
|
if isRetryableError(resp.StatusCode) {
|
||||||
return nil, provider.NewSoftError(err)
|
return nil, provider.NewSoftError(err)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -299,3 +299,8 @@ func (p WebhookProvider) AdjustEndpoints(e []*endpoint.Endpoint) ([]*endpoint.En
|
|||||||
func (p WebhookProvider) GetDomainFilter() endpoint.DomainFilter {
|
func (p WebhookProvider) GetDomainFilter() endpoint.DomainFilter {
|
||||||
return p.DomainFilter
|
return p.DomainFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isRetryableError returns true for HTTP status codes between 500 and 510 (inclusive)
|
||||||
|
func isRetryableError(statusCode int) bool {
|
||||||
|
return statusCode >= http.StatusInternalServerError && statusCode <= http.StatusNotExtended
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user