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

DT-1217: Python script to remove a user from a list of snapshots #1901

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

snf2ye
Copy link
Contributor

@snf2ye snf2ye commented Feb 5, 2025

Jira ticket: https://broadworkbench.atlassian.net/browse/DT-1217

Addresses

As we try to help unblock users stuck with too many google groups, it can be helpful to remove a single user/group from a bunch of snapshots. We have been asked to do this twice in the last month so it is probably worth committing this script to our repo.

Summary of changes

  • new python script with example use case

Testing Strategy

  • This has been used to help users in two separate cases by myself & @raejohanek

@snf2ye snf2ye requested a review from a team as a code owner February 5, 2025 20:32
@snf2ye snf2ye requested review from rushtong and s-rubenstein and removed request for a team February 5, 2025 20:32
Copy link
Contributor

@s-rubenstein s-rubenstein left a comment

Choose a reason for hiding this comment

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

This seems very reasonable to me

Copy link
Member

@pshapiro4broad pshapiro4broad left a comment

Choose a reason for hiding this comment

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

Looks OK, just some minor comments

tools/removeSnapshotMember/remove_member_from_snapshot.py Outdated Show resolved Hide resolved
for snapshot_id in snapshot_ids:
print(f"Removing from {snapshot_id}")
result = clients.snapshots_api.delete_snapshot_policy_member(snapshot_id, role, email)
print(result)
Copy link
Member

Choose a reason for hiding this comment

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

Should this validate the result? If there are a lot of IDs, maybe only print the ones that failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I updated the error messaging.

On success:

Removing <email> as steward from 1 snapshots
DONE. Successfully removed 1 members from 1 snapshots. 0 failed.

On failure:

Removing <email> as steward from 1 snapshots
Error: Could not remove <email> from 733dcfa4-1bd6-4c58-a9e5-8dd224d3ce9f; Exception: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({<redacted>)
HTTP response body: {"message":"<email> not found","errorDetail":[]}

DONE. Successfully removed 0 members from 1 snapshots. 1 failed.

Copy link
Contributor

@rushtong rushtong left a comment

Choose a reason for hiding this comment

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

Looks good. I agree with Phil's suggestion about logging.

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.

4 participants