Multiplayer agent harness for work.
Deploy recorded layers when the AWS target core is stopped (#1329)
Regan Bell3f2b92e01e82
diff --git a/cli/src/backends/aws.ts b/cli/src/backends/aws.tsindex a05f42690..bc0115c44 100644--- a/cli/src/backends/aws.ts+++ b/cli/src/backends/aws.ts@@ -2477,7 +2477,7 @@ export async function awsUp(config: QmConfig, _configDir: string, opts: AwsUpOptdesiredLayerBody = deploymentLayerBody(opts.sandboxDir);desiredLayer = putDeploymentLayerArtifact(config, desiredLayerBody);layerChanged = desiredLayer.sha256 !== current?.layer?.sha256;- if (!layerChanged) {+ if (!layerChanged && before.counts.core !== 0) {const state = await currentDeploymentLayerState({config,transport: awsDeploymentLayerTransport,diff --git a/cli/test/aws.test.ts b/cli/test/aws.test.tsindex e90339863..72f23ca4b 100644--- a/cli/test/aws.test.ts+++ b/cli/test/aws.test.ts@@ -1307,6 +1307,51 @@ test("AWS up scales services to the configured desired count and live check flag}});+test("AWS up reapplies the recorded layer after starting a stopped core", async () => {+ const dir = mkdtempSync(join(tmpdir(), "qm-aws-stopped-layer-"));+ const dockerBin = join(dir, "docker");+ writeFileSync(dockerBin, `#!/usr/bin/env node\nconsole.log("Digest: sha256:${"a".repeat(64)}");\n`);+ chmodSync(dockerBin, 0o755);+ const single = oneServiceConfig();+ const fake = statefulAws(dir, single);+ const priorPath = process.env.PATH;+ process.env.PATH = `${dir}:${priorPath}`;+ try {+ await awsUp(single, dir, { yes: true, sandboxDir: dir });+ const stopped = JSON.parse(readFileSync(fake.state, "utf8"));+ const previousId = stopped.dynamo["deployment/current"].manifestId.S;+ const previous = JSON.parse(stopped.dynamo[`deployment/manifest/${previousId}`].manifest.S);+ stopped.services["acme-core"].desiredCount = 0;+ writeFileSync(fake.state, JSON.stringify(stopped));+ const fetchLayer = globalThis.fetch;+ const writes: string[] = [];+ let stoppedReads = 0;+ globalThis.fetch = async (url, init) => {+ if (String(url).includes("/v1/deployment-layer")) {+ const current = JSON.parse(readFileSync(fake.state, "utf8"));+ if (current.services["acme-core"].desiredCount === 0) {+ stoppedReads++;+ return new Response("core is stopped", { status: 503 });+ }+ if (init?.method === "PUT") writes.push(String(init.body));+ }+ return fetchLayer(url, init);+ };+ await awsUp(single, dir, { yes: true, sandboxDir: dir });+ const resumed = JSON.parse(readFileSync(fake.state, "utf8"));+ const currentId = resumed.dynamo["deployment/current"].manifestId.S;+ const current = JSON.parse(resumed.dynamo[`deployment/manifest/${currentId}`].manifest.S);+ assert.equal(stoppedReads, 0);+ assert.deepEqual(writes, [EMPTY_LAYER_BODY]);+ assert.equal(resumed.services["acme-core"].desiredCount, 1);+ assert.deepEqual(current.layer, previous.layer);+ } finally {+ process.env.PATH = priorPath;+ fake.restore();+ rmSync(dir, { recursive: true, force: true });+ }+});+test("AWS up records a restore point under the lease before any mutation and stamps it in the manifest", async () => {const dir = mkdtempSync(join(tmpdir(), "qm-aws-db-restore-point-"));const dockerBin = join(dir, "docker");