Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions hcloud/client_handler_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func retryPolicy(resp *Response, err error) bool {
return true
case ErrorCodeRateLimitExceeded:
return true
case ErrorCodeBadGateway:
return true
case ErrorCodeTimeout:
return true
}
Expand Down
5 changes: 5 additions & 0 deletions hcloud/client_handler_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func TestRetryPolicy(t *testing.T) {
resp: fakeResponse(t, 502, ``, false),
want: true,
},
{
name: "api returns bad_gateway error",
resp: fakeResponse(t, 502, `{"error":{"code":"bad_gateway"}}`, true),
want: true,
},
{
name: "api returns unavailable error",
resp: fakeResponse(t, 503, `{"error":{"code":"unavailable"}}`, true),
Expand Down
1 change: 1 addition & 0 deletions hcloud/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
ErrorCodeResourceLocked ErrorCode = "resource_locked" // The resource is locked. The caller should contact support
ErrorCodeServerError ErrorCode = "server_error" // Error within the API backend
ErrorCodeTokenReadonly ErrorCode = "token_readonly" // The token is only allowed to perform GET requests
ErrorCodeBadGateway ErrorCode = "bad_gateway" // The request could not be answered by the API backend, please retry
ErrorCodeTimeout ErrorCode = "timeout" // The request could not be answered in time, please retry
ErrorUnsupportedError ErrorCode = "unsupported_error" // The given resource does not support this
ErrorDeprecatedAPIEndpoint ErrorCode = "deprecated_api_endpoint" // The request can not be answered because the API functionality was removed
Expand Down
1 change: 1 addition & 0 deletions hcloud/hcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ When the API returned an HTTP error, with the status code:
When the API returned an application error, with the code:
- [ErrorCodeConflict]
- [ErrorCodeRateLimitExceeded]
- [ErrorCodeBadGateway]
- [ErrorCodeTimeout]

Changes to the retry policy might occur between releases, and will not be considered
Expand Down
Loading