diff --git a/.github/spot-runner-action/dist/index.js b/.github/spot-runner-action/dist/index.js index d18edc5916a8..54dc696e1c35 100644 --- a/.github/spot-runner-action/dist/index.js +++ b/.github/spot-runner-action/dist/index.js @@ -675,7 +675,7 @@ function start() { } else if (config.subaction === "start") { // We need to terminate - yield terminate("stopped"); + yield terminate("stopped", false); } else { throw new Error("Unexpected subaction: " + config.subaction); @@ -759,7 +759,7 @@ function start() { } }); } -function terminate(instanceStatus) { +function terminate(instanceStatus, cleanupRunners = true) { return __awaiter(this, void 0, void 0, function* () { try { core.info("Starting instance cleanup"); @@ -768,13 +768,17 @@ function terminate(instanceStatus) { const ghClient = new github_1.GithubClient(config); const instances = yield ec2Client.getInstancesForTags(instanceStatus); yield ec2Client.terminateInstances(instances.map((i) => i.InstanceId)); - core.info("Clearing previously installed runners"); - const result = yield ghClient.removeRunnersWithLabels([config.githubJobId]); - if (result) { - core.info("Finished runner cleanup"); - } - else { - throw Error("Failed to cleanup runners. Continuing, but failure expected!"); + if (cleanupRunners) { + core.info("Clearing previously installed runners"); + const result = yield ghClient.removeRunnersWithLabels([ + config.githubJobId, + ]); + if (result) { + core.info("Finished runner cleanup"); + } + else { + throw Error("Failed to cleanup runners. Continuing, but failure expected!"); + } } } catch (error) { diff --git a/.github/spot-runner-action/src/main.ts b/.github/spot-runner-action/src/main.ts index 79059048ef9c..7e0320d2b5d3 100644 --- a/.github/spot-runner-action/src/main.ts +++ b/.github/spot-runner-action/src/main.ts @@ -43,7 +43,7 @@ async function start() { // then we make a fresh instance } else if (config.subaction === "start") { // We need to terminate - await terminate("stopped"); + await terminate("stopped", false); } else { throw new Error("Unexpected subaction: " + config.subaction); } @@ -139,7 +139,7 @@ async function start() { } } -async function terminate(instanceStatus?: string) { +async function terminate(instanceStatus?: string, cleanupRunners = true) { try { core.info("Starting instance cleanup"); const config = new ActionConfig(); @@ -147,14 +147,18 @@ async function terminate(instanceStatus?: string) { const ghClient = new GithubClient(config); const instances = await ec2Client.getInstancesForTags(instanceStatus); await ec2Client.terminateInstances(instances.map((i) => i.InstanceId!)); - core.info("Clearing previously installed runners"); - const result = await ghClient.removeRunnersWithLabels([config.githubJobId]); - if (result) { - core.info("Finished runner cleanup"); - } else { - throw Error( - "Failed to cleanup runners. Continuing, but failure expected!" - ); + if (cleanupRunners) { + core.info("Clearing previously installed runners"); + const result = await ghClient.removeRunnersWithLabels([ + config.githubJobId, + ]); + if (result) { + core.info("Finished runner cleanup"); + } else { + throw Error( + "Failed to cleanup runners. Continuing, but failure expected!" + ); + } } } catch (error) { core.info(error);