Skip to content

Commit 0f7f4f9

Browse files
committed
improve log output druing startup
1 parent 5ba3f23 commit 0f7f4f9

File tree

4 files changed

+50
-20
lines changed

4 files changed

+50
-20
lines changed

client/src/components/setup/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<v-stepper-header>
1616
<v-stepper-item
17-
title="Connect"
17+
title="Configure"
1818
value="1"
1919
></v-stepper-item>
2020

server/src/kubero.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,8 @@ export class Kubero {
944944
}
945945
}
946946
} catch (error) {
947-
console.log('Error: getSleepEnabled: ', error)
947+
console.log('❌ getSleepEnabled: could not check for Zeropod')
948+
//console.log(error)
948949
return false
949950
}
950951

server/src/modules/kubectl.ts

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,21 @@ export class Kubectl {
6565
//this.kc.loadFromDefault(); // should not be used since we want also load from base64 ENV var
6666

6767
if (process.env.KUBECONFIG_BASE64) {
68-
debug.log("Use kubectl config from base64");
6968
let buff = Buffer.from(process.env.KUBECONFIG_BASE64, 'base64');
7069
const kubeconfig = buff.toString('ascii');
7170
this.kc.loadFromString(kubeconfig);
71+
72+
debug.log("ℹ️ Kubeconfig loaded from base64");
7273
} else if(process.env.KUBECONFIG_PATH) {
73-
debug.log("Use kubectl config from file " + process.env.KUBECONFIG_PATH);
7474
this.kc.loadFromFile(process.env.KUBECONFIG_PATH);
75+
debug.log("ℹ️ Kubeconfig loaded from file " + process.env.KUBECONFIG_PATH);
7576
} else{
7677
try {
7778
this.kc.loadFromCluster();
78-
debug.log("Kubeconfig loaded from cluster");
79+
debug.log("ℹ️ Kubeconfig loaded from cluster");
7980
} catch (error) {
8081
debug.log("❌ Error loading from cluster");
81-
debug.log(error);
82+
//debug.log(error);
8283
}
8384
}
8485

@@ -95,19 +96,25 @@ export class Kubectl {
9596
this.exec = new Exec(this.kc)
9697
this.customObjectsApi = this.kc.makeApiClient(CustomObjectsApi);
9798
} catch (error) {
98-
debug.log("❌ Error creating api clients. Check kubeconfig, cluster connectivity and context");
99-
debug.log(error);
99+
console.log("❌ Error creating api clients. Check kubeconfig, cluster connectivity and context");
100+
//debug.log(error);
100101
this.kubeVersion = void 0;
101102
return;
102103
}
103104

104105
this.getKubeVersion()
105106
.then(v => {
107+
if (v && v.gitVersion) {
108+
console.log("ℹ️ Kube version: " + v.gitVersion);
109+
} else {
110+
console.log("❌ Failed to get Kubernetes version");
111+
process.env.KUBERO_SETUP = 'enabled';
112+
}
106113
this.kubeVersion = v;
107114
})
108115
.catch(error => {
109-
debug.log("❌ Error getting kube version");
110-
debug.log(error);
116+
console.log("❌ Failed to get Kubernetes version");
117+
//debug.log(error);
111118
});
112119

113120
this.getOperatorVersion()
@@ -121,7 +128,7 @@ export class Kubectl {
121128
// TODO and WARNING: This does not respect the context set by the user!
122129
try {
123130
let versionInfo = await this.versionApi.getCode()
124-
debug.debug(JSON.stringify(versionInfo.body));
131+
//debug.debug(JSON.stringify(versionInfo.body));
125132
return versionInfo.body;
126133
} catch (error) {
127134
debug.log("getKubeVersion: error getting kube version");
@@ -136,7 +143,8 @@ export class Kubectl {
136143
if (contextName) {
137144
const pods = await this.getPods(namespace, contextName)
138145
.catch(error => {
139-
debug.log("Failed to get Operator Version", error);
146+
debug.log("❌ Failed to get Operator Version");
147+
//debug.log(error);
140148
//return 'error';
141149
});
142150
if (pods) {
@@ -180,8 +188,8 @@ export class Kubectl {
180188
)
181189
return pipelines.body as IKubectlPipelineList;
182190
} catch (error) {
183-
debug.log(error);
184-
debug.log("getPipelinesList: error getting pipelines");
191+
//debug.log(error);
192+
debug.log("getPipelinesList: error getting pipelines");
185193
}
186194
const pipelines = {} as IKubectlPipelineList;
187195
pipelines.items = [];
@@ -200,7 +208,8 @@ export class Kubectl {
200208
"kuberopipelines",
201209
pipeline
202210
).catch(error => {
203-
debug.log(error);
211+
debug.log("❌ Error creating pipeline: " + pl.name);
212+
//debug.log(error);
204213
});
205214
}
206215

@@ -218,7 +227,8 @@ export class Kubectl {
218227
pl.name,
219228
pipeline
220229
).catch(error => {
221-
debug.log(error);
230+
debug.log("❌ Error updating pipeline: " + pl.name);
231+
//debug.log(error);
222232
});
223233
}
224234

@@ -246,7 +256,8 @@ export class Kubectl {
246256
"kuberopipelines",
247257
pipelineName
248258
).catch(error => {
249-
debug.log(error);
259+
//debug.log(error);
260+
debug.log("getPipeline: error getting pipeline");
250261
throw error;
251262
});
252263
if (pipeline) {
@@ -346,7 +357,7 @@ export class Kubectl {
346357
)
347358
return appslist.body as IKubectlAppList;
348359
} catch (error) {
349-
debug.log(error);
360+
//debug.log(error);
350361
debug.log("getAppsList: error getting apps");
351362
}
352363
const appslist = {} as IKubectlAppList;
@@ -412,7 +423,7 @@ export class Kubectl {
412423
//let operators = response.body as KubernetesListObject<KubernetesObject>;
413424
operators = response.body as any // TODO : fix type. This is a hacky way to get the type to work
414425
} catch (error) {
415-
debug.log(error);
426+
//debug.log(error);
416427
debug.log("error getting operators");
417428
}
418429

@@ -1077,7 +1088,7 @@ export class Kubectl {
10771088
//console.log(config.body);
10781089
return config.body;
10791090
} catch (error) {
1080-
debug.log(error);
1091+
//debug.log(error);
10811092
debug.log("getKuberoConfig: error getting config");
10821093
}
10831094
}
@@ -1306,4 +1317,20 @@ export class Kubectl {
13061317
}
13071318
}
13081319

1320+
public async createNamespace(namespace: string): Promise<any> {
1321+
const ns = {
1322+
apiVersion: 'v1',
1323+
kind: 'Namespace',
1324+
metadata: {
1325+
name: namespace
1326+
}
1327+
}
1328+
try {
1329+
return await this.coreV1Api.createNamespace(ns);
1330+
} catch (error) {
1331+
//console.log(error);
1332+
console.log('ERROR creating namespace');
1333+
}
1334+
}
1335+
13091336
}

server/src/modules/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ export class Settings {
246246
process.env.KUBERO_SETUP = "disabled"
247247

248248
this.kubectl.updateKubectlConfig(kubeConfig, kubeContext)
249+
250+
this.kubectl.createNamespace(kuberoNamespace)
249251
return {
250252
error: "",
251253
status: "ok"

0 commit comments

Comments
 (0)