Skip to content

Commit f592b75

Browse files
refactor(rest): simplify sigv4 retry adapter configuration
1 parent 6d53e24 commit f592b75

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

pyiceberg/catalog/rest/__init__.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,6 @@ class IdentifierKind(Enum):
238238
SIGV4_SERVICE = "rest.signing-name"
239239
SIGV4_MAX_RETRIES = "rest.sigv4.max-retries"
240240
SIGV4_DEFAULT_MAX_RETRIES = 10
241-
SIGV4_RETRY_BACKOFF_FACTOR = 0.5
242-
SIGV4_RETRY_STATUS_CODES = (429, 500, 502, 503, 504)
243241
EMPTY_BODY_SHA256: str = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
244242
OAUTH2_SERVER_URI = "oauth2-server-uri"
245243
SNAPSHOT_LOADING_MODE = "snapshot-loading-mode"
@@ -697,25 +695,11 @@ def _init_sigv4(self, session: Session) -> None:
697695
from botocore.awsrequest import AWSRequest
698696
from requests import PreparedRequest
699697
from requests.adapters import HTTPAdapter
700-
from urllib3.util.retry import Retry
701-
702698
class SigV4Adapter(HTTPAdapter):
703699
def __init__(self, **properties: str):
704700
self._properties = properties
705701
max_retries = property_as_int(self._properties, SIGV4_MAX_RETRIES, SIGV4_DEFAULT_MAX_RETRIES)
706-
super().__init__(
707-
max_retries=Retry(
708-
total=max_retries,
709-
status=max_retries,
710-
connect=max_retries,
711-
read=max_retries,
712-
# Keep retries conservative for idempotent calls.
713-
allowed_methods=frozenset({"GET", "HEAD", "OPTIONS"}),
714-
status_forcelist=SIGV4_RETRY_STATUS_CODES,
715-
backoff_factor=SIGV4_RETRY_BACKOFF_FACTOR,
716-
respect_retry_after_header=True,
717-
)
718-
)
702+
super().__init__(max_retries=max_retries)
719703
self._boto_session = boto3.Session(
720704
profile_name=get_first_property_value(self._properties, AWS_PROFILE_NAME),
721705
region_name=get_first_property_value(self._properties, AWS_REGION),

tests/catalog/test_rest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ def test_sigv4_adapter_default_retry_config(rest_mock: Mocker) -> None:
547547
adapter = catalog._session.adapters[catalog.uri]
548548
assert isinstance(adapter, HTTPAdapter)
549549
assert adapter.max_retries.total == SIGV4_DEFAULT_MAX_RETRIES
550-
assert 429 in adapter.max_retries.status_forcelist
551550

552551

553552
def test_sigv4_adapter_override_retry_config(rest_mock: Mocker) -> None:

0 commit comments

Comments
 (0)