From 036fd74f37c4865903f5f7b687a84fe58d7f8b68 Mon Sep 17 00:00:00 2001 From: Senthil Ravichandran Date: Tue, 18 Aug 2026 01:55:59 -0700 Subject: [PATCH 1/2] fix(portable): require exited stop state Signed-off-by: Senthil Ravichandran --- .../portable-demo-lifecycle-stop.test.ts | 34 +++++++++++++++++++ .../experimental/portable-demo-lifecycle.ts | 5 ++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/lib/onboard/experimental/portable-demo-lifecycle-stop.test.ts b/src/lib/onboard/experimental/portable-demo-lifecycle-stop.test.ts index 020b82f0db1..19757f0fee7 100644 --- a/src/lib/onboard/experimental/portable-demo-lifecycle-stop.test.ts +++ b/src/lib/onboard/experimental/portable-demo-lifecycle-stop.test.ts @@ -265,6 +265,40 @@ afterEach(() => { }); describe("portable demo sandbox stop reconciliation", () => { + it("returns already-stopped for an exited container without another mutation (#9200)", () => { + const harness = createStopHarness(); + harness.runtime.setState(false, "exited"); + const beforeStop = vi.fn(); + + expect(stopSandbox(harness, {}, beforeStop)).toEqual({ kind: "already-stopped" }); + + expect(beforeStop).not.toHaveBeenCalled(); + expectReceiptUnchanged(harness); + expect( + harness.runtime.podman.mock.calls.some(([args]) => { + const command = args[0] === "--url" ? args.slice(2) : args; + return command[0] === "stop"; + }), + ).toBe(false); + }); + + it("rejects a non-running container without an exited status (#9200)", () => { + const harness = createStopHarness(); + harness.runtime.setState(false, null); + const beforeStop = vi.fn(); + + expect(() => stopSandbox(harness, {}, beforeStop)).toThrow("is not in the exited state"); + + expect(beforeStop).not.toHaveBeenCalled(); + expectReceiptUnchanged(harness); + expect( + harness.runtime.podman.mock.calls.some(([args]) => { + const command = args[0] === "--url" ? args.slice(2) : args; + return command[0] === "stop"; + }), + ).toBe(false); + }); + it("waits for an already-stopping container to settle without another mutation (#9200)", () => { const harness = createStopHarness(); let now = 0; diff --git a/src/lib/onboard/experimental/portable-demo-lifecycle.ts b/src/lib/onboard/experimental/portable-demo-lifecycle.ts index fc8da883c51..f617b30a309 100644 --- a/src/lib/onboard/experimental/portable-demo-lifecycle.ts +++ b/src/lib/onboard/experimental/portable-demo-lifecycle.ts @@ -1338,7 +1338,10 @@ export function stopPortableDemoSandboxLifecycle( }; if (!inspection.running) { - if (inspection.status !== "stopping") return { kind: "already-stopped" }; + if (inspection.status === "exited") return { kind: "already-stopped" }; + if (inspection.status !== "stopping") { + throw new Error(`Portable sandbox '${sandboxName}' is not in the exited state`); + } if (waitFor(STOP_SETTLEMENT_TIMEOUT_MS, timing, inspectExitedState)) { return { kind: "already-stopped" }; } From 01a96e74a5360bfa67dd6c07d946c57e97a07777 Mon Sep 17 00:00:00 2001 From: Rebecca Sliter <571084+rsliter@users.noreply.github.com> Date: Tue, 18 Aug 2026 07:50:50 -0700 Subject: [PATCH 2/2] test(portable): name missing stop status precisely Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com> --- .../onboard/experimental/portable-demo-lifecycle-stop.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/onboard/experimental/portable-demo-lifecycle-stop.test.ts b/src/lib/onboard/experimental/portable-demo-lifecycle-stop.test.ts index 19757f0fee7..2664f40e002 100644 --- a/src/lib/onboard/experimental/portable-demo-lifecycle-stop.test.ts +++ b/src/lib/onboard/experimental/portable-demo-lifecycle-stop.test.ts @@ -282,7 +282,7 @@ describe("portable demo sandbox stop reconciliation", () => { ).toBe(false); }); - it("rejects a non-running container without an exited status (#9200)", () => { + it("rejects a non-running container with no Podman status (#9200)", () => { const harness = createStopHarness(); harness.runtime.setState(false, null); const beforeStop = vi.fn();