-
Notifications
You must be signed in to change notification settings - Fork 1
Add scheduled repair.deletion #43
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
Changes from 3 commits
f61e9db
a66e646
1d2019e
5e0f702
09673e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,35 +15,28 @@ def __init__(self, axonops, args): | |
| self.full_repair_url = f"{self.repair_url}/{args.org}/cassandra/{args.cluster}" | ||
| self.full_cassandrascheduledrepair_url = f"{self.cassandrascheduledrepair_url}/{args.org}/cassandra/{args.cluster}" | ||
|
|
||
| def remove_old_repairs_from_axonops(self): | ||
| """ Check if the scheduled repair already exists in AxonOps, if so, remove it. """ | ||
| def remove_all_repairs_from_axonops(self): | ||
| """ Remove all scheduled repairs from AxonOps. """ | ||
| if self.args.v: | ||
| print("Checking if scheduled repair already exists") | ||
| print("Removing all scheduled repairs") | ||
|
|
||
| if self.args.tags != "": | ||
| response = self.axonops.do_request( | ||
| url=self.full_repair_url, | ||
| method='GET', | ||
| ) | ||
| if not response: | ||
| if self.args.v: | ||
| print("Getting scheduled repair with tag:", self.args.tags) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was never done since GET doesn't support filtering by tags.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point |
||
| response = self.axonops.do_request( | ||
| url=self.full_repair_url, | ||
| method='GET', | ||
| ) | ||
| if not response: | ||
| print("No response received when checking for existing scheduled repair") | ||
| return | ||
| elif 'ScheduledRepairs' in response and response['ScheduledRepairs']: | ||
| for repair in response['ScheduledRepairs']: | ||
| if self.args.v: | ||
| print("No response received when checking for existing scheduled repair") | ||
| return | ||
| elif 'ScheduledRepairs' in response and response['ScheduledRepairs']: | ||
| for repair in response['ScheduledRepairs']: | ||
| if self.args.v: | ||
| print(f"Checking scheduled repair: {repair['ID']}") | ||
| self.remove_repair(repair['ID']) | ||
| if 'Params' in repair: | ||
| print(repair['Params']) | ||
|
|
||
| else: | ||
| print("Repair tag not found, this will be threaded as a new scheduled repair") | ||
| print(f"Deleting scheduled repair: {repair['ID']}") | ||
| self.remove_repair(repair['ID']) | ||
| if 'Params' in repair: | ||
| print(repair['Params']) | ||
| else: | ||
| if self.args.v: | ||
| print("No tag provided, this will be threaded as a new scheduled repair") | ||
| print("No scheduled repairs found") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could have found adaptive repairs, but we're not looking at those.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, only the scheduled is needed here |
||
|
|
||
| def set_options(self): | ||
| """Apply optional CLI parameters into the payload before sending it.""" | ||
|
|
@@ -101,8 +94,30 @@ def set_repair(self): | |
| print("POST", self.full_add_repair_url, self.repair_data) | ||
|
|
||
| if self.args.delete: | ||
|
||
| if self.args.v: | ||
| print("This scheduled repair is delete, not sending to AxonOps") | ||
| if self.args.tags != "": | ||
| response = self.axonops.do_request( | ||
| url=self.full_repair_url, | ||
| method='GET', | ||
| ) | ||
| if not response: | ||
| if self.args.v: | ||
| print("No response received when checking for existing scheduled repair") | ||
| return | ||
| elif 'ScheduledRepairs' in response and response['ScheduledRepairs']: | ||
| for repair in response['ScheduledRepairs']: | ||
| if self.args.tags != repair['Params'][0]['tag']: | ||
| continue | ||
|
||
| if self.args.v: | ||
| print(f"Deleting scheduled repair: {repair['ID']}") | ||
| self.remove_repair(repair['ID']) | ||
| if 'Params' in repair: | ||
| print(repair['Params']) | ||
| else: | ||
| print("No scheduled repairs found") | ||
| else: | ||
| if self.args.v: | ||
| print("Tags are always required for deletions") | ||
| raise | ||
|
||
| return | ||
|
|
||
| self.axonops.do_request( | ||
|
|
||
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.
I liked this functionality, especially for testing purposes, but if we were creating one scheduled repair at a time, we would always delete all previously scheduled repairs. Instead, I put it behind a parameter flag.
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.
That looks very good