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

Index Delete Retry #223

Merged
merged 7 commits into from
Aug 4, 2022
Merged

Index Delete Retry #223

merged 7 commits into from
Aug 4, 2022

Conversation

willronchetti
Copy link
Member

  • Retry delete_index in case of an error, likely related to a snapshot occurring at the same time as the delete operation. Give it two minutes (12 tries) to succeed.

snovault/elasticsearch/create_mapping.py Outdated Show resolved Hide resolved
collection=in_type)
break
else:
assert res.get('acknowledged') is True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. assert is usually a test-time thing to do. AssertionError usually means test failure and is distinct from programmatic failure. dcicutils.misc_utils has a check_true function that will raise RuntimeError or some other error of your choosing if you want to use that.

if res.get('status') == 404:
log.info('MAPPING: index %s not found and cannot be deleted' % in_type,
collection=in_type)
break
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would remove the two break statements in each arm of the if and put a single break after the if to make it clearer that this if res is not None arm always falls through. I might add a comment like

break # Exit the retry loop

Copy link
Collaborator

@netsettler netsettler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this looks fine.

Oddly, it was the assert that was worrying me because I wasn't sure if it was only an intellectual check or a runtime promise. Removing it clarified things and I doubt will hurt anything.

@willronchetti willronchetti merged commit 795abe8 into master Aug 4, 2022
@willronchetti willronchetti deleted the snapshot branch August 4, 2022 19:41
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.

2 participants