mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 13:38:53 -04:00
Merge pull request #1330 from GSA/fix_test_coverage
actually start deleting old s3 objects
This commit is contained in:
@@ -87,7 +87,6 @@ def get_bucket_name():
|
||||
|
||||
|
||||
def cleanup_old_s3_objects():
|
||||
|
||||
bucket_name = get_bucket_name()
|
||||
|
||||
s3_client = get_s3_client()
|
||||
@@ -99,9 +98,15 @@ def cleanup_old_s3_objects():
|
||||
while True:
|
||||
for obj in response.get("Contents", []):
|
||||
if obj["LastModified"] <= time_limit:
|
||||
current_app.logger.info(
|
||||
f"#delete-old-s3-objects Wanting to delete: {obj['LastModified']} {obj['Key']}"
|
||||
)
|
||||
|
||||
try:
|
||||
remove_csv_object(obj["Key"])
|
||||
current_app.logger.info(
|
||||
f"#delete-old-s3-objects Deleted: {obj['LastModified']} {obj['Key']}"
|
||||
)
|
||||
except botocore.exceptions.ClientError:
|
||||
current_app.logger.exception(f"Couldn't delete {obj['Key']}")
|
||||
|
||||
if "NextContinuationToken" in response:
|
||||
response = s3_client.list_objects_v2(
|
||||
Bucket=bucket_name,
|
||||
|
||||
@@ -251,7 +251,7 @@ class Config(object):
|
||||
},
|
||||
"delete_old_s3_objects": {
|
||||
"task": "delete-old-s3-objects",
|
||||
"schedule": crontab(minute="*/5"),
|
||||
"schedule": crontab(hour=7, minute=10),
|
||||
"options": {"queue": QueueNames.PERIODIC},
|
||||
},
|
||||
"regenerate-job-cache": {
|
||||
|
||||
Reference in New Issue
Block a user