-
Notifications
You must be signed in to change notification settings - Fork 279
[OLD] Fix rename cluster duplicate name issue / improve cluster metadata for UI #2944
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: main
Are you sure you want to change the base?
Conversation
Backend Code coverage changed from 65.0% to 65.2%. Change: .2% 😃. Coverage report
|
280613c
to
f12841b
Compare
Backend Code coverage changed from 65.0% to 65.2%. Change: .2% 😃. Coverage report
|
f12841b
to
38a7582
Compare
Backend Code coverage changed from 65.0% to 65.2%. Change: .2% 😃. Coverage report
|
@vyncent-t can you please add How to test to the 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.
Left a couple of comments.
<Typography>{t('translation|Name')}</Typography> | ||
{displayOriginalName && ( | ||
<Typography variant="body2" color="textSecondary"> | ||
{t('translation|Original name of cluster: {{ originalName }}', { |
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.
Just Original name: ...
should be enough given the context. Reads too verbose otherwise.
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.
done!
const sourcePath = cluster.meta_data?.origin?.kubeconfig; | ||
const kubeconfigPath = process.env.KUBECONFIG ?? sourcePath; |
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 it should always be the meta_data case here. No the KUBECONFIG env.
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.
done!
return path | ||
}(), | ||
}, | ||
"originalName": context.Name, |
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 see in the /config requests from the frontend that the original name is the one being sent as the name above, so we already have the original name + custom name (in the extensions) in the frontend AFAIU.
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.
in the frontend when I log the end result of a cluster that has been fetched, if it has been renamed then the cluster.name is set to the customName
looking at the /config response looks like the top name is the original name but after its processed and finished for the the frontend the cluster log information is different
so I think we do have access to the original name as long as it is never renamed
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 need to understand what "after its processed and finished for the the frontend " means in this case.
Seems like we likely need to always keep the original name as the key (till we also add the kubeconfig path) for both the backend and frontend, and use the renamed name just for the display.
backend/cmd/headlamp.go
Outdated
path, _ := c.getKubeConfigPath(context.SourceStr()) | ||
return 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.
I think the path should be set from the methods that read the cluster in the first place rather than trying to find it again 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.
moved it so that we aren't trying to find it right inside of where it is being initialized
38a7582
to
2eed250
Compare
Backend Code coverage changed from 65.1% to 65.2%. Change: .1% 😃. Coverage report
|
108d28b
to
bdaa350
Compare
Backend Code coverage changed from 64.9% to 65.1%. Change: .2% 😃. Coverage report
|
backend/cmd/headlamp.go
Outdated
@@ -1191,6 +1191,11 @@ func (c *HeadlampConfig) getClusters() []Cluster { | |||
continue | |||
} | |||
|
|||
kubeconfigPath, err := c.getKubeConfigPath(context.SourceStr()) |
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 actual path of the kubeconfig needs to be corrected. This will always give the kubeconfig we loaded headlamp with, but if we have more than one, it's not clear this will yield the correct value. So I think that the way to add it is in the methods where we load the actual kubeconfig: we should add a reference to the file's path for each cluster.
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.
so to confirm, we find where we load the cluster information from the kube config, create a middle func that adds the file path from that kubeconfig, and attach it to the cluster information before sending it off again?
should the same be done for the original name then? and just save the name under clusterID
or something similar before sending it off?
return path | ||
}(), | ||
}, | ||
"originalName": context.Name, |
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 need to understand what "after its processed and finished for the the frontend " means in this case.
Seems like we likely need to always keep the original name as the key (till we also add the kubeconfig path) for both the backend and frontend, and use the renamed name just for the display.
bdaa350
to
935b77a
Compare
Backend Code coverage changed from 65.0% to 65.1%. Change: .1% 😃. Coverage report
|
updated the branch
|
e666e61
to
ab90e50
Compare
4b7ac0d
to
22660bd
Compare
Backend Code coverage changed from 64.9% to 65.2%. Change: .3% 😃. Coverage report
|
22660bd
to
2901cd6
Compare
Backend Code coverage changed from 64.9% to 65.2%. Change: .3% 😃. Coverage report
|
backend/pkg/kubeconfig/kubeconfig.go
Outdated
PathName string `json:"pathName"` | ||
PathID string `json:"pathID"` |
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.
Instead of path name and path ID, which are confusing, why not kubeConfigPath and ID or ClusterID?
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.
will change these to kubeConfigPath
and ClusterID
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.
done!
// note: we need to have it in a const for the linting to pass | ||
const sourceKubeconfig = "kubeconfig" |
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.
This existed already before, right? I am surprised this change is needed.
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.
This one was a weird linter issue, it wouldn't accept it in the linter as an if block so I made some adjustments to it here that satisfy the linter while also being able to use it "correctly"
2901cd6
to
cd65438
Compare
Backend Code coverage changed from 65.0% to 65.2%. Change: .2% 😃. Coverage report
|
… pathID Signed-off-by: Vincent T <[email protected]>
Signed-off-by: Vincent T <[email protected]>
…clusters Signed-off-by: Vincent T <[email protected]>
…d updates test Signed-off-by: Vincent T <[email protected]>
Changes Include SettingsCluster.tsx: - handles error logic from backend to prevent users from entering a name/custom name already in use by another cluster - introduces new confirm dialog for when users enter clashing names ConfirmDialog.tsx: - introduces optional params for disabling the Yes and No button, allowing for single option "continue" dialog clusterApi.ts: - reworks the current renameCluster function to now handle renaming for dynamic and non dynamic clusters differently Signed-off-by: Vincent T <[email protected]>
cd65438
to
edf8bd0
Compare
Backend Code coverage changed from 64.9% to 65.2%. Change: .3% 😃. Coverage report
|
Unknown CLA label state. Rechecking for CLA labels. Send feedback to sig-contributor-experience at kubernetes/community. /check-cla |
|
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This branch replaces the need for #2747
Description
This PR is needed as a part to fix the delete non dynamic cluster PR
originalName
origin.kubeconfig
andpathID
source
field in the home view to have an accurate path for kubeconfigsThis PR also fixes an issue with duplicate name clusters.
Currently, users are able to 'reuse' cluster names, causing the existing cluster to be replaced with the renamed one. This UI redirection provides a way to prevent this from happening from within headlamp only.
renameCluster
functionality in the backend to cover both non dynamic and dynamic clustersChanges include
Cluster info
cluster.metadata.origin.kubeconfig
andcluster.metadata.originalName
andcluster.metadata.pathID
Home View
Origin
now displays correct Kubeconfig pathCluster Settings
OriginalName
now displayed in non-dynamic cluster settingsHow to test
Test the source path
Test the original name label
Name
sectionTest the duplicate rename blocker UI