Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log s3 batch deletes #5204

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion koku/masu/test/util/aws/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def test_batch_delete_s3_objects(self, mock_resource):
mock_bucket.delete_objects.assert_has_calls(
[call(Delete={"Objects": expected_keys[:1000]}), call(Delete={"Objects": expected_keys[1000:]})]
)
self.assertIn("removed files from s3 bucket", captured_logs.output[-1])
self.assertIn("removed batch files from s3 bucket", captured_logs.output[-1])

def test_remove_s3_objects_not_matching_metadata(self):
"""Test remove_s3_objects_not_matching_metadata."""
Expand Down
16 changes: 8 additions & 8 deletions koku/masu/util/aws/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,15 +803,15 @@ def delete_s3_objects(request_id, keys_to_delete, context) -> list[str]:
batch_end = batch_start + batch_size
object_keys_batch = keys_to_delete[batch_start:batch_end]
s3_bucket.delete_objects(Delete={"Objects": object_keys_batch})
LOG.info(
log_json(
request_id,
msg="removed files from s3 bucket",
context=context,
bucket=settings.S3_BUCKET_NAME,
file_list=keys_to_delete,
LOG.info(
log_json(
request_id,
msg="removed batch files from s3 bucket",
context=context,
bucket=settings.S3_BUCKET_NAME,
file_list=object_keys_batch,
)
)
)
return keys_to_delete
except (EndpointConnectionError, ClientError) as err:
LOG.warning(
Expand Down
Loading