Skip to content

Commit acbaad4

Browse files
author
Rob Howley
committed
make tagging retryable
Signed-off-by: Rob Howley <rhowley@seatgeek.com>
1 parent 6b751d5 commit acbaad4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

sdk/python/feast/infra/online_stores/dynamodb.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121

2222
from aiobotocore.config import AioConfig
2323
from pydantic import StrictBool, StrictStr
24+
from tenacity import (
25+
retry,
26+
retry_if_exception_type,
27+
stop_after_attempt,
28+
wait_exponential,
29+
)
2430

2531
from feast import Entity, FeatureView, utils
2632
from feast.infra.infra_object import DYNAMODB_INFRA_OBJECT_CLASS_TYPE, InfraObject
@@ -786,6 +792,14 @@ def _latest_data_to_write(
786792
return (v for _, v in OrderedDict((ah[0], ah[1]) for ah in sorted_data).items())
787793

788794

795+
class RetryableBotoError(Exception):
796+
pass
797+
798+
799+
class LimitExceededException(RetryableBotoError):
800+
pass
801+
802+
789803
class _DynamoTableManager:
790804
def __init__(
791805
self, dynamodb_resource, config: RepoConfig, feature_view: FeatureView
@@ -820,6 +834,12 @@ def table_tags(self) -> list[dict[str, str]]:
820834

821835
return common_tags + table_tags
822836

837+
@retry(
838+
wait=wait_exponential(multiplier=1, max=4),
839+
retry=retry_if_exception_type(RetryableBotoError),
840+
stop=stop_after_attempt(3),
841+
reraise=True,
842+
)
823843
def _update_tags(self, new_tags: list[dict[str, str]]):
824844
table_arn = self._dynamodb_client.describe_table(TableName=self.table_name)[
825845
"Table"
@@ -834,7 +854,11 @@ def _update_tags(self, new_tags: list[dict[str, str]]):
834854
)
835855

836856
if new_tags:
837-
self._dynamodb_client.tag_resource(ResourceArn=table_arn, Tags=new_tags)
857+
try:
858+
self._dynamodb_client.tag_resource(ResourceArn=table_arn, Tags=new_tags)
859+
except ClientError as ce:
860+
if ce.response["Error"]["Code"] == "LimitExceededException":
861+
raise LimitExceededException from ce
838862

839863
def update(self):
840864
# Add Tags attribute to creation request only if configured to prevent

0 commit comments

Comments
 (0)