Skip to content

Commit

Permalink
do not retry on locked error
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Jul 9, 2024
1 parent 3977d76 commit 9fb4fda
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hcloud/client_handler_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func retryPolicy(resp *Response, err error) bool {
switch {
case errors.As(err, &apiErr):
switch apiErr.Code { //nolint:exhaustive
case ErrorCodeConflict, ErrorCodeLocked:
case ErrorCodeConflict:
return true
case ErrorCodeRateLimitExceeded:
return true
Expand Down
4 changes: 3 additions & 1 deletion hcloud/client_handler_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ func TestRetryPolicy(t *testing.T) {
want: false,
},
{
// The API error code locked is used in many unexpected situations, we can
// only retry in specific context where we know the error is not misused.
name: "api returns locked error",
resp: fakeResponse(t, 423, `{"error":{"code":"locked"}}`, true),
want: true,
want: false,
},
{
// HTTP 423 is used in many situations (e.g. protected), we must only
Expand Down

0 comments on commit 9fb4fda

Please sign in to comment.