-
Notifications
You must be signed in to change notification settings - Fork 160
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
frontend: Details: Make multi cluster aware #2520
base: main
Are you sure you want to change the base?
Conversation
This is because in multi cluster mode the "cluster" that is used is not the correct one (it is all of them). Signed-off-by: René Dudfield <[email protected]>
Also add some documentation and a return type for the function. Signed-off-by: René Dudfield <[email protected]>
This allows links to Details views to have the cluster from where the resource lives in when in multi cluster mode. This allows the URL to contain the multiple clusters and for the URL to still know which of the multiple clusters to look. Signed-off-by: René Dudfield <[email protected]>
From the ?cluster= in a URL search paramater. Signed-off-by: René Dudfield <[email protected]>
This is so that in multi cluster mode the URL can keep the group of clusters in the URL, but the details still know which cluster to use for fetching details. Signed-off-by: René Dudfield <[email protected]>
Please look into this branch, since I think I had also added a way to llink to resources details without having to create a new URL query param: |
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 (haven't double checked) that in https://github.com/headlamp-k8s/headlamp/tree/aggregated-view-original-rebased , I had computed the route directly from the resource in ResourceLink, thus using the known URLs without a cluster param.
The problem with only relying on this is that:
This PR makes these things work. |
I see, and it's a good idea to keep the group context. But for that, I think it makes more sense to do it the other way around: keep the URL for the details view matching the normal details URL (i.e. /c/SINGLE_CLUSTER/resource-kind/my-resource) and use the query param for a group association: |
All other links would then need to special case where I don't think your proposal makes sense. Because why would we change the URL to Edit: With that proposal clicking on a detail view would update all the links in the navigation. With this way none of the other components need to rerender. Unless I’m misunderstanding something?
But they are two different views. There are other things being displayed than just the resource details. Every thing else related to the clusters is different. |
* | ||
* @returns the cluster name from the URL. If no cluster is defined in the URL, undefined is returned. | ||
*/ | ||
export function useClusterFromURLVar(): string | undefined { |
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 we should be very explicit about what this means, because we already have a cluster 'variable' in the url /c/cluster/. To disambiguate I think this should be named something like useClusterFromQueryParam
of course if the approach of storing single cluster in query params stays, I only just saw discussion above
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 do you mean, never mind?
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 was thinking “query” is maybe overloaded with react query stuff. But maybe it’s ok.
useClusterFromSearchParam is also not quite right making it sound like it’s from a search.
useClusterFromURLQuery?
useURLQueryCluster?
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.
well there's a separate discussion about the url format, so this comment may not be relevant, let me rephrase it better
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.
useURLQueryCluster sounds good
hm or maybe an approach of naming it for what it is instead of where it's stored, something like useDetailsSingleCluster
?
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.
Yeah maybe useDetailsSingleCluster is the least misdirecting/confusing.
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.
well there's a separate discussion about the url format, so this comment may not be relevant, let me rephrase it better
Can you please let us know which proposal you’d prefer and why?
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.
posted it in a separate comment
URL is supposed to be a unique resource identifier with the previous multi cluster changes we already changed the meaning of the /c/cluster/ param, it now represents all the selected clusters and not the cluster of a given resource. so now we need to store information about a given resource cluster: we could repurpose the we could put it in the query params a logical solution would be to introduce a new param in the url, like but this kind of solution seems like a big breaking change. so I think doing |
Adding How is it a breaking change though? Edit:
Considering that.. I'm leaning towards ?cluster... but if we can't come to a consensus, and someone asks I can try to implement one of the other ways. eg. |
Detail links from current version wouldn't work in new version (if that is something we're concerned about) |
I guess we can keep the previous route? So it will keep working as well.
One other con against ?cluster is that if you remove it the URL is broken.
So yeah... for these reasons I think it's worth trying out:
What do you think? If you both agree I'll try it. cc @joaquimrocha |
This makes Details views work with multiple cluster.
The ?cluster is passed via a URL query parameter. Because in the normal cluster part of the URL is the group of clusters, and the details view needs to know which of the clusters the resource is in.
Here you can see details views being clicked on and the work (even though multiple clusters are active).
multi-cluster-small.mp4