-
Notifications
You must be signed in to change notification settings - Fork 9
Add support for using cluster name for the delete cluster command #509
Conversation
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.
Cool!
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.
See my comment on the name ambiguity edge case. Might need a bit of UX consideration in how we present that message.
Like the coolest would be to offer some kind of picker that is like
Found more than one cluster called "My Cluster", please type the id of the cluster that you would like to delete:
CLUSTER ID ORGANIZATION NAME
123ab testing My Cluster
456cd production My Cluster
But if that needs more UX consideration, then for now just failing and asking the user to use a cluster ID instead would be ok with me.
I like that, I'll try to implement it |
So my understanding is we basically have to list clusters (read:
whether In installations with many organizations and clusters we see this taking several seconds (in one case, more than 5). So every command would get delayed by that duration. To me, that is too much of a downside. What are other ways we can think of? Some ideas:
|
Yes, we do fetch all clusters in every command. I believe caching wouldn't be an ideal solution, especially if we encounter situations like this:
Also, would it make sense to have a |
The caching idea was not about caching cluster names. Rather only cache cluster IDs we really got from the API. So every hit on that cache could be considered a valid cluster ID that at least has existed at some point. |
Oh I get it now, so we'll cache the cluster IDs, so if we provided an ID, it would check the cache and if it's there, it would not make the API call. That sounds good, I can start on that |
I added support for name collisions, which also prints a table with the colliding clusters, and then you can enter the ID of the cluster that you want to use. Updated the description with the preview. Next: Adding the ID cache |
Also added caching and unit tests for caching. Right now, cluster IDs are saved in the cache for every |
After I opened the |
I haven't looked at everything yet, so might have missed it. One more questions regarding the cluster cache: Does the cache ever expire? Would cluster IDs get re-fetched when the cache is older than a certain duration? One thing to keep in mind is that the cache is not endpoint/installation specific. So what is a valid ID in one installation might not be one in another. But with cluster IDs as random as they are, I don't see that as a problem. |
Thank you for the thorough review, @marians . I really appreciate the suggestions you've made. I didn't take into consideration expiry dates and endpoint-specific IDs, but I think it may be worth switching to a YAML structure to introduce those, to make it adding other functionality easier to do in the future |
- Save cache as YAML - Implement separate cluster ID caches per endpoint - Implement expiration for each endpoint cluster IDs
Updated the description with a preview of the file |
Nitpick: Some people in the company will be much happier to find sentences in comments ending in a full stop. Do as you wish. |
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.
We spoke about a little UX improvement to be made when the name is ambiguous.
Besides that, great work! ❤️
Updated the description with the preview |
Towards https://github.com/giantswarm/gsctl/issues/188
At the moment, this only provides support for the delete cluster command
ClusterIDMissing
errors toClusterNameOrIDMissing
When a cluster is deleted, the confirmation will state the name/ID provided by the user. So if the user provided an ID, the confirmation will show the ID; or a name, if he provided a name.
Preview
Deleting a cluster with the name

Deleting a cluster with the ID

Trying to delete a cluster with an ID/name that doesn't exist

Trying to delete a cluster that has the same name as another existing one

Saving cluster IDs in the cache file (

~/.config/gsctl/clustercache.yaml
)As a side note, this only includes the
delete cluster
command, because I want to know that my implementation is right, before copying and pasting it to the other commands.Also, I would like to do 1-2 commands per PR, to keep them small, so we could prevent any unwanted bugs.