From d68b3209080aa206d24a2db25345768a9562d910 Mon Sep 17 00:00:00 2001 From: Gerrit Renker Date: Fri, 6 Dec 2024 08:55:35 -0500 Subject: [PATCH] [s3_meta_request]: Retry on ExpiredToken Similar to the case of `RequestTimeout`, when progress stalls due to a prolonged time of the server closing connections and similar conditions that prevent refreshing STS tokens, retrying `ExpiredToken` will give a stalling job a chance to continue, rather than failing. Documented success case in #471. Resolves #471. --- include/aws/s3/s3.h | 1 + source/s3.c | 1 + source/s3_util.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/include/aws/s3/s3.h b/include/aws/s3/s3.h index fa146f25..0eeb6c60 100644 --- a/include/aws/s3/s3.h +++ b/include/aws/s3/s3.h @@ -49,6 +49,7 @@ enum aws_s3_errors { AWS_ERROR_S3_RECV_FILE_ALREADY_EXISTS, AWS_ERROR_S3_RECV_FILE_NOT_FOUND, AWS_ERROR_S3_REQUEST_TIMEOUT, + AWS_ERROR_S3_TOKEN_EXPIRED, AWS_ERROR_S3_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_S3_PACKAGE_ID) }; diff --git a/source/s3.c b/source/s3.c index a5a0d739..08aa1199 100644 --- a/source/s3.c +++ b/source/s3.c @@ -52,6 +52,7 @@ static struct aws_error_info s_errors[] = { AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_RECV_FILE_ALREADY_EXISTS, "File already exists, cannot create as new."), AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_RECV_FILE_NOT_FOUND, "The receive file doesn't exist, cannot create as configuration required."), AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_REQUEST_TIMEOUT, "RequestTimeout error received from S3."), + AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_TOKEN_EXPIRED, "Token expired - needs a refresh."), }; /* clang-format on */ diff --git a/source/s3_util.c b/source/s3_util.c index 93d51e93..8e556dcf 100644 --- a/source/s3_util.c +++ b/source/s3_util.c @@ -692,6 +692,11 @@ int aws_s3_crt_error_code_from_recoverable_server_error_code_string(struct aws_b return AWS_ERROR_S3_REQUEST_TIMEOUT; } + if (aws_byte_cursor_eq_c_str_ignore_case(&error_code_string, "ExpiredToken") || + aws_byte_cursor_eq_c_str_ignore_case(&error_code_string, "TokenRefreshRequired")) { + return AWS_ERROR_S3_TOKEN_EXPIRED; + } + return AWS_ERROR_UNKNOWN; }