Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dont do tag updates for new tables
Signed-off-by: Rob Howley <howley.robert@gmail.com>
  • Loading branch information
robhowley committed Apr 23, 2025
commit c7548e1569fa6ca48395f73bec621363da2ba4ee
14 changes: 10 additions & 4 deletions sdk/python/feast/infra/online_stores/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import contextlib
import itertools
import logging
from collections import OrderedDict
from collections import OrderedDict, defaultdict
from datetime import datetime
from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Union

Expand Down Expand Up @@ -199,23 +199,28 @@ def update(
online_config.session_based_auth,
)

do_tag_updates = defaultdict(bool)
for table_instance in tables_to_keep:
# Add Tags attribute to creation request only if configured to prevent
# TagResource permission issues, even with an empty Tags array.
table_tags = self._table_tags(online_config, table_instance)
kwargs = {"Tags": table_tags} if table_tags else {}

table_name = _get_table_name(online_config, config, table_instance)
try:
dynamodb_resource.create_table(
TableName=_get_table_name(online_config, config, table_instance),
TableName=table_name,
KeySchema=[{"AttributeName": "entity_id", "KeyType": "HASH"}],
AttributeDefinitions=[
{"AttributeName": "entity_id", "AttributeType": "S"}
],
BillingMode="PAY_PER_REQUEST",
**kwargs,
)

except ClientError as ce:
do_tag_updates[table_name] = True

# If the table creation fails with ResourceInUseException,
# it means the table already exists or is being created.
# Otherwise, re-raise the exception
Expand All @@ -227,8 +232,9 @@ def update(
dynamodb_client.get_waiter("table_exists").wait(TableName=table_name)
# once table is confirmed to exist, update the tags.
# tags won't be updated in the create_table call if the table already exists
tags = self._table_tags(online_config, table_instance)
self._update_tags(dynamodb_client, table_name, tags)
if do_tag_updates[table_name]:
tags = self._table_tags(online_config, table_instance)
self._update_tags(dynamodb_client, table_name, tags)
Comment on lines +236 to +238
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the table already exists, then we should perform tag updates. otherwise we can skip that bc the tags would've been added in the create_table call


for table_to_delete in tables_to_delete:
_delete_table_idempotent(
Expand Down