Add scheduled repair.deletion#43
Conversation
| scheduled_repair.remove_old_repairs_from_axonops() | ||
| if args.deleteall: | ||
| scheduled_repair.remove_all_repairs_from_axonops() | ||
| return |
There was a problem hiding this comment.
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.
| ) | ||
| if not response: | ||
| if self.args.v: | ||
| print("Getting scheduled repair with tag:", self.args.tags) |
There was a problem hiding this comment.
This was never done since GET doesn't support filtering by tags.
| else: | ||
| if self.args.v: | ||
| print("No tag provided, this will be threaded as a new scheduled repair") | ||
| print("No scheduled repairs found") |
There was a problem hiding this comment.
We could have found adaptive repairs, but we're not looking at those.
There was a problem hiding this comment.
yes, only the scheduled is needed here
| elif 'ScheduledRepairs' in response and response['ScheduledRepairs']: | ||
| for repair in response['ScheduledRepairs']: | ||
| if self.args.tags != repair['Params'][0]['tag']: | ||
| continue |
There was a problem hiding this comment.
We filter out here to delete one tagged schedule repair at a time.
There was a problem hiding this comment.
Testing scheduled repair mixed with tags and without. I had an error while deleting a tag:
$ pipenv run python axonops.py -v scheduledrepair --delete --tags asd
[...]
File "/home/marionugnes/git/axonops-ansible-collection/cli/axonopscli/application.py", line 218, in run_scheduled_repair
scheduled_repair.set_repair()
File "/home/marionugnes/git/axonops-ansible-collection/cli/axonopscli/components/scheduled_repair.py", line 108, in set_repair
if self.args.tags != repair['Params'][0]['tag']:
~~~~~~~~~~~~~~~~~~~^^^^^^^
KeyError: 'tag'
I added a little if to check this case.
| else: | ||
| if self.args.v: | ||
| print("Tags are always required for deletions") | ||
| raise |
There was a problem hiding this comment.
Double check what our parser logic does.
| @@ -101,8 +94,30 @@ def set_repair(self): | |||
| print("POST", self.full_add_repair_url, self.repair_data) | |||
|
|
|||
| if self.args.delete: | |||
There was a problem hiding this comment.
We lost the ability to modify only a schedule with the same tag, instead of creating two separate schedules. Seeing if I can fix it
Fix a few issues with #42.
If everything looks good, please merge this into #42 , then squash #42 into master, and update the client.