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

bug: Add try/except handler for force #1535

Merged
merged 12 commits into from
Apr 16, 2024
Merged

bug: Add try/except handler for force #1535

merged 12 commits into from
Apr 16, 2024

Conversation

jrconlin
Copy link
Member

@jrconlin jrconlin commented Apr 8, 2024

Description

This will wrap the force delete_service_data with a try/except handler
so as not to prevent the tokenserver record from being removed if the
delete_service_data fails.

  • Added override_node option to attempt the delete using the specified node instead of the recorded one. (useful if the original record was copied over and the subsequent managing node changed.)
  • Ran code through black to improve formatting
  • cargo update for audit

Issue(s)

Closes SYNC-3426

jrconlin added 4 commits April 8, 2024 12:37
This will wrap the force `delete_service_data` with a try/except handler
so as not to prevent the tokenserver record from being removed if the
delete_service_data fails.
* Try/except will capture any errors from trying to call the delete on a
given node, this could fail if the auth or node aren't correct.
* Override will override the attempted node. This will allow us to force
the delete message, even if the original data was copied over and the
node was incorrect.
@jrconlin jrconlin requested review from pjenvey and taddes April 8, 2024 20:26
Copy link
Contributor

@taddes taddes left a comment

Choose a reason for hiding this comment

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

LGTM, fully acknowledging my relative unfamiliarity with tokenserver. Just a few small tweaks here and there. Thanks for the formatting run, it makes it easier to read for sure!

),
},
secret=secret,
)
secret = tokenlib.get_derived_secret(token, secret=secret)
endpoint = PATTERN.format(uid=user.uid, node=user.node)
auth = HawkAuth(token, secret)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we don't do the dryrun check sooner in the function? Just wondering if it's better to exit earlier before making the token.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mostly just to exercise code. For a dry run, I prefer doing as much as possible up until I'm about to do something destructive / permanent so that I know that all other aspects/functions work. Ideally, the dryrun would dump state so that could see what the action to be taken would be, but that can produce a lot of noise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah that's a great point!

tools/tokenserver/purge_old_records.py Outdated Show resolved Hide resolved
tools/tokenserver/purge_old_records.py Outdated Show resolved Hide resolved
tools/tokenserver/purge_old_records.py Outdated Show resolved Hide resolved
tools/tokenserver/purge_old_records.py Outdated Show resolved Hide resolved
@jrconlin jrconlin requested a review from taddes April 10, 2024 15:58
Copy link
Contributor

@taddes taddes left a comment

Choose a reason for hiding this comment

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

🚀 👍

@jrconlin jrconlin merged commit b777fa0 into master Apr 16, 2024
8 checks passed
@jrconlin jrconlin deleted the bug/SYNC-3426_try branch April 16, 2024 17:07
This was referenced Apr 16, 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.

3 participants