Closed twrichards closed 6 months ago
Seen on image-loader (merged by @twrichards 8 minutes and 51 seconds ago) Please check your changes!
Seen on auth, usage, metadata-editor, thrall, leases, cropper, collections, media-api, kahuna (merged by @twrichards 9 minutes and 56 seconds ago) Please check your changes!
Co-authored-by: @dblatcher
Original issue neatly described here https://github.com/guardian/grid/issues/4026, see also the follow-up comments as we explored the problem in the lead up to this PR.
Infrastructure changes in https://github.com/guardian/editorial-tools-platform/pull/733
Change summary by area
/common-lib/**/aws/
/common-lib/**/config/
sqs.ingest.queue.url
s3.ingest.bucket
s3.fail.bucket
/dev/
/image-loader/
the ImageLoader Controller continually monitors the SQS queue - on receiving a message, either:
approximateReceiveCount
property of the message every time the message is consumed)approximateReceiveCount
is > 2, the file is transferred directly to the fail bucket - in this case we assume there is a problem with the image file (too big?) that caused the previous instances to crash while trying to process it, so don't try again.if the queue is configured, healthcheck will fail if the instance has stopped polling the queue for messages
/prepare endpoint : authenticated kahuna users can post the filenames and imageId’s of the images they want to upload and get back the pre-signed URLS to upload the files directly to the s3 ingest queue
new status types for UploadStatusTable:
/kahuna/
Config: Kahuna will continue to use the old/current method of posting image files directly to ImageLoader if there is no queue-based ingest bucket defined , otherwise, it will:
filehash
for this)POST
the filenames and media ids of the files to be uploaded to the/prepare
endpoint to receive the presigned URL for each imagePUT
the file in S3 using the the presigned URLPOST
to/uploadStatus
endpoint to update the image status ‘Queued’/uploadStatus
endpoint toGET
the image status, updating the UI when an image is ‘Completed’ or ‘Failed’Diagrams
Architecture
reveal mermaid code
```mermaid flowchart TD user(Kahuna) ftp(FTP server) feeds(Grid Feeds) image-loader(image-loader\nec2) ingest[(ingest bucket\ns3)] queue(SQS queue) bucket[(image bucket\ns3)] elastic[(elasticsearch)] status[(upload status\ndynamo)] user <-- request\n presigned URL --> image-loader user -- upload file\n(presigned URL) -->ingest ftp -- upload file--> ingest feeds -- upload file--> ingest ingest -- objectCreated --> queue queue <-- pulls messages --> image-loader image-loader -- move file from\n ingest bucket---> bucket image-loader -- add image ---> elastic image-loader -- update status ---> status ```UI upload sequence