From ef5d9b9dfa952eedf2e1ead76cd18a09b5bc86be Mon Sep 17 00:00:00 2001 From: 0x2b3bfa0 <0x2b3bfa0+git@googlemail.com> Date: Sat, 6 Mar 2021 13:42:36 +0100 Subject: [PATCH] Add destroy timeout feature --- bin/cml-runner.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/cml-runner.js b/bin/cml-runner.js index ce95ce5ae..995bdb9d9 100755 --- a/bin/cml-runner.js +++ b/bin/cml-runner.js @@ -7,7 +7,7 @@ const fs = require('fs').promises; const yargs = require('yargs'); const decamelize = require('decamelize-keys'); -const { exec, randid } = require('../src/utils'); +const { exec, randid, sleep } = require('../src/utils'); const tf = require('../src/terraform'); const CML = require('../src/cml'); @@ -18,6 +18,7 @@ const { RUNNER_PATH = `${WORKDIR_BASE}/${NAME}`, RUNNER_IDLE_TIMEOUT = 5 * 60, + RUNNER_DESTROY_DELAY = 30, RUNNER_LABELS = 'cml', RUNNER_NAME = NAME, RUNNER_SINGLE = false, @@ -92,6 +93,11 @@ const shutdown = async (opts) => { } }; + console.log( + `\tDestroy scheduled: ${RUNNER_DESTROY_DELAY} seconds remaining.` + ); + await sleep(RUNNER_DESTROY_DELAY); + if (cloud) { await destroy_terraform(); } else {