Skip to content

Clean up stale gh-aw gateway containers before binding port on self-hosted runners#39998

Merged
pelikhan merged 5 commits into
mainfrom
copilot/clean-up-gh-aw-containers
Jun 18, 2026
Merged

Clean up stale gh-aw gateway containers before binding port on self-hosted runners#39998
pelikhan merged 5 commits into
mainfrom
copilot/clean-up-gh-aw-containers

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

On persistent self-hosted runners, leftover ghcr.io/github/gh-aw-mcpg containers from prior jobs hold port 8080, causing the next job to fail at gateway startup with bind: address already in use. The prior stop logic (kill $GATEWAY_PID) does not stop the Docker container — only the wrapper process — leaving the gateway bound to the host port.

Changes

  • mcp_setup_generator.go: Add --name awmg-mcpg to the generated docker run command, enabling reliable container management by name (same pattern as awmg-proxy / awmg-cli-proxy).

  • start_mcp_gateway.sh / start_mcp_gateway.cjs: Add pre-start cleanup (docker rm -f awmg-mcpg 2>/dev/null || true) before launching the container. Idempotent — no-ops when no stale container exists.

  • stop_mcp_gateway.sh: Move docker stop awmg-mcpg / docker rm -f awmg-mcpg before the GATEWAY_PID empty-check so container teardown happens unconditionally, even if the start step never captured a PID.

  • Tests / golden files: Update mcp_setup_generator_test.go, start_mcp_gateway_test.sh, WASM golden snapshots, and all 250 compiled .lock.yml workflow files to reflect the new docker command shape.

Generated docker command (before → after)

- docker run -i --rm --network host --add-host host.docker.internal:127.0.0.1 ...
+ docker run -i --rm --network host --name awmg-mcpg --add-host host.docker.internal:127.0.0.1 ...

Changeset

  • Type: patch
  • Description: Fixed stale gh-aw gateway containers on self-hosted runners so port 8080 is cleaned up before the next gateway start.

Generated by 📋 Changeset Generator for issue #39998 ·



✨ PR Review Safe Output Test - Run 27758408911

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

💥 [THE END] — Illustrated by Smoke Claude ·

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Hey @Copilot 👋 — thanks for picking up the stale-container cleanup work for self-hosted runners! Named containers with pre-start cleanup is exactly the kind of reliability fix that helps here.

A few things to address before this is ready for review:

  • Complete the implementation — all 6 checklist items are still unchecked. The only change in the current diff is a comment reword in actions/setup-cli/install.sh, which is unrelated to the stated goal. The core changes to mcp_setup_generator.go, start_mcp_gateway.sh, start_mcp_gateway.cjs, and stop_mcp_gateway.sh still need to land.
  • Add testsmcp_setup_generator_test.go needs assertions that the generated docker run command includes --name awmg-mcpg, as noted in the checklist.
  • Validate — run make fmt, tests, and compilation before marking ready for review.

If you'd like a hand completing this, assign the following prompt to your coding agent:

Complete the container cleanup work in gh-aw (PR #39998):
1. In mcp_setup_generator.go, add `--name awmg-mcpg` to the Docker run command for the MCP gateway.
2. In start_mcp_gateway.sh, add pre-start cleanup before the docker run line:
   docker stop awmg-mcpg 2>/dev/null; docker rm awmg-mcpg 2>/dev/null
3. In start_mcp_gateway.cjs, add the equivalent pre-start cleanup via child_process/exec before spawning the container.
4. In stop_mcp_gateway.sh, add `docker stop awmg-mcpg 2>/dev/null; docker rm awmg-mcpg 2>/dev/null` alongside the existing wrapper PID termination.
5. In mcp_setup_generator_test.go, add test assertions that the generated docker run command includes `--name awmg-mcpg`.
6. Run `make fmt` and all tests before committing. Ensure the build compiles cleanly.

Generated by ✅ Contribution Check ·

… runners

- Add --name awmg-mcpg to docker run in mcp_setup_generator.go so the
  container can be identified and stopped by name
- Add pre-start cleanup (docker rm -f awmg-mcpg) in start_mcp_gateway.sh
  and start_mcp_gateway.cjs to remove any stale container before launch
- Restructure stop_mcp_gateway.sh to run docker stop/rm before PID check
  so containers get cleaned up even if PID was not captured
- Update golden test files and integration test assertions
- Regenerate all 250 .lock.yml workflow files via make recompile

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Clean up stale gh-aw containers on self-hosted runners Clean up stale gh-aw gateway containers before binding port on self-hosted runners Jun 18, 2026
Copilot AI requested a review from pelikhan June 18, 2026 06:47
@github-actions github-actions Bot mentioned this pull request Jun 18, 2026
@pelikhan pelikhan marked this pull request as ready for review June 18, 2026 11:13
Copilot AI review requested due to automatic review settings June 18, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent MCP gateway startup failures on persistent self-hosted runners by ensuring stale gh-aw gateway containers don’t keep host port 8080 bound between jobs. It does this by introducing a stable container name (awmg-mcpg) and adding pre-start cleanup logic, plus updating generated workflow artifacts to match the new docker run shape.

Changes:

  • Add --name awmg-mcpg to the generated MCP gateway docker run command so the container can be reliably managed by name.
  • Add “stale container” cleanup (docker rm -f awmg-mcpg … || true) before starting the gateway (both Bash and JS implementations).
  • Update tests and compiled .lock.yml workflow outputs to reflect the updated docker command.
Show a summary per file
File Description
pkg/workflow/mcp_setup_generator.go Adds --name awmg-mcpg to the generated gateway container command.
pkg/workflow/mcp_setup_generator_test.go Asserts the generated docker command contains the new container name flag.
actions/setup/sh/start_mcp_gateway.sh Adds pre-start removal of a stale awmg-mcpg container.
actions/setup/js/start_mcp_gateway.cjs Adds pre-start removal of a stale awmg-mcpg container (JS runner).
actions/setup/sh/stop_mcp_gateway.sh Changes gateway teardown ordering to stop/remove by container name earlier.
actions/setup/sh/start_mcp_gateway_test.sh Adds a shell test that checks the stale-container cleanup exists.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/basic-copilot.golden Updates golden output to include --name awmg-mcpg.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/playwright-cli-mode.golden Updates golden output to include --name awmg-mcpg.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/smoke-copilot.golden Updates golden output to include --name awmg-mcpg.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/with-imports.golden Updates golden output to include --name awmg-mcpg.
pkg/workflow/testdata/TestWasmGolden_AllEngines/claude.golden Updates golden output to include --name awmg-mcpg.
pkg/workflow/testdata/TestWasmGolden_AllEngines/codex.golden Updates golden output to include --name awmg-mcpg.
pkg/workflow/testdata/TestWasmGolden_AllEngines/copilot.golden Updates golden output to include --name awmg-mcpg.
pkg/workflow/testdata/TestWasmGolden_AllEngines/gemini.golden Updates golden output to include --name awmg-mcpg.
actions/setup-cli/install.sh Updates the script sync header comment.
.github/workflows/workflow-normalizer.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/workflow-health-manager.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/workflow-generator.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/video-analyzer.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/update-astro.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/tidy.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/test-workflow.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/test-quality-sentinel.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/test-project-url-default.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/test-dispatcher.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/super-linter.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/spec-librarian.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/spec-extractor.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/smoke-project.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/smoke-pi.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/smoke-copilot-sdk.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/smoke-ci.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/security-review.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/security-compliance.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/ruflo-backed-task.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/research.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/repo-tree-map.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/release.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/refiner.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/q.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/python-data-charts.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/pr-description-caveman.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/plan.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/pdf-summary.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/outcome-collector.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/org-health-report.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/objective-impact-report.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/metrics-collector.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/mergefest.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/linter-miner.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/lint-monster.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/layout-spec-maintainer.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/jsweep.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/gpclean.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/firewall.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/firewall-escape.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/example-permissions-warning.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/example-failure-category-filter.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/dev-hawk.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/designer-drift-audit.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/dependabot-worker.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/delight.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/daily-windows-terminal-integration-builder.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/daily-team-status.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/daily-safeoutputs-git-simulator.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/daily-max-ai-credits-test.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/daily-credit-limit-test.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/daily-byok-ollama-test.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/craft.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/copilot-opt.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/copilot-centralization-optimizer.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/copilot-centralization-drilldown.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/contribution-check.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/code-simplifier.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/ci-coach.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/brave.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/bot-detection.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/artifacts-summary.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/architecture-guardian.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/archie.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/agentic-token-trend-audit.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/agentic-token-optimizer.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/agentic-token-audit.lock.yml Regenerates compiled workflow output with updated docker command.
.github/workflows/ace-editor.lock.yml Regenerates compiled workflow output with updated docker command.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 265/265 changed files
  • Comments generated: 3

Comment thread actions/setup/sh/stop_mcp_gateway.sh Outdated
Comment on lines +14 to +22
# Stop the named gateway container first — this is more reliable than killing the
# docker run wrapper PID because it asks the Docker daemon to stop the container
# directly. This ensures the host port is freed even on persistent self-hosted
# runners where a prior kill of the wrapper process left the container running.
# This runs unconditionally (even when GATEWAY_PID is empty) so that partially
# started containers are cleaned up if the start step failed before capturing PID.
echo "Stopping awmg-mcpg container..."
docker stop awmg-mcpg 2>/dev/null || docker rm -f awmg-mcpg 2>/dev/null || true

Comment thread actions/setup/sh/start_mcp_gateway.sh Outdated
# On persistent self-hosted runners a prior job's gateway container may still be
# running and holding the host port, causing "bind: address already in use" when
# we try to start the new one. Force-removing by the well-known container name
# is idempotent and safe: if no such container exists the command exits 0.
Comment thread actions/setup/js/start_mcp_gateway.cjs Outdated
// On persistent self-hosted runners a prior job's gateway container may still
// be running and holding the host port, causing "bind: address already in use"
// when we try to start the new one. Force-removing by the well-known container
// name is idempotent and safe: if no such container exists Docker exits 0.
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #39998 does not have the 'implementation' label (has_implementation_label=false) and has only 12 new lines of code in business logic directories (≤100 threshold). Neither enforcement condition is met.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 60/100 — Acceptable

Analyzed 1 Go test (integration) modification: 1 design test, 0 implementation tests, 0 guideline violations. A shell test file was also modified but is not scored.

📊 Metrics & Test Classification (1 test analyzed)
Metric Value
New/modified tests analyzed 1
✅ Design tests (behavioral contracts) 1 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 0 (0%)
Duplicate test clusters 0
Test inflation detected YES (3 test lines / 1 prod line = 3:1)
🚨 Coding-guideline violations 0
Test File Classification Issues Detected
TestMCPGatewayDockerCommandUsesRunnerIdentityAndSocketGroup pkg/workflow/mcp_setup_generator_test.go:527 ✅ Design

Go: 1 (*_test.go); JavaScript: 0. Shell test (start_mcp_gateway_test.sh +7 lines) detected but not scored.

Score Breakdown

Component Weight Earned Notes
Behavioral Coverage 40 40 1/1 new assertions verify observable generator output
Error/Edge Case Coverage 30 0 New assertion is happy-path only (positive existence check)
Low Duplication 20 20 No copy-paste patterns
Proportional Growth 10 0 3 test lines added vs 1 production line → 3:1 ratio > 2:1 threshold

Test Analysis

The modification adds one new require.Contains assertion to TestMCPGatewayDockerCommandUsesRunnerIdentityAndSocketGroup checking that --name awmg-mcpg appears in the generated docker command YAML. This is a behavioral contract test: it verifies the generator emits the well-known container name that enables stale-container cleanup on self-hosted runners. The assertion carries a descriptive message and the file has the required //go:build integration build tag.

The shell test addition (start_mcp_gateway_test.sh) uses grep -q "docker rm -f awmg-mcpg" to check the cleanup logic is present in the start script — a reasonable pattern for shell-script testing.

Note: actions/setup/js/start_mcp_gateway.cjs received 14 lines of production changes (stale-container cleanup) with no corresponding JS test coverage. This is a minor gap but acceptable given the straightforward nature of the change.

Verdict

Check passed. 0% implementation tests (threshold: 30%). The single new assertion enforces a behavioral contract — the generator must emit a well-known container name for cleanup. Score is 60/100 (Acceptable) due to no error-path coverage in the new assertion and minor test inflation.

🧪 Test quality analysis by Test Quality Sentinel ·

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 60/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

Comments that could not be inline-anchored

actions/setup/sh/stop_mcp_gateway.sh:21

[/diagnose] docker stop || docker rm -f only runs the force-remove if docker stop fails. When docker stop succeeds the container enters stopped state, and release of the name depends on async --rm daemon cleanup — a brief window where a subsequent docker run --name awmg-mcpg could fail with name already in use. The pre-start docker rm -f in start_mcp_gateway.sh closes this window, so no bug today — but for a cleanup path whose sole purpose is freeing the name/port, a single …

actions/setup/sh/start_mcp_gateway.sh:87

[/diagnose] The validation block checks for -i, --rm, and --network flags but not --name awmg-mcpg. If MCP_GATEWAY_DOCKER_COMMAND is ever set manually (or generated by an older/patched compiler), the cleanup at line 159 silently no-ops (no container to remove), the new container starts unnamed, and future stop scripts can't tear it down by name. Adding a validation keeps the invariant visible:

<details>
<summary>💡 Suggested validation</summary>

if ! echo &quot;$MCP_GATEWAY_D</details>

<details><summary>pkg/workflow/mcp_setup_generator_test.go:551</summary>

**[/tdd]** `containerNameSnippet` gets a `require.Contains` check, but unlike every other flag snippet (lines 552–560 all have `require.Less` ordering guards), there&#39;s no assertion that `--name awmg-mcpg` appears before `--add-host`. A future refactor could silently reorder the flags and still pass this test.

&lt;details&gt;
&lt;summary&gt;💡 Suggested ordering assertion&lt;/summary&gt;

```go
require.Less(t, strings.Index(yamlStr, containerNameSnippet), strings.Index(yamlStr, addHostSnippet),
    &quot;--name awmg-…

</details>

<details><summary>actions/setup/sh/start_mcp_gateway_test.sh:307</summary>

**[/tdd]** The test greps for the presence of `docker rm -f awmg-mcpg` and `awmg-mcpg` in the script, but doesn&#39;t verify that cleanup actually runs *before* the gateway launch. A later edit could move the cleanup after the `$MCP_GATEWAY_DOCKER_COMMAND` invocation and this test would still pass.

&lt;details&gt;
&lt;summary&gt;💡 Stronger ordering check&lt;/summary&gt;

```bash
CLEANUP_LINE=$(grep -n &#39;docker rm -f awmg-mcpg&#39; &quot;$SCRIPT_PATH&quot; | head -1 | cut -d: -f1)
LAUNCH_LINE=$(grep -n &#39;MCP_GATEWAY_DOCKER_COMMAND…

</details>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST_CHANGES — The approach is correct and the pre-start cleanup in start_mcp_gateway.sh / .cjs is solid, but stop_mcp_gateway.sh has a blocking correctness issue plus a latency concern.

Blocking issues (must fix before merge)

1. Container stopped before graceful /close endpoint (existing comment, restated for emphasis)

docker stop awmg-mcpg is placed before the /close endpoint attempt and before the $GATEWAY_PID process check. Once the container is stopped, the docker run wrapper ($GATEWAY_PID) exits, the /close curl call always fails (gateway is gone), and the remaining PID-based logic becomes a no-op. This makes every workflow teardown a forced shutdown — the graceful mechanism added for spec compliance is now dead code.

Fix: move the docker stop block to after the /close-then-SIGTERM fallback chain, as the final cleanup step.

2. docker stop default 10-second grace period adds latency (new comment on line 21)

Even after fixing the ordering, docker stop without --time 0 waits up to 10 s for the container to respond to SIGTERM before force-killing. At this point in the script graceful shutdown has already been attempted; using docker stop --time 0 (or equivalent) avoids a silent 10-second CI stall when the container is stuck.

Non-blocking (existing comments)
  • Comment in start_mcp_gateway.sh and start_mcp_gateway.cjs inaccurately states docker rm -f exits 0 when the container doesn't exist — it exits non-zero; the || true is what makes it idempotent.

🔎 Code quality review by PR Code Quality Reviewer

Comment thread actions/setup/sh/stop_mcp_gateway.sh Outdated
# This runs unconditionally (even when GATEWAY_PID is empty) so that partially
# started containers are cleaned up if the start step failed before capturing PID.
echo "Stopping awmg-mcpg container..."
docker stop awmg-mcpg 2>/dev/null || docker rm -f awmg-mcpg 2>/dev/null || true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker stop uses the default 10-second grace period, adding up to 10 s of latency on every workflow teardown if the container is unresponsive.

💡 Suggested fix

This call is a force-cleanup (the /close endpoint is the intended graceful path). Pass --time 0 so Docker skips the SIGTERM wait and immediately forces the container to exit:

docker stop --time 0 awmg-mcpg 2>/dev/null || docker rm -f awmg-mcpg 2>/dev/null || true

This is orthogonal to the ordering issue already flagged: even after moving this block to after the /close attempt, you still want --time 0 here because graceful shutdown has already been attempted and this is the unconditional cleanup step.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

- stop_mcp_gateway.sh: use EXIT trap for container cleanup so /close
  endpoint is attempted first; container teardown still runs on every
  exit path (missing PID, process gone, successful /close, kill fallback)
- start_mcp_gateway.sh: fix misleading comment about docker rm -f
  idempotency; clarify that || true provides the idempotency, not Docker
- start_mcp_gateway.cjs: same comment fix as the shell script

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Done in commit b0d1d54:

  • stop_mcp_gateway.sh: replaced the upfront docker stop/rm block with an EXIT trap (cleanup_container). The /close endpoint is now always attempted first when the gateway is reachable; the trap guarantees container teardown on every exit path (missing PID, process already gone, successful /close, or kill fallback).
  • start_mcp_gateway.sh and start_mcp_gateway.cjs: corrected the idempotency comments — docker rm -f does exit non-zero when the container doesn't exist; idempotency comes from the trailing || true (and 2>/dev/null), not from Docker itself.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🚀 Smoke Gemini MISSION COMPLETE! Gemini has spoken. ✨

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions

Copy link
Copy Markdown
Contributor

📰 BREAKING: Smoke Copilot - AOAI (Entra) is now investigating this pull request. Sources say the story is developing...

@github-actions

Copy link
Copy Markdown
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions

Copy link
Copy Markdown
Contributor

📰 BREAKING: Smoke Copilot - AOAI (apikey) is now investigating this pull request. Sources say the story is developing...

@github-actions

Copy link
Copy Markdown
Contributor

Commit pushed: bc4a89a

Generated by Changeset Generator

@github-actions

Copy link
Copy Markdown
Contributor

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.54.0
jq 1.7
yq v4.53.3
curl 8.5.0
gh 2.93.0
node v22.22.3
python3 3.11.15 (PyPy 7.3.23)
go 1.24.13
java 21.0.11
dotnet 10.0.300

Result: 12/12 tools available ✅

Overall Status: PASS

🔧 Tool validation by Agent Container Smoke Test ·

@github-actions

Copy link
Copy Markdown
Contributor

✅ Test 1: GitHub MCP
✅ Test 2: Web Fetch
✅ Test 3: File Writing
✅ Test 4: Bash Tool
❌ Test 5: Build gh-aw
Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

Smoke Gemini — Powered by Gemini ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke test 27758408912
#40041 [docs] Update documentation for features from 2026-06-18
#40039 [docs] Update glossary - daily scan
Overall: PASS
Issue field update: SKIPPED

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex ·

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Silent build complete
Temp files and checks
Green across the board

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke run: PASS
PR title: Clean up stale gh-aw gateway containers before binding port on self-hosted runners
Merged titles: [docs] Update documentation for features from 2026-06-18; [docs] Update glossary - daily scan
1✅ 2✅ 3✅ 4✅ 5✅
6✅ 7✅ 8✅ 9✅ 10✅
11✅ 12✅ 13✅ 14✅ 15✅
Author: @app/copilot-swe-agent
Assignees: @pelikhan @Copilot

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot ·

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Smoke moon hums
Bot bonk rock with stick
Tests grunt then sleep

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot ·

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smoke review done. Cave eyes saw 2 anchors.

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Smoke Test: Claude — Run 27758408911

Core #1-12: ✅ all passed
PR Review #13-18: ✅ all passed · #19: ⚠️ skipped (no safe test PR)

Overall: PARTIAL (0 failed, 1 skipped) — Claude engine nominal! 💥

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

💥 [THE END] — Illustrated by Smoke Claude ·

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥 Automated smoke test review - all systems nominal!

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

💥 [THE END] — Illustrated by Smoke Claude

@@ -0,0 +1,5 @@
---
"gh-aw": patch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good: pinning the changeset type to patch matches the bugfix scope of this PR.

"gh-aw": patch
---

Fixed stale `gh-aw` gateway containers on self-hosted runners so port 8080 is cleaned up before the next gateway start.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear changeset summary — it explains the port 8080 cleanup behavior well.

@github-actions

Copy link
Copy Markdown
Contributor

Smoke tests failed: 1✅ 2❌ 3❌ 4❌ 5✅ 6✅ overall FAIL. See issue #40047.

📰 BREAKING: Report filed by Smoke Copilot - AOAI (apikey) ·

@pelikhan pelikhan merged commit 79b10f0 into main Jun 18, 2026
38 checks passed
@pelikhan pelikhan deleted the copilot/clean-up-gh-aw-containers branch June 18, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants