Skip to content

fix: propagate DOCKER_HOST to MCP gateway for ARC/dind runners - #31670

Merged
pelikhan merged 1 commit into
mainfrom
salmanmkc/arc-docker-host-propagation
May 12, 2026
Merged

pelikhan merged 1 commit into
mainfrom
salmanmkc/arc-docker-host-propagation

Conversation

@salmanmkc

@salmanmkc salmanmkc commented May 12, 2026 •

Copy link
Copy Markdown
Collaborator

Resolves the Docker socket path from DOCKER_HOST instead of hardcoding /var/run/docker.sock. Passes DOCKER_HOST to the gateway container and auto-detects socket GID from the resolved path.

Ref #28888

Copilot AI review requested due to automatic review settings May 12, 2026 10:46
@salmanmkc
salmanmkc force-pushed the salmanmkc/arc-docker-host-propagation branch from dfb0a78 to bd1f4b7 Compare May 12, 2026 10:48
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

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 improves portability of the MCP gateway startup on self-hosted runners by deriving the Docker socket mount and group ID from DOCKER_HOST (instead of hardcoding /var/run/docker.sock) and propagating DOCKER_HOST into the gateway container. It also introduces a new (separately-scoped) feature flag to emit GHES-compatible artifact action pins.

Changes:

  • Resolve Docker socket path from DOCKER_HOST, compute socket GID from the resolved path, and mount that path into the MCP gateway container; also pass DOCKER_HOST through to the container.
  • Add ghes-artifact-compat feature flag to pin actions/{upload,download}-artifact to v3.x when enabled.
  • Add embedded v3.x artifact pins to the action pin dataset and test the compat behavior.
Show a summary per file
File Description
pkg/workflow/mcp_setup_generator.go Derives DOCKER_SOCK_PATH from DOCKER_HOST, uses it for socket GID detection and docker socket mount, and propagates DOCKER_HOST to the container.
pkg/workflow/mcp_setup_generator_test.go Updates expectations for resolved socket path and DOCKER_HOST propagation.
pkg/workflow/compiler.go Enables GHES artifact compat mode via feature flag during compilation.
pkg/workflow/action_pins.go Adds GHES artifact compat pin selection logic and global toggle.
pkg/workflow/action_pins_test.go Adds tests validating GHES compat behavior and pin presence.
pkg/constants/feature_constants.go Introduces ghes-artifact-compat feature flag constant and docs.
pkg/actionpins/data/action_pins.json Adds v3.x pins for upload/download artifact actions.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@salmanmkc
salmanmkc force-pushed the salmanmkc/arc-docker-host-propagation branch from bd1f4b7 to ded5994 Compare May 12, 2026 11:03
@github-actions

This comment has been minimized.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot recompile

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

@copilot recompile

Recompiled — all 219 workflow lock files have been updated and pushed in commit chore: recompile all workflow lock files.

Copilot AI requested a review from pelikhan May 12, 2026 13:31
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot review modifed code in .lock.yml from a security and shell sec POV

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

@copilot review modifed code in .lock.yml from a security and shell sec POV

Security review of the modified shell snippet in all 219 .lock.yml files — no issues found. Here are the findings:

Shell snippet added to every lock file:

case "${DOCKER_HOST:-}" in
  unix://* ) DOCKER_SOCK_PATH="${DOCKER_HOST#unix://}" ;;
  /* ) DOCKER_SOCK_PATH="$DOCKER_HOST" ;;
  * ) DOCKER_SOCK_PATH=/var/run/docker.sock ;;
esac
DOCKER_SOCK_GID=$(stat -c '%g' "$DOCKER_SOCK_PATH" 2>/dev/null || echo '0')
export MCP_GATEWAY_DOCKER_COMMAND='... -v '"${DOCKER_SOCK_PATH}"':/var/run/docker.sock ...'

Analysis:

Point Assessment
case "${DOCKER_HOST:-}" ✅ Properly double-quoted; prevents word-splitting and glob expansion
DOCKER_SOCK_PATH="${DOCKER_HOST#unix://}" ✅ Pure POSIX parameter expansion, no sub-shell execution
DOCKER_SOCK_PATH="$DOCKER_HOST" ✅ Double-quoted assignment, no injection surface
stat -c '%g' "$DOCKER_SOCK_PATH" ✅ Path double-quoted; stat -c '%g' outputs only numeric GID, so DOCKER_SOCK_GID is always a digit string or 0 — no injection possible via --group-add
'"${DOCKER_SOCK_PATH}"':/var/run/docker.sock in the docker command ✅ The path is wrapped in double quotes at eval time, preserving word boundaries
-e DOCKER_HOST=unix:///var/run/docker.sock passed into the container ✅ Hardcodes a safe, known value inside the container — prevents any externally tainted DOCKER_HOST value from leaking in

Threat model note: DOCKER_HOST is an infrastructure-set variable on ARC/dind runners, not workflow-author-controlled content, so the attack surface is inherently limited. Even so, all uses are properly quoted or use parameter expansion only.

No changes needed.

Resolve the Docker socket path from DOCKER_HOST instead of hardcoding
/var/run/docker.sock. Pass DOCKER_HOST through to the gateway container
so it can use custom socket paths. Auto-detect the socket GID from the
resolved path so --group-add works correctly on ARC/dind setups.

Ref #28888
@salmanmkc
salmanmkc force-pushed the salmanmkc/arc-docker-host-propagation branch from 331e57f to 30788ea Compare May 12, 2026 13:51
@github-actions

Copy link
Copy Markdown
Contributor

✅ smoke-ci: safeoutputs CLI comment + comment-memory run (25738933541)

Generated by Smoke CI for issue #31670 · ◷

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot build build-wasm and lint o

@pelikhan

Copy link
Copy Markdown
Collaborator

LGTM. Let's wait for the wasm refresh and merge.

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

@copilot build build-wasm and lint o

  • build-wasm: ✅ succeeded — gh-aw.wasm built successfully (21 MB).
  • lint: ❌ 3 pre-existing issues, none in files touched by this PR:
    • pkg/workflow/engine_helpers.go:376 — HasSuffix + TrimSuffix → CutSuffix (modernize)
    • pkg/cli/workflows.go:355 — pointer-like arg for pool (staticcheck SA6002)
    • pkg/workflow/firewall_args_test.go:56 — De Morgan's law (staticcheck QF1001)

All 3 are unrelated to the DOCKER_HOST changes in this PR. The only modified Go files (mcp_setup_generator.go, mcp_setup_generator_test.go) are clean.

Copilot AI requested a review from pelikhan May 12, 2026 14:07
@pelikhan
pelikhan merged commit d2795db into main May 12, 2026
21 of 26 checks passed
@pelikhan
pelikhan deleted the salmanmkc/arc-docker-host-propagation branch May 12, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants