Skip to content
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 KubernetesClusters overriding entity names too often #3524

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/main/cluster-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ export class ClusterManager extends Singleton {
};
entity.metadata.distro = cluster.distribution;
entity.metadata.kubeVersion = cluster.version;
entity.metadata.name = cluster.name;

if (cluster.preferences?.clusterName) {
/**
* Only set the name if the it is overriden in preferences. If it isn't
* set then the name of the entity has been explicitly set by its source
*/
entity.metadata.name = cluster.preferences.clusterName;
}

entity.spec.metrics ||= { source: "local" };

if (entity.spec.metrics.source === "local") {
Expand Down Expand Up @@ -164,14 +172,15 @@ export class ClusterManager extends Singleton {

if (!cluster) {
try {
/**
* Add the bare minimum of data to ClusterStore. And especially no
* preferences, as those might be configured by the entity's source
*/
this.store.addCluster({
id: entity.metadata.uid,
preferences: {
clusterName: entity.metadata.name
},
kubeConfigPath: entity.spec.kubeconfigPath,
contextName: entity.spec.kubeconfigContext,
accessibleNamespaces: entity.spec.accessibleNamespaces
accessibleNamespaces: entity.spec.accessibleNamespaces ?? [],
});
} catch (error) {
if (error.code === "ENOENT" && error.path === entity.spec.kubeconfigPath) {
Expand Down