Skip to content

Commit

Permalink
Write compressed config, round 2 [RHELDST-25461]
Browse files Browse the repository at this point in the history
This commit re-enables the writing of compressed config, this time
without the extraneous layer of base64 encoding, as this is understood
to be done implicitly by botocore.

Must be merged *after* deployment of corresponding exodus-lambda change:
release-engineering/exodus-lambda#589
  • Loading branch information
rohanpm committed Aug 5, 2024
1 parent 9b87b41 commit 62d8643
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 4 additions & 3 deletions exodus_gw/aws/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ def query_definitions(self) -> dict[str, Any]:
)
if query_result.get("Items"):
item = query_result["Items"][0]
if item_encoded := item["config"].get("B"):
if item_bytes := item["config"].get("B"):
# new-style: config is compressed and stored as bytes
item_bytes = b64decode(item_encoded)
item_json = gzip.decompress(item_bytes).decode()
else:
# old-style, config was stored as JSON string.
Expand Down Expand Up @@ -161,7 +160,9 @@ def create_config_request(self, config):
"Item": {
"from_date": {"S": self.from_date},
"config_id": {"S": "exodus-config"},
"config": {"S": json.dumps(config)},
"config": {
"B": gzip.compress(json.dumps(config).encode())
},
}
}
},
Expand Down
6 changes: 1 addition & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ def side_effect(
assert Limit == 1
config_json = json.dumps(fake_config)
if binary_config:
config_value = {
"B": base64.b64encode(
gzip.compress(config_json.encode())
).decode()
}
config_value = {"B": gzip.compress(config_json.encode())}
else:
config_value = {"S": config_json}
return {
Expand Down
12 changes: 10 additions & 2 deletions tests/worker/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def test_deploy_config(
"Item": {
"from_date": {"S": NOW_UTC},
"config_id": {"S": "exodus-config"},
"config": {"S": json.dumps(fake_config)},
"config": {
"B": gzip.compress(
json.dumps(fake_config).encode()
)
},
}
}
},
Expand Down Expand Up @@ -154,7 +158,11 @@ def test_deploy_config_with_flush(
"Item": {
"from_date": {"S": NOW_UTC},
"config_id": {"S": "exodus-config"},
"config": {"S": json.dumps(updated_config)},
"config": {
"B": gzip.compress(
json.dumps(updated_config).encode()
)
},
}
}
},
Expand Down

0 comments on commit 62d8643

Please sign in to comment.