From 67af027bffe4f2267d990d1033d635c2ce606f5b Mon Sep 17 00:00:00 2001 From: Luke Couzens Date: Wed, 3 Jul 2024 16:39:26 +0100 Subject: [PATCH] log s3 batch deletes (#5204) * log s3 batch deletes --- koku/masu/test/util/aws/test_common.py | 2 +- koku/masu/util/aws/common.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/koku/masu/test/util/aws/test_common.py b/koku/masu/test/util/aws/test_common.py index 393b844ad9..8c0d6b74a7 100644 --- a/koku/masu/test/util/aws/test_common.py +++ b/koku/masu/test/util/aws/test_common.py @@ -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.""" diff --git a/koku/masu/util/aws/common.py b/koku/masu/util/aws/common.py index 9d1abd0121..e9510003e9 100644 --- a/koku/masu/util/aws/common.py +++ b/koku/masu/util/aws/common.py @@ -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(