Repository navigation
Serialize self-hosted AWF jobs sharing a Docker daemon - #79119
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
✅ PR Specification Reviewer completed successfully!
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills... |
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
Reviewed head 5257544dd92f585abbd5db9da6d59be136f702bb.
Applicable contract: docs/src/content/docs/reference/self-hosted-runners.md, Shared-daemon concurrency (§ Shared-daemon concurrency / Compatibility resource inventory). The documented lease acquisition is not implementable as written: docker image import receives 1024 zero bytes rather than a valid archive, so setup fails before reserving the lease. This is blocking because the advertised self-hosted serialization path cannot start. One inline finding was published. No other directly applicable normative specification was identified; this static review did not execute tests or workflows.
Generated by PR Specification Reviewer for #79119 · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.7K
Comment /review-specs to run again
|
|
||
| Self-hosted jobs using the same Docker daemon are **serialized**, not run concurrently inside AWF. Setup acquires the daemon-visible `gh-aw-daemon-lease` container before modifying shared runtime state and holds it through the action's always/post cleanup. Another job waits up to ten minutes, then fails without starting AWF or stopping the lease owner's services. Startup retries retain the lease. Separate runs, reruns, and matrix copies receive distinct SHA-256 invocation identities incorporating run metadata and a random UUID. | ||
|
|
||
| The lease and its private, non-executable image carry the `io.github.gh-aw.invocation` label. The container also records repository, run ID, attempt, and job labels. Acquisition uses Docker's atomic container-name reservation, not a local lock file, so separate runner processes targeting the same daemon coordinate. Cleanup verifies the invocation label and removes the lease by immutable container ID. No lock image is downloaded or started. |
There was a problem hiding this comment.
This contract currently cannot be fulfilled by the acquisition implementation: docker_lease.cjs calls docker image import with Buffer.alloc(1024) as stdin (line 110), which is not a valid tar archive for docker image import, so setup fails before creating the lease. Please use a valid minimal image/archive (while preserving the non-executable/no-download guarantees) or adjust the implementation and tests before documenting this behavior.
There was a problem hiding this comment.
The lease archive is now built as a valid ustar containing the locally generated static pause binary; the lease container runs it without network access, and no image or executable is downloaded. The archive and ELF headers are covered by the lease tests.
Comment MemoryPeek at saved memory (spec-review-history)History |
There was a problem hiding this comment.
Found two blocking correctness/test-quality issues:
- The stopped lease container is removable by routine Docker prune, allowing a second job to acquire the name and overlap the active owner.
- The setup ordering regression test can pass when the acquire call is absent because it does not assert both search results exist.
Static review only; repository code was not executed per review constraints.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~5 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| } | ||
| }); | ||
|
|
||
| it("acquires before setup's first shared filesystem deletion and releases last", () => { |
There was a problem hiding this comment.
This ordering assertion is vacuous if the acquire call is removed: indexOf(...) returns -1, and -1 < indexOf("sudo -n rm -rf /tmp/gh-aw") still passes. Since this test is the guard for the critical acquire-before-cleanup invariant, assert both indices are non-negative before comparing them.
There was a problem hiding this comment.
The setup-order regression asserts both indices are non-negative before comparing them, so removing the acquisition call now fails the test.
| while (true) { | ||
| if (!inspectLease(run)) { | ||
| try { | ||
| run(["container", "create", "--name", LEASE_NAME, "--network", "none", "--label", `${OWNER_LABEL}=${owner}`, ...metadata, image, "/never-executed"]); |
There was a problem hiding this comment.
This lease is created but never started, so a routine docker container prune (or docker system prune) can delete it while the owner is still active. The next invocation then acquires the fixed name and runs concurrently, defeating the serialization guarantee. Please make the lease container ineligible for normal pruning (for example, keep a minimal command running) or otherwise add a daemon-enforced protection; documentation alone cannot preserve the lock.
There was a problem hiding this comment.
The lease container is started and runs the local pause executable with networking disabled and an unless-stopped restart policy, so normal prune operations cannot remove an active lease.
Comment MemoryPeek at saved memory (review-history)History |
There was a problem hiding this comment.
🟡 Changes recommended
Critical lease-ownership and cleanup gaps can interfere with other jobs, strand leases and host processes, and leave persistent runner trust changes behind.
7 open issues
Prevent timed-out jobs from finalizing shared runtime state · New Stop invocation-owned MCP listeners before releasing the lease · New Use invocation-private storage for action-source checkout · New Provision Node before lease acquisition · New Emit always-run cleanup for every script-mode setup · New Clean up host trust changes when Docker teardown fails · New Add lease validation and ownership label to MCP gateway launcher · New
What changed in this PR
Introduces a Docker-daemon lease to serialize self-hosted AWF jobs that share fixed container names and listener ports, addressing #79118. This extends gh-aw’s runtime-path isolation with shared-resource coordination.
Changes:
- Adds atomic lease acquisition, unique invocation identities, bounded waits, and ownership-aware release.
- Adds lease checks and container labels to shell startup and teardown paths.
- Documents concurrency limits and recovery, with unit and two-process Docker regressions.
| File | Description |
|---|---|
docs/src/content/docs/reference/self-hosted-runners.md |
Documents shared resources, serialization, and administrator recovery. |
actions/setup/sh/stop_mcp_gateway.sh |
Checks ownership before gateway shutdown. |
actions/setup/sh/stop_difc_proxy.sh |
Checks ownership before DIFC proxy teardown. |
actions/setup/sh/stop_cli_proxy.sh |
Checks ownership before CLI proxy removal. |
actions/setup/sh/start_mcp_gateway.sh |
Validates the lease and labels shell-launched gateways. |
actions/setup/sh/start_difc_proxy.sh |
Validates the lease and labels DIFC containers. |
actions/setup/sh/start_cli_proxy.sh |
Validates the lease and labels CLI proxy containers. |
actions/setup/sh/run_awf_with_startup_retries.sh |
Requires a validated lease before AWF execution. |
actions/setup/sh/assert_docker_lease.sh |
Provides a shared shell ownership-check helper. |
actions/setup/setup.sh |
Acquires the lease before shared setup work. |
actions/setup/post.js |
Releases the lease after post-action cleanup. |
actions/setup/js/docker_lease.test.cjs |
Tests identities, contention, ownership, and failure handling. |
actions/setup/js/docker_lease.integration.test.cjs |
Adds opt-in shared-daemon and interruption regressions. |
actions/setup/js/docker_lease.cjs |
Implements lease acquisition, validation, inventory, and release. |
actions/setup/clean.sh |
Adds lease release to script-mode cleanup. |
Review effort: Max (adaptive)
| if (Date.now() >= deadline) { | ||
| throw new Error("Timed out waiting for the shared-daemon AWF lease. It may belong to a running or interrupted job; never remove it without checking its owner."); |
There was a problem hiding this comment.
Shared-runtime finalization is gated on a validated lease in both action post and script cleanup; rejected contenders skip telemetry/output finalization and leave the active owner’s shared tree untouched.
| requireCleanDaemon(run); | ||
| run(["container", "rm", lease.Id]); |
There was a problem hiding this comment.
The MCP Scripts PID is recorded with its invocation owner, classified as a shared host listener, and stopped with exit confirmation before lease release. Cleanup retains the lease if the process does not exit.
|
|
||
| # Acquire before touching shared paths, containers, or listeners. Kept until always/post. | ||
| if [[ "${RUNNER_ENVIRONMENT:-}" == "self-hosted" ]]; then | ||
| node "$(dirname "${BASH_SOURCE[0]}")/js/docker_lease.cjs" acquire |
There was a problem hiding this comment.
Script-mode action-source checkouts use a per-run, attempt, job, and matrix-index path, preventing contenders from replacing the active invocation’s checkout.
|
|
||
| # Acquire before touching shared paths, containers, or listeners. Kept until always/post. | ||
| if [[ "${RUNNER_ENVIRONMENT:-}" == "self-hosted" ]]; then | ||
| node "$(dirname "${BASH_SOURCE[0]}")/js/docker_lease.cjs" acquire |
There was a problem hiding this comment.
Action mode passes the bundled process.execPath into setup; script mode emits a pinned actions/setup-node step before setup acquires the lease.
|
|
||
| # Acquire before touching shared paths, containers, or listeners. Kept until always/post. | ||
| if [[ "${RUNNER_ENVIRONMENT:-}" == "self-hosted" ]]; then | ||
| node "$(dirname "${BASH_SOURCE[0]}")/js/docker_lease.cjs" acquire |
There was a problem hiding this comment.
Script-mode setup callers, including gateway provenance and admission, now append the if: always() cleanup step so leases are released after success or failure.
|
|
||
| if [[ "${RUNNER_ENVIRONMENT:-}" == "self-hosted" ]]; then | ||
| # shellcheck source=assert_docker_lease.sh | ||
| source "$(dirname "${BASH_SOURCE[0]}")/assert_docker_lease.sh" awmg-proxy |
There was a problem hiding this comment.
Commit 4c0d732 separates host-trust cleanup status from Docker teardown status. Owned CA/remote state is cleaned even when Docker inspection fails, while teardown still fails and prevents unsafe lease release.
|
|
||
| if [[ "${RUNNER_ENVIRONMENT:-}" == "self-hosted" ]]; then | ||
| # shellcheck source=assert_docker_lease.sh | ||
| source "$(dirname "${BASH_SOURCE[0]}")/assert_docker_lease.sh" awmg-mcpg |
There was a problem hiding this comment.
The JavaScript gateway launcher validates the lease and existing service owner before replacement, adds the invocation label to startup, and is covered alongside the cleanup ownership checks in the gateway and lease tests.
|
@copilot address review feedback |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
@copilot merge main and recompile workflows |
…ocker-resources Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Fixed in |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…rces' into copilot/isolate-awf-docker-resources Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged main in
The lease ownership, cleanup, checkout, Node provisioning and gateway feedback was addressed in
Review fixes are in |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "5f15f27506bf7e5df45a6efe914d6518a2d969b4",
"kind": "requested",
"schema_version": "1",
"state": "26a2636e1d9a3170138d83fe43d727244646ce17978ad094f3602b8298c56b2f",
"work": [
"130c3a5e319c5067c33128676c8e8033d0cd3bf29288f5a0e5c134e8bd3ba3ca",
"47f188a12b316525c2202f4f75b82185d76be0a140c0f99eae185cf2b7d8acb1",
"4cfbab64c0207356aa61ab0fd09744c7681bb2bb5b58ae2cc5c32b6f7a6b0a41",
"90bcee77287b19fd7de7aeb6a2c85cf52a359e2a13f84db25946a9d3f8ee91fa",
"95a70dfd18ba9582418af7a1f12bf16b2fe0ac9dfd317910810645f42b8171ef",
"a2cbdbd1db4bb0b87f7ba923fbb73a78a6eb7c267852264c49c364f7f3ceaa5e",
"b022f26d67a7632b7f68197c960c6f2e68122ab9add8f6b90e0e11f9a4c438d0",
"bf178e67abe2dc2ba9696f3bc658f75fdee094c31260b6e429b36bdaf3d59aad",
"d9e4b77c16b5b9b566062f7943df499f8b0037f9999bc6ad8f505e08ce692e00",
"dbae9eaaa7c0a9c5a1910418564fe763280e6908f9cc368d75c155a6a2200048",
"de0c09763a8b5c03ef404816e49a24c6c74aa0336e6a7e7a6637a58c7de9ef43"
],
"workflow": "pr-sous-chef"
}
|
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Fixed the stale launcher assertion and included the generated workflow locks required by drift validation in commit |
Merged latest |

AWF’s fixed Docker names and listener ports can collide across simultaneous self-hosted jobs, even with isolated runtime paths. This change serializes the shared-daemon lifecycle until upstream supports resource namespacing.
Daemon coordination
Ownership and recovery
Concurrency contract
Compatibility boundary: shared-daemon jobs are serialized, not independently namespaced. Unrestricted parallelism still requires isolated hosts/VMs and Docker daemons.