1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Log cluster model if adding a cluster fails when syncing from catalog (#4463)

This commit is contained in:
Sebastian Malton 2021-12-01 08:08:48 -05:00 committed by GitHub
parent 4257fce2f0
commit 80eeffc229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,22 +182,24 @@ export class ClusterManager extends Singleton {
const cluster = this.store.getById(entity.metadata.uid);
if (!cluster) {
const model = {
id: entity.metadata.uid,
kubeConfigPath: entity.spec.kubeconfigPath,
contextName: entity.spec.kubeconfigContext,
accessibleNamespaces: entity.spec.accessibleNamespaces ?? [],
};
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,
kubeConfigPath: entity.spec.kubeconfigPath,
contextName: entity.spec.kubeconfigContext,
accessibleNamespaces: entity.spec.accessibleNamespaces ?? [],
});
this.store.addCluster(model);
} catch (error) {
if (error.code === "ENOENT" && error.path === entity.spec.kubeconfigPath) {
logger.warn(`${logPrefix} kubeconfig file disappeared`, { path: entity.spec.kubeconfigPath });
logger.warn(`${logPrefix} kubeconfig file disappeared`, model);
} else {
logger.error(`${logPrefix} failed to add cluster: ${error}`);
logger.error(`${logPrefix} failed to add cluster: ${error}`, model);
}
}
} else {