mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
log s3 objects we want to delete
This commit is contained in:
@@ -93,8 +93,10 @@ def cleanup_old_s3_objects():
|
|||||||
response = s3_client.list_objects_v2(Bucket=bucket_name)
|
response = s3_client.list_objects_v2(Bucket=bucket_name)
|
||||||
while True:
|
while True:
|
||||||
for obj in response.get("Contents", []):
|
for obj in response.get("Contents", []):
|
||||||
if obj["LastModified"] >= time_limit:
|
if obj["LastModified"] <= time_limit:
|
||||||
print(f"{obj['LastModified']} {obj['Key']}")
|
current_app.logger.info(
|
||||||
|
f"#delete-old-s3-objects Wanting to delete: {obj['LastModified']} {obj['Key']}"
|
||||||
|
)
|
||||||
if "NextContinuationToken" in response:
|
if "NextContinuationToken" in response:
|
||||||
response = s3_client.list_objects_v2(
|
response = s3_client.list_objects_v2(
|
||||||
Bucket=bucket_name,
|
Bucket=bucket_name,
|
||||||
@@ -104,7 +106,7 @@ def cleanup_old_s3_objects():
|
|||||||
break
|
break
|
||||||
except Exception:
|
except Exception:
|
||||||
current_app.logger.error(
|
current_app.logger.error(
|
||||||
f"An error occurred while cleaning up old s3 objects #notify-api-1303",
|
"#delete-old-s3-objects An error occurred while cleaning up old s3 objects",
|
||||||
exc_info=True,
|
exc_info=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user