Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Consistency] [BE] Cron job to delete unused post attachments #181

Open
4 tasks
katsukixyz opened this issue Oct 8, 2023 · 0 comments
Open
4 tasks

[Consistency] [BE] Cron job to delete unused post attachments #181

katsukixyz opened this issue Oct 8, 2023 · 0 comments
Assignees

Comments

@katsukixyz
Copy link
Collaborator

katsukixyz commented Oct 8, 2023

Context

We have implemented post deletion functionality in a previous sprint. However, we need to handle the case in which attachment deletion from the storage bucket fails during post deletion. We want to add a cron job to remove all the missed deletions so that we don't incur extra cost.

Requirements

You are to write a cron job using Netlify Scheduled Functions. This cron job should be invoked once every day and should do the following:

  1. Fetch all storage bucket objects. The object keys are in the form postId/attachmentName.fileExtension.
  2. Fetch all posts that are pending: false.
  3. Determine the attachments (bucket objects) that are not associated with any posts.
  4. Delete those attachments (retry 3 times).

For testing, you can contact your engineering leadership for our storage bucket credentials to make sure your function invocation does what it is intended to do.

Acceptance Criteria

PM

  • Unused images should be garbage collected once a day via this ticket

EM

  • Log any errors using Sentry
  • Cron job occurs once every day
  • Attachments not associated with a post are deleted correctly with error retrying logic
@katsukixyz katsukixyz changed the title [Consistency] [BE] Cron job to delete unused images [Consistency] [BE] Cron job to delete unused post attachments Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants