fix: one file the worker may not delete no longer stops the cleanup of every other file
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 7m23s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m34s
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 7m23s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m34s
CI run 318 failed in retention_test: an expired upload outside the storage policy's prefixes (originals/, videos/) made delete_object raise AccessDenied, and the cleanup stopped there on every tick, so no file behind it was ever deleted. The worker now logs it as an error (so it reaches Sentry), tries that file again a day later and goes on with the rest; retention_test covers it. The test fixtures that wrote keys under test/, machine-test/, machine-log-test/ and reset-test/ now use originals/, where the worker may delete them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import threading
|
||||
import time
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
import psycopg
|
||||
from botocore.exceptions import ClientError
|
||||
from psycopg.types.json import Jsonb
|
||||
from . import mail, observability, unpaid
|
||||
from .adapters import FakeTiny, LocalS3Storage, require_runtime
|
||||
@@ -40,7 +41,16 @@ def cleanup():
|
||||
AND (expires_at<=now() OR (NOT complete AND created_at<now()-interval '1 day'))
|
||||
ORDER BY created_at FOR UPDATE SKIP LOCKED LIMIT 50""").fetchall()
|
||||
for row in rows:
|
||||
storage.discard(row['object_key'],row['multipart_id'],row['complete'])
|
||||
# A file this worker may not delete (outside the storage policy's
|
||||
# prefixes, or a storage refusal) must not stop the cleanup of
|
||||
# every file after it: it is reported and tried again tomorrow.
|
||||
try:
|
||||
storage.discard(row['object_key'],row['multipart_id'],row['complete'])
|
||||
except ClientError as exc:
|
||||
logging.error('Cleanup could not delete upload %s (%s): %s', row['id'],
|
||||
row['object_key'].split('/')[0], exc.response.get('Error',{}).get('Code'))
|
||||
c.execute("UPDATE dtf_local.uploads SET expires_at=now()+interval '1 day' WHERE id=%s", (row['id'],))
|
||||
continue
|
||||
# A generated PNG's pieces for the Kanban's viewer go with it (item 7).
|
||||
if row['name'].lower().endswith('.png'):
|
||||
storage.discard_prefix(f"originals/tiles/{row['id']}/")
|
||||
|
||||
Reference in New Issue
Block a user