Skip to content

Commit

Permalink
fix retries after exception normalization (#989)
Browse files Browse the repository at this point in the history
  • Loading branch information
thehesiod committed Dec 22, 2022
1 parent 8d9d71a commit 14b2f5f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changes
-------
2.4.2 (2022-12-22)
^^^^^^^^^^^^^^^^^^
* fix retries (#988)

2.4.1 (2022-11-28)
^^^^^^^^^^^^^^^^^^
* Adds support for checksums in streamed request trailers (thanks @terrycain #962)
Expand Down
2 changes: 1 addition & 1 deletion aiobotocore/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.4.1'
__version__ = '2.4.2'
6 changes: 1 addition & 5 deletions aiobotocore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import logging

import aiohttp.client_exceptions
import botocore.awsrequest
from botocore.exceptions import (
InvalidIMDSEndpointError,
Expand All @@ -12,6 +11,7 @@
from botocore.utils import (
DEFAULT_METADATA_SERVICE_TIMEOUT,
METADATA_BASE_URL,
RETRYABLE_HTTP_ERRORS,
BadIMDSRequestError,
ClientError,
ContainerMetadataFetcher,
Expand All @@ -31,10 +31,6 @@
from aiobotocore._helpers import asynccontextmanager

logger = logging.getLogger(__name__)
RETRYABLE_HTTP_ERRORS = (
aiohttp.client_exceptions.ClientError,
asyncio.TimeoutError,
)


class _RefCountedSession(aiobotocore.httpsession.AIOHTTPSession):
Expand Down
3 changes: 1 addition & 2 deletions tests/boto_tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import itertools
import json
from typing import List, Tuple, Union
Expand Down Expand Up @@ -194,7 +193,7 @@ async def test_idmsfetcher_retry():
async def test_idmsfetcher_timeout():
session = fake_aiohttp_session(
[
(asyncio.TimeoutError(), 500),
(ReadTimeoutError(endpoint_url='url'), 500),
]
)

Expand Down
15 changes: 9 additions & 6 deletions tests/python3.8/boto_tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import asyncio
import json
import unittest
from unittest import mock

import pytest
from aiohttp.client_exceptions import ClientConnectionError
from botocore.exceptions import (
ConnectionClosedError,
ConnectTimeoutError,
ReadTimeoutError,
)
from botocore.utils import MetadataRetrievalError

from aiobotocore import utils
Expand Down Expand Up @@ -146,7 +149,7 @@ async def test_non_200_response_for_role_name_is_retried(self):
async def test_http_connection_error_for_role_name_is_retried(self):
# Connection related errors should be retried
self.add_get_token_imds_response(token='token')
self.add_imds_connection_error(ClientConnectionError(''))
self.add_imds_connection_error(ConnectionClosedError(endpoint_url=''))
self.add_get_role_name_imds_response()
self.add_get_credentials_imds_response()
result = await AioInstanceMetadataFetcher(
Expand Down Expand Up @@ -190,7 +193,7 @@ async def test_http_connection_errors_is_retried(self):
self.add_get_token_imds_response(token='token')
self.add_get_role_name_imds_response()
# Connection related errors should be retried
self.add_imds_connection_error(ClientConnectionError(''))
self.add_imds_connection_error(ConnectionClosedError(endpoint_url=''))
self.add_get_credentials_imds_response()
result = await AioInstanceMetadataFetcher(
num_attempts=2
Expand Down Expand Up @@ -333,7 +336,7 @@ async def test_metadata_token_not_supported_405(self):
@pytest.mark.asyncio
async def test_metadata_token_not_supported_timeout(self):
user_agent = 'my-user-agent'
self.add_imds_connection_error(asyncio.TimeoutError('url'))
self.add_imds_connection_error(ReadTimeoutError(endpoint_url='url'))
self.add_get_role_name_imds_response()
self.add_get_credentials_imds_response()

Expand All @@ -349,7 +352,7 @@ async def test_metadata_token_not_supported_timeout(self):
@pytest.mark.asyncio
async def test_token_not_supported_exhaust_retries(self):
user_agent = 'my-user-agent'
self.add_imds_connection_error(asyncio.TimeoutError('url'))
self.add_imds_connection_error(ConnectTimeoutError(endpoint_url='url'))
self.add_get_role_name_imds_response()
self.add_get_credentials_imds_response()

Expand Down

0 comments on commit 14b2f5f

Please sign in to comment.