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

Add cleanup task #37

Merged
merged 4 commits into from
Jul 22, 2024
Merged

Conversation

alejandromumo
Copy link
Member

@alejandromumo alejandromumo commented Jul 16, 2024

closes zenodo/zenodo-rdm#937

this needs to be rebased on top of main when #33 is merged

Copy link
Member

@slint slint left a 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)

if not deposit_id:
raise DepositNotCreated("Deposit id not returned by SWH.")

deposit = self.record_cls.create(record.id)
Copy link
Member Author

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:
Copy link
Member Author

@alejandromumo alejandromumo Jul 19, 2024

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
Copy link
Member Author

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:
Copy link
Member Author

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

Copy link
Member

@slint slint left a 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.

@alejandromumo alejandromumo merged commit 6eb38bd into inveniosoftware:main Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retry waiting deposits
2 participants