Skip to content

Commit 40dcbc9

Browse files
committed
single check
1 parent 216cd33 commit 40dcbc9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Diff for: bin/cml/runner.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const shutdown = async (opts) => {
2828
noRetry,
2929
reason,
3030
destroyDelay,
31-
destroyDelayed
31+
single
3232
} = opts;
3333
const tfPath = workdir;
3434

@@ -41,7 +41,13 @@ const shutdown = async (opts) => {
4141
RUNNER && RUNNER.kill('SIGINT');
4242
winston.info('\tSuccess');
4343
} catch (err) {
44-
winston.error(`\tFailed: ${err.message}`);
44+
if (single) {
45+
winston.warn(
46+
`\tFailed: Runner in --single mode, might have cleared itself.`
47+
);
48+
} else {
49+
winston.error(`\tFailed: ${err.message}`);
50+
}
4551
}
4652
};
4753

@@ -69,10 +75,8 @@ const shutdown = async (opts) => {
6975
const destroyTerraform = async () => {
7076
if (!tfResource) return;
7177

72-
if (destroyDelayed) {
73-
winston.info(`Waiting ${destroyDelay} seconds to destroy`);
74-
await sleep(destroyDelay);
75-
}
78+
winston.info(`Waiting ${destroyDelay} seconds to destroy`);
79+
await sleep(destroyDelay);
7680

7781
try {
7882
winston.debug(await tf.destroy({ dir: tfPath }));
@@ -424,7 +428,7 @@ exports.handler = async (opts) => {
424428
try {
425429
await run(opts);
426430
} catch (error) {
427-
await shutdown({ ...opts, error, destroyDelayed: true });
431+
await shutdown({ ...opts, error });
428432
}
429433
};
430434

Diff for: src/cml.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ class CML {
339339
}
340340

341341
async unregisterRunner(opts = {}) {
342-
const { id: runnerId } = await this.runnerByName(opts);
342+
const { id: runnerId } = (await this.runnerByName(opts)) || {};
343+
if (!runnerId) throw new Error(`Runner with id ${runnerId} not found`);
344+
343345
return await getDriver(this).unregisterRunner({ runnerId, ...opts });
344346
}
345347

0 commit comments

Comments
 (0)