-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add cleanup task #37
Add cleanup task #37
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some minor comments about failures how to query them (plus a "nice to have" that we can shelve)
7c36696
to
ab49709
Compare
if not deposit_id: | ||
raise DepositNotCreated("Deposit id not returned by SWH.") | ||
|
||
deposit = self.record_cls.create(record.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved deposit.create
after the deposition is created on remote, otherwise we could end up with a deposition locally that doesn't exist in SWH.
@@ -103,14 +103,9 @@ def sync_status(self, id_, uow=None): | |||
deposit = deposit_res.deposit | |||
if not deposit: | |||
return | |||
if deposit.status == SWHDepositStatus.FAILED: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the check from sync_status
, otherwise we can't "recover" a deposition. E.g.:
- We create a deposit and start polling its status
- It reaches the max retries for polling, we mark it as
FAILED
- Next day we want to sync the deposition status because it might have worked in SWH
current_app.logger.exception("Failed to complete deposit archival.") | ||
raise | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-raising would retry this task, and the task would try to create the deposit again. We don't want that
service.sync_status(deposit.id) | ||
except Exception as ex: | ||
# If the sync failed for any reason, set the status to "FAILED" | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugly nested try / catch, but service.update_status
can also fail. In that case, we want to continue trying other deposits
616777a
to
bcdc8b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I like some of the renames and overall restructuring :)
One comment on creating the table index, and it's good to merge.
closes zenodo/zenodo-rdm#937
this needs to be rebased on top of main when #33 is merged