From b6ffc25755dc88296d69dac8d4739f1448d2fc10 Mon Sep 17 00:00:00 2001 From: "Timothy J. Aveni" Date: Sun, 28 Jun 2026 21:36:58 -0700 Subject: [PATCH] Stop deploy from reconfiguring central backend --- tofu/runtime/deploy.ts | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/tofu/runtime/deploy.ts b/tofu/runtime/deploy.ts index 25b6cf9..43b368d 100644 --- a/tofu/runtime/deploy.ts +++ b/tofu/runtime/deploy.ts @@ -13,7 +13,6 @@ const repoRoot = process.env.QUIXOS_REPO_ROOT ?? path.resolve(sourceScriptDir, " const scriptDir = process.env.QUIXOS_RUNTIME_DIR ?? path.resolve(repoRoot, "tofu/runtime"); const amiBuilderDir = path.resolve(scriptDir, "../ami-builder"); const centralDir = path.resolve(scriptDir, "../central"); -const centralInitBackendScript = path.join(centralDir, "init-backend.sh"); const legacyResolvedAmiVarsFile = "resolved-ami.auto.tfvars.json"; const resolvedDeployVarsFile = "zz-qx-deploy.auto.tfvars.json"; @@ -171,27 +170,6 @@ const capture = (command, args, options = {}) => const captureMaybe = (command, args, options = {}) => run(command, args, { ...options, capture: true, allowFailure: true }); -let centralBackendReconfigured = false; -const reconfigureCentralBackend = (env) => { - if (centralBackendReconfigured || !fs.existsSync(centralDir)) { - return; - } - - if (fs.existsSync(centralInitBackendScript)) { - run(centralInitBackendScript, ["-reconfigure"], { - cwd: centralDir, - env, - }); - } else { - run("tofu", ["init", "-reconfigure"], { - cwd: centralDir, - env, - }); - } - - centralBackendReconfigured = true; -}; - const centralOutput = (name, { env, required = false } = {}) => { if (!fs.existsSync(centralDir)) { if (required) { @@ -200,25 +178,22 @@ const centralOutput = (name, { env, required = false } = {}) => { return null; } - let result = captureMaybe("tofu", ["-chdir=" + centralDir, "output", "-raw", name], { env }); - if ( - result.status !== 0 - && /Backend initialization required|please run "tofu init"|run\s+"tofu init"/i.test(result.stderr) - ) { - reconfigureCentralBackend(env); - result = captureMaybe("tofu", ["-chdir=" + centralDir, "output", "-raw", name], { env }); - } + const result = captureMaybe("tofu", ["-chdir=" + centralDir, "output", "-raw", name], { env }); const value = result.stdout.trim(); if (result.status === 0 && value) { return value; } if (required) { + const initHint = /Backend initialization required|please run "tofu init"|run\s+"tofu init"/i.test(result.stderr) + ? "Initialize central explicitly with: (cd tofu/central && ./init-backend.sh -reconfigure)" + : ""; const details = [ `Unable to read tofu/central output '${name}'.`, `Command: tofu -chdir=${centralDir} output -raw ${name}`, result.stderr.trimEnd(), result.stdout.trimEnd(), + initHint, ].filter(Boolean).join("\n"); throw new Error(details); }