-
Notifications
You must be signed in to change notification settings - Fork 30
Delete OCP cluster leftovers using openshift-installer #166
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
base: master
Are you sure you want to change the base?
Conversation
a232acb to
b2bd7e6
Compare
|
@oharan2 The checks are failing in black. Please fix |
jyejare
left a comment
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.
Finishing the 1st round of review. Suggested some changes.
| is_flag=True, | ||
| help="Remove only unused OCP Cluster occupied resources from the provider", | ||
| ) | ||
| @click.option("-y", "--yes", is_flag=True, help="Answer yes to all prompts") |
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.
If we don't have choice to say no, or if we should not provide the choice, let's remove the option here.
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.
The alternative is -d, say no to all cluster deletion makes the deletion mode redundant.
In deletion mode, if not passing -y (yes to all prompts), you can go cluster by cluster and decide which one to clean up.
Therefore you're in deletion mode, but you can safely exclude some of it.
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 think the framework that Cloudwash comes up with for excluding is to have the resource in exceptions list. That means the user has to pre-choose the clusters that user dont want to delete resources from.
Can we move to exceptions mode, How that would impact your use case ?
| "DISCS": {"delete": []}, | ||
| "PIPS": {"delete": []}, | ||
| "OCPS": {"delete": []}, | ||
| "OCPS": {"delete": [], "clusters": []}, |
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.
As per the cloudwash design 'clusters' must be part of delete dict
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.
What the part that you concern will be breaking?
The clusters part is only for producing a dry run report with printing the actual ocp names that the resources are associated with.
The deletable part that is considered is individual resources and not entire clusters.
See use of generated report in the pic inside the updated PR description.
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.
Yup, Got that But again the clusters are nothing but resources, we just changing its place from independent key-value to within the standard dictionary structure.
Saying this because we will be streamlining the dry data printing in future by having its own Class and hence good to keep the standard going fwd.
|
|
||
|
|
||
| def destroy_ocp_cluster(metadata_path: str, cluster_name: str): | ||
| if metadata_path == "" or not os.path.exists(metadata_path): |
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.
You can choose to use Pathlib to play with file system.
Optional!
| # Return without raising exception, will try to fetch next OCP cluster info | ||
| logger.error(f"Failed to load cluster info from metadata path: {metadata_path}.") | ||
| else: | ||
| err_msg = f"Failed to cleanup OCP cluster {cluster_name}. Failure info:" |
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.
Define this where it's needed, it's bit confusing 😔
| logger.error(f"{err_msg}\n{ex}") | ||
|
|
||
|
|
||
| def validate_deletion_with_user_input(cluster_name) -> bool: |
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.
The user input in automated resources cleanup is almost impossible.
Would you still want to go ahead ?
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.
Correct. This is why we have to provide the cli option -y for automated cleanups, the alternative is -d (see comment above)
jyejare
left a comment
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.
Few more structural and consistency comments.
Also, Did you find the chance to run the changes on multi-clusters for multi type resources.
| is_flag=True, | ||
| help="Remove only unused OCP Cluster occupied resources from the provider", | ||
| ) | ||
| @click.option("-y", "--yes", is_flag=True, help="Answer yes to all prompts") |
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 think the framework that Cloudwash comes up with for excluding is to have the resource in exceptions list. That means the user has to pre-choose the clusters that user dont want to delete resources from.
Can we move to exceptions mode, How that would impact your use case ?
| "DISCS": {"delete": []}, | ||
| "PIPS": {"delete": []}, | ||
| "OCPS": {"delete": []}, | ||
| "OCPS": {"delete": [], "clusters": []}, |
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.
Yup, Got that But again the clusters are nothing but resources, we just changing its place from independent key-value to within the standard dictionary structure.
Saying this because we will be streamlining the dry data printing in future by having its own Class and hence good to keep the standard going fwd.
| print(f'Error: Input {user_input} unrecognised. Please try again.') | ||
|
|
||
|
|
||
| def destroy_ocp_cluster_wrapper(metadata_path: str, cluster_name: str, user_validation=False): |
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.
Docstring please, maybe for all the functions here, may be autogenerate :)
| self.client = client | ||
| self._delete = [] | ||
| def __init__(self): | ||
| self._deletable = {"ocp_clusters": [], "filtered_leftovers": []} |
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 think its good to be consistant with var names, That is self_delete = {}
| def __init__(self, client): | ||
| self.client = client | ||
| self.cleaning_region = self.client.cleaning_region | ||
| super().__init__() |
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.
Doesnt seems to be required.
Main changes:
openshift-installer, for local env check if exists--yes, -yflag to bypass prompt questions before cluster destroyingLeftoverAWSOcpclass that holds OCP cluster with all it's collected metadata and filtered resources