refactoring & fixes

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2020-07-29 14:57:27 +03:00
1 parent 2054f38d08
commit 3a115ae485
6 files changed
+80 -43

No files matched your search

+17 -9
View File
@@ -153,10 +153,8 @@ export class Cluster implements ClusterModel {
@action
async refresh() {
logger.info(`[CLUSTER]: refreshing status`, this.getMeta());
const connectionStatus = await this.getConnectionStatus();
this.online = connectionStatus > ClusterStatus.Offline;
this.accessible = connectionStatus == ClusterStatus.AccessGranted;
logger.info(`[CLUSTER]: refresh`, this.getMeta());
await this.refreshConnectionStatus();
if (this.accessible) {
this.kubeCtl = new Kubectl(this.version)
this.distribution = this.detectKubernetesDistribution(this.version)
@@ -169,11 +167,18 @@ export class Cluster implements ClusterModel {
this.features = features;
this.isAdmin = isAdmin;
this.nodes = nodesCount;
await Promise.all([
this.refreshEvents(),
this.refreshAllowedResources(),
]);
}
await Promise.all([
this.refreshEvents(),
this.refreshAllowedResources(),
]);
}
@action
async refreshConnectionStatus() {
const connectionStatus = await this.getConnectionStatus();
this.online = connectionStatus > ClusterStatus.Offline;
this.accessible = connectionStatus == ClusterStatus.AccessGranted;
}
@action
@@ -219,7 +224,7 @@ export class Cluster implements ClusterModel {
const apiUrl = this.kubeProxyUrl + path;
return request(apiUrl, {
json: true,
timeout: 10000,
timeout: 5000,
headers: {
...(options.headers || {}),
Host: new URL(this.webContentUrl).host,
@@ -442,6 +447,9 @@ export class Cluster implements ClusterModel {
{ resource: "storageclasses", group: "storage.k8s.io" },
]
try {
if (!this.allowedNamespaces.length) {
return [];
}
const resourceAccessStatuses = await Promise.all(
apiResources.map(apiResource => this.canI({
resource: apiResource.resource,
+2 -2
View File
@@ -5,7 +5,7 @@ import type { Cluster } from "./cluster"
import { bundledKubectl, Kubectl } from "./kubectl"
import logger from "./logger"
export interface KubeAuthProxyResponse {
export interface KubeAuthProxyLog {
data: string;
error?: boolean; // stream=stderr
}
@@ -80,7 +80,7 @@ export class KubeAuthProxy {
return errorMsg
}
protected async sendIpcLogMessage(res: KubeAuthProxyResponse) {
protected async sendIpcLogMessage(res: KubeAuthProxyLog) {
const channel = `kube-auth:${this.cluster.id}`
logger.info(`[KUBE-AUTH]: out-channel "${channel}"`, { ...res, meta: this.cluster.getMeta() });
broadcastIpc({