Skip to content

Commit 26edb09

Browse files
committed
Add logs to trace missing exit code
1 parent 535f32b commit 26edb09

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

packages/adapters/src/kubernetes-instance-adapter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ IComponent {
228228
this.logger.error("Trying to stop non existent runner", this._runnerName);
229229
} else {
230230
await this.timeout(ms);
231-
await this.kubeClient.deletePod(this._runnerName, 2);
231+
await this.kubeClient.deletePod(this._runnerName, 2)
232+
.catch(e => {
233+
this.logger.error("Error deleting pod", this._runnerName);
234+
});
232235

233236
this._runnerName = undefined;
234237
}

packages/cli/src/lib/config/profileConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class ProfileConfig extends ConfigFileDefault<ProfileConfigEntity
3232
return this.setEntry("apiUrl", normalizeUrl(apiUrl));
3333
}
3434
setMiddlewareApiUrl(middlewareApiUrl: string): boolean {
35-
return this.setEntry("middlewareApiUrl", normalizeUrl(middlewareApiUrl)) as boolean;
35+
return this.setEntry("middlewareApiUrl", normalizeUrl(middlewareApiUrl));
3636
}
3737
setEnv(env: configEnv): boolean {
3838
return this.setEntry("env", env);

packages/host/src/lib/csi-controller.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,23 @@ export class CSIController extends TypedEmitter<Events> {
253253
try {
254254
const stopResult = await this.instanceStopped();
255255

256+
this.logger.debug("Stop result", stopResult);
257+
256258
if (stopResult) {
257-
code = stopResult.exitcode;
259+
code = stopResult.exitcode || code;
258260
this.logger.trace("Instance ended with code", code);
259261
this.status = stopResult.status;
260262
this.setExitInfo(code, stopResult.message);
263+
264+
this.logger.debug("Exit info", this.terminated);
261265
}
262266
} catch (e: any) {
263267
code = e.exitcode;
268+
264269
this.status = e.status || InstanceStatus.ERRORED;
265270
this.setExitInfo(code, e.reason);
266271

267-
this.logger.error("Instance caused error", e.message, code);
272+
this.logger.error("Instance caused error", e);
268273
} finally {
269274
clearInterval(interval);
270275
}
@@ -274,7 +279,7 @@ export class CSIController extends TypedEmitter<Events> {
274279

275280
this.emit("terminated", code);
276281

277-
this.logger.trace("Finalizing...");
282+
this.logger.trace("Finalizing...", code);
278283

279284
await this.finalize();
280285

@@ -299,7 +304,7 @@ export class CSIController extends TypedEmitter<Events> {
299304

300305
const exitcode = await this.endOfSequence;
301306

302-
this.logger.trace("End of sequence");
307+
this.logger.trace("End of sequence", exitcode);
303308

304309
if (exitcode > 0) {
305310
this.status = InstanceStatus.ERRORED;
@@ -320,7 +325,10 @@ export class CSIController extends TypedEmitter<Events> {
320325
};
321326

322327
this.instancePromise = instanceMain()
323-
.then((exitcode) => mapRunnerExitCode(exitcode, this.sequence))
328+
.then((exitcode) => {
329+
this.logger.debug("instanceMain ExitCode", exitcode);
330+
return mapRunnerExitCode(exitcode, this.sequence);
331+
})
324332
.catch((error) => {
325333
this.logger.error("Instance promise rejected", error);
326334
this.initResolver?.rej(error);
@@ -373,6 +381,8 @@ export class CSIController extends TypedEmitter<Events> {
373381
}
374382

375383
instanceStopped(): CSIController["instancePromise"] {
384+
this.logger.debug("function InstanceStopped called");
385+
376386
if (!this.instancePromise) {
377387
throw new CSIControllerError("UNATTACHED_STREAMS");
378388
}
@@ -766,6 +776,8 @@ export class CSIController extends TypedEmitter<Events> {
766776
async kill(opts = { removeImmediately: false }) {
767777
if (this.status === InstanceStatus.KILLING) {
768778
await this.instanceAdapter.remove();
779+
780+
return;
769781
}
770782

771783
this.status = InstanceStatus.KILLING;

packages/host/src/lib/csi-dispatcher.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ export class CSIDispatcher extends TypedEmitter<Events> {
182182

183183
delete this.instanceStore[csiController.id];
184184
})
185-
.once("terminated", (code) => {
185+
.on("terminated", (code) => {
186+
this.logger.debug("Terminated event received", code);
187+
186188
if (csiController.requires && csiController.requires !== "") {
187189
(this.serviceDiscovery.getData({
188190
topic: new TopicId(csiController.requires),

packages/host/src/lib/host.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,14 @@ export class Host implements IComponent {
393393
* @param {DispatcherInstanceTerminatedEventData} eventData Event details.
394394
*/
395395
async handleDispatcherTerminatedEvent(eventData: DispatcherInstanceTerminatedEventData) {
396+
this.logger.debug("handleDispatcherTerminatedEvent", eventData);
397+
396398
this.auditor.auditInstance(eventData.id, InstanceMessageCode.INSTANCE_TERMINATED);
397399

398400
this.pushTelemetry("Instance terminated", {
399401
executionTime: eventData.info.executionTime.toString(),
400402
id: eventData.id,
401-
code: eventData.code.toString(),
403+
code: (eventData.code || -2).toString(),
402404
seqId: eventData.sequence.id
403405
});
404406
}

0 commit comments

Comments
 (0)