-
Notifications
You must be signed in to change notification settings - Fork 225
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
fix the cluster info for headlamp_info to inlcude originalName #2747
base: main
Are you sure you want to change the base?
Conversation
progress: able now to have the cluster generate a headlamp_info field when it is created and gathered via the need to fix:
|
2136402
to
6248883
Compare
Backend Code coverage changed from 63.8% to 64.4%. Change: .6% 😃. Coverage report
|
6248883
to
776c7c0
Compare
note: done
to do
|
let me know what you guys think for these changes before I move on to create some tests 😎 @knrt10 @yolossn contextThe main issue we are trying to solve is that there is currently no way to preserve the original name that a cluster has been created with, this has lead to issues with renaming / duplicate naming clusters with names that have been used already. Currently, on main if you create a cluster and rename it and then you console log the clusters that are being rendered at the home page, you will see that the "name" field populates the changed name while the kubeconfig still holds the old name The goal here is to make sure we create the |
Backend Code coverage changed from 63.8% to 64.2%. Change: .4% 😃. Coverage report
|
776c7c0
to
0acb858
Compare
note: previous push fixes logic for clusters that were renamed already (with the headlamp_info already there) to update the headlamp_info to have their original name saved also |
@vyncent-t Thank you for the PR. I am not sure what this would solve. This was the intended change. Our approach initially was we do want to change the kubeconfig name of user because if user change the name in headlamp does not mean they want to change their kubeconfig. For example if they get their clusters using kubeclt they should still see the same name. This is the reason we do not change the name field in kubeconfig, rather than we edit the headlmap_info extension in the metadata. So when user renames the cluster only that thing is changed. Regarding clusters that use the same name. That I think should not be possible because we automatically throw an error if there are same context name. Also, if there are same name in kubeconfig that is automatically rejected by kubectl as well |
@knrt10 thanks for getting back to me 😎 allow me to clarify a few things and feel free to let me know if we should sync up to cover this This PR is a prerequisite for continuing the progress of the delete non dynamic clusters PR that you had reviewed for me earlier (along with two other issues that stem from this that I will explain later). In the delete non dynamic clusters PR's current state, the delete function needs a name in which to find and delete that cluster, however for clusters that have been renamed, that new customName is what is being being used in the app and thus when we go to delete that cluster on the app the customName is what is being passed into the delete function. The goal of this PR is to expand the This PR does not change the existing main data of a kubeconfig context, it only creates the I will include more information about what this PR does and how to test it in the description As for the clusters using the same name and renaming- I am also working on two issues that spawn from the current name handling for clusters. Currently we are able to create a cluster and rename it to the name of another cluster, causing the renamed cluster link to 'consume' the og cluster link. There is also the issue of creating a cluster with the og name of an older renamed cluster causing duplicate links. These were able to be done through renaming use and no errors stop this. I am also working on fixes for both of these but they too require this TLDR: I have been tasked with expanding the |
Thank you for explaining. It makes sense now. Will review it now. |
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.
Some suggestions.
0acb858
to
24f7a6b
Compare
Backend Code coverage changed from 63.8% to 64.0%. Change: .2% 😃. Coverage report
|
24f7a6b
to
7c1a4aa
Compare
Backend Code coverage changed from 64.8% to 64.9%. Change: .1% 😃. Coverage report
|
7c1a4aa
to
8724036
Compare
@knrt10 made some changes from what you suggested and also added a test, I am using a mock env approach that seems to work when its ran at the end of the test, still new to tests so let me know what you think! I was also thinking of maybe using the format that you have for the TestRenameCluster if what I have here isn't the best way |
Backend Code coverage changed from 64.7% to 64.9%. Change: .2% 😃. Coverage report
|
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.
Thanks for the changes, added some suggestions
backend/pkg/kubeconfig/kubeconfig.go
Outdated
@@ -56,9 +57,14 @@ type OidcConfig struct { | |||
|
|||
// CustomObject represents the custom object that holds the HeadlampInfo regarding custom name. | |||
type CustomObject struct { | |||
// ??? |
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.
?? hehe, nice 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.
Oh! I forgot about these, I meant to ask if you could provide context here on what these params are/do?
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.
// ??? | |
type CustomObject struct { | |
// TypeMeta describes the type of the object and its API schema version. | |
// It should have "Kind" set to "HeadlampInfo" and "APIVersion" set to "v1". | |
// +k8s:deepcopy-gen=false | |
metav1.TypeMeta | |
// ObjectMeta contains metadata about the custom object, such as name and labels. | |
// This is used to store additional metadata about the headlamp_info extension. | |
// +optional |
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.
Still not updated here.
8724036
to
5b62830
Compare
Backend Code coverage changed from 64.7% to 64.9%. Change: .2% 😃. Coverage report
|
3e09a73
to
1d0edcf
Compare
Backend Code coverage changed from 64.8% to 65.5%. Change: .7% 😃. Coverage report
|
1d0edcf
to
830a93e
Compare
Backend Code coverage changed from 65.0% to 65.5%. Change: .5% 😃. Coverage report
|
830a93e
to
9593a65
Compare
Backend Code coverage changed from 65.0% to 65.5%. Change: .5% 😃. Coverage report
|
9593a65
to
87b0859
Compare
rebased to main
|
Backend Code coverage changed from 65.0% to 65.6%. Change: .6% 😃. Coverage report
|
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 am not sure why we need these changes, especially if they are to accommodate stateless clusters, which shouldn't need the headlamp_info extension.
backend/cmd/headlamp.go
Outdated
) | ||
|
||
/* handler to keep the original name for a cluster.*/ | ||
//nolint:lll |
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.
Can you avoid this?
@@ -1136,6 +1142,72 @@ func (c *HeadlampConfig) getClusters() []Cluster { | |||
return clusters | |||
} | |||
|
|||
// handleHeadlampInfo this function handles the clusters that need to have headlamp_info created or updated. |
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 don't understand exactly what this is doing from this comment. What does "handles the clusters" mean?
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 am a bit confused as to what exactly this patch is trying to achieve and why.
backend/pkg/kubeconfig/kubeconfig.go
Outdated
@@ -56,9 +57,14 @@ type OidcConfig struct { | |||
|
|||
// CustomObject represents the custom object that holds the HeadlampInfo regarding custom name. | |||
type CustomObject struct { | |||
// ??? |
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.
Still not updated here.
backend/pkg/kubeconfig/kubeconfig.go
Outdated
metav1.TypeMeta | ||
// ??? |
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.
And here.
backend/pkg/kubeconfig/kubeconfig.go
Outdated
// ??? | ||
// TypeMeta describes the type of the object and its API schema version. | ||
// It should have "Kind" set to "HeadlampInfo" and "APIVersion" set to "v1". | ||
// +k8s:deepcopy-gen=false | ||
metav1.TypeMeta | ||
// ??? | ||
// ObjectMeta contains metadata about the custom object, such as name and labels. | ||
// This is used to store additional metadata about the headlamp_info extension. | ||
// +optional |
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.
Doesn't belong to this commit.
async function handleDynamicClusterName(cluster: string) { | ||
findKubeconfigByClusterName(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.
Why do we need to have a handleDynamicClusterName function wrapping the new one? (and in general "handle*" is not a great name unless it's for something that's just a response, e.g. handleConfigRouteRequest
).
frontend/src/stateless/index.ts
Outdated
const contextToUpdate = matchingKubeconfig || matchingContext; | ||
const extensions = contextToUpdate?.context.extensions || []; | ||
let headlampExtension = extensions.find( | ||
extension => extension.name === 'headlamp_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.
Why do stateless clusters need the headlamp_info
extension? This extension's purpose was to avoid modifying the cluster name of clusters coming from "external" (to headlamp) kubeconfigs, and we were even talking the other day about whether we should even do this at all for those. But for anything that "belongs" or is defined in Headlamp, like stateless clusters, we should just change the actual context name when the user chooses to update it.
6011ae2
to
5157118
Compare
NOTE:
|
4efd536
to
5fd0090
Compare
|
ddbd526
to
e3158e1
Compare
…nfo on getClusters calls Signed-off-by: Vincent T <[email protected]>
Signed-off-by: Vincent T <[email protected]>
Signed-off-by: Vincent T <[email protected]>
e3158e1
to
e5ac4c5
Compare
Backend Code coverage changed from 65.0% to 65.2%. Change: .2% 😃. Coverage report
|
Fixes issue #2750
Description
This PR aims to expands the current implementation of the
headlamp_info
extension that is created to provide additional information about a cluster within the kubeconfig.Changes
headlamp_info
extension is now created at the home view of the app (it used to only be created if we rename a cluster)headlamp_info
extension now includes a field for storing the original name of a clusteroriginalName
headlamp_info
is now updated to include theoriginalName
field and correct valheadlamp_info
field for future cluster renaming by introducing thecustomName
field along withoriginalName
How to test
headlamp_info
field andoriginalName
field containing the clusters nameContext notes:
Non dynamic clusters