Skip to content

DynamoDB: Fix startup in non-default account ID/region#10157

Merged
viren-nadkarni merged 3 commits intomasterfrom
ddb-ttl-xaccount
Feb 6, 2024
Merged

DynamoDB: Fix startup in non-default account ID/region#10157
viren-nadkarni merged 3 commits intomasterfrom
ddb-ttl-xaccount

Conversation

@viren-nadkarni
Copy link
Member

@viren-nadkarni viren-nadkarni commented Feb 1, 2024

Summary

It was observed that test_time_to_live_deletion would fail in non-default account/region setting (#8204), specifically the second of the below two assertions that it performs:

assert response.status_code == 200
assert response.json() == {"ExpiredItems": 1}

The first assertion would pass with HTTP 200 but for the second, the response value would be '' cause JSON deserialisation error.

There were two root problems:

  1. How rolo works. By default, if an invalid route is queried at the LocalStack endpoint, it returns an HTTP 200 with an empty response by default. See Invalid routes must return HTTP 404 Not Found #10167 for details
  2. Lack of credentials passed to connect_externally_to(): This is used when DDB Local is started to do a health check. Lack of explicit credentials meant that the factory would fallback to env values, which we are removing in Use non-default formatted access key ID for tests #8204. Boto client creation would fail, causing the healthcheck to fail, which in turn prevented the custom routes from being registered.

def on_before_start(self):
self.server.start_dynamodb()
if config.DYNAMODB_REMOVE_EXPIRED_ITEMS:
self._expired_items_worker.start()
self._router_rules = ROUTER.add(DynamoDBDeveloperEndpoints())

Changes

  • Pass dummy credentials (for now, just 000000000000) to the connect_externally_to() usage. The client is only used to check if DDB returns a valid response, and we don't really care about the actual value.
  • Minor refactoring so that DDB startup always prints error messages

Tests

Changes were tested with non-default credentials, see commit 4da325e, where the test_time_to_live_deletion passes 🟢

@viren-nadkarni viren-nadkarni self-assigned this Feb 1, 2024
@viren-nadkarni viren-nadkarni added the semver: patch Non-breaking changes which can be included in patch releases label Feb 1, 2024
@github-actions
Copy link

github-actions bot commented Feb 1, 2024

S3 Image Test Results (AMD64 / ARM64)

  2 files    2 suites   3m 16s ⏱️
386 tests 335 ✅  51 💤 0 ❌
772 runs  670 ✅ 102 💤 0 ❌

Results for commit 4da325e.

♻️ This comment has been updated with latest results.

@viren-nadkarni viren-nadkarni changed the title DynamoDB: Fix TTL expire endpoint in non-default account ID/region DynamoDB: Fix startup in non-default account ID/region Feb 5, 2024
@viren-nadkarni viren-nadkarni marked this pull request as ready for review February 5, 2024 17:42
@github-actions
Copy link

github-actions bot commented Feb 5, 2024

LocalStack Community integration with Pro

    2 files      2 suites   1h 21m 52s ⏱️
2 622 tests 2 374 ✅ 248 💤 0 ❌
2 624 runs  2 374 ✅ 250 💤 0 ❌

Results for commit ab98792.

♻️ This comment has been updated with latest results.

@viren-nadkarni viren-nadkarni merged commit a8ef05d into master Feb 6, 2024
@viren-nadkarni viren-nadkarni deleted the ddb-ttl-xaccount branch February 6, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants