From 0749ac94b21ebdb6c4ea6055e8534fec8d7957ee Mon Sep 17 00:00:00 2001 From: DavidGOrtega Date: Wed, 28 Oct 2020 17:25:08 +0100 Subject: [PATCH] Cml cloud runner destroy one (#316) * [wip] CML contexts * octokit on demand * token * clean env before tests * print env * yaml * yaml * yaml * yaml * check * fix repo env * fix repo env * fix repo env * fix repo env * check name * env github tests * env github tests * log check * log check * no check tessts * enviromental tests * workflow eenv * gitlab uploads and github_token * snapshots * Cml contexts (#314) * token * clean env before tests * print env * yaml * yaml * yaml * yaml * check * fix repo env * fix repo env * fix repo env * fix repo env * check name * env github tests * env github tests * log check * log check * no check tessts * enviromental tests * workflow eenv * gitlab uploads and github_token * snapshots * docker entrypooint * docker entrypoint register_runner * update templates * token repo * token repo * specify driver * log env * log env * Destroy one tf resource * update also github.context * Cml contexts sha fix (#315) * token * clean env before tests * print env * yaml * yaml * yaml * yaml * check * fix repo env * fix repo env * fix repo env * fix repo env * check name * env github tests * env github tests * log check * log check * no check tessts * enviromental tests * workflow eenv * gitlab uploads and github_token * snapshots * log env * log env * update also github.context * No log * point to iterative repos * point to iterative repos without slash * point to iterative ai * test slash * test slash * fix strip * removal of strip * refactor * slash * minor refactor * no console * Cml contexts sha (#326) * git sha * commit_sha * log * log gh sha * log gh sha * show origin * remote as repo * remote as repo * tests * remove one test not working on gitlab * space * publish backend * no banckend in publish --- bin/cml-cloud-runner-entrypoint.js | 6 +++++- bin/cml-cloud-runner.js | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/cml-cloud-runner-entrypoint.js b/bin/cml-cloud-runner-entrypoint.js index 9640f9540..a07d305b0 100755 --- a/bin/cml-cloud-runner-entrypoint.js +++ b/bin/cml-cloud-runner-entrypoint.js @@ -15,6 +15,7 @@ const { RUNNER_EXECUTOR = 'shell', RUNNER_RUNTIME = '', RUNNER_IMAGE = 'dvcorg/cml:latest', + RUNNER_TF_NAME, RUNNER_DRIVER, RUNNER_REPO, @@ -49,8 +50,11 @@ const shutdown_host = async () => { try { console.log('Terraform destroy...'); try { + const tf_resource = RUNNER_TF_NAME ? `-target=${RUNNER_TF_NAME}` : ''; console.log( - await exec('cd / && terraform init && terraform destroy -auto-approve') + await exec( + `cd / && terraform init && terraform destroy -auto-approve ${tf_resource}` + ) ); } catch (err) { console.log(`Failed destroying terraform: ${err.message}`); diff --git a/bin/cml-cloud-runner.js b/bin/cml-cloud-runner.js index 73a3819b3..85bb76a41 100644 --- a/bin/cml-cloud-runner.js +++ b/bin/cml-cloud-runner.js @@ -108,6 +108,7 @@ const setup_runners = async (opts) => { -e AWS_ACCESS_KEY_ID=${process.env.AWS_ACCESS_KEY_ID} \ -v $(pwd)/terraform.tfstate:/terraform.tfstate \ -v $(pwd)/main.tf:/main.tf \ + -e "RUNNER_TF_NAME=iterative_machine.${resource.name}" \ -e "repo_token=${repo_token}" \ -e "RUNNER_REPO=${runner_repo}" \ -e "RUNNER_DRIVER=${driver}" \