From 5037d7368d832400b43d93ae6f6ac2bda07b8901 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 24 Feb 2025 10:58:26 +0000 Subject: [PATCH] azureblob: handle retry error codes more carefully --- backend/azureblob/azureblob.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index fcefd19c5..c2db11267 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -656,13 +656,29 @@ func (f *Fs) shouldRetry(ctx context.Context, err error) (bool, error) { if fserrors.ContextError(ctx, &err) { return false, err } - // FIXME interpret special errors - more to do here - if storageErr, ok := err.(*azcore.ResponseError); ok { + var storageErr *azcore.ResponseError + if errors.As(err, &storageErr) { + // General errors from: + // https://learn.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes + // Blob specific errors from: + // https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes switch storageErr.ErrorCode { case "InvalidBlobOrBlock": // These errors happen sometimes in multipart uploads // because of block concurrency issues return true, err + case "InternalError": + // The server encountered an internal error. Please retry the request. + return true, err + case "OperationTimedOut": + // The operation could not be completed within the permitted time. The + // operation may or may not have succeeded on the server side. Please query + // the server state before retrying the operation. + return true, err + case "ServerBusy": + // The server is currently unable to receive requests. Please retry your + // request. + return true, err } statusCode := storageErr.StatusCode for _, e := range retryErrorCodes {