Skip to content

fix: bound container stop and raise Docker API timeout on deploy - #53

Merged
compscidr merged 1 commit into
mainfrom
docker-timeouts-on-replace
Aug 10, 2026
Merged

fix: bound container stop and raise Docker API timeout on deploy#53
compscidr merged 1 commit into
mainfrom
docker-timeouts-on-replace

Conversation

@compscidr

Copy link
Copy Markdown
Owner

Problem

First playbook run against a host with an existing (especially crash-looping) runner container fails:

Error removing container <id>: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

…and the immediate rerun succeeds. Replacing the container stops+removes the old one first; a crash-looping or wedged runner can take longer than the Docker SDK's 60s default client timeout to stop and remove. The timeout only kills the client's wait — the daemon finishes the removal in the background, which is why the second pass works.

Fix

Two new role vars, applied to the docker_container deploy task:

  • github_runner_docker_timeout (default 180) → module timeout: gives the API client room to wait out a slow stop+remove.
  • github_runner_stop_timeout (default 10) → container stop_timeout: bounds the graceful SIGTERM window before SIGKILL, so replacement stays fast even when the runner process is wedged. Deliberately not force_kill — a deploy racing a running CI job still gets a few seconds of cleanup.

Also bumps the collection to 0.1.4 with CHANGELOG and README variable-table entries, per repo convention.

Testing

  • ansible-lint clean (production profile, 33 files).
  • YAML parse validated on the changed role files.

🤖 Generated with Claude Code

Replacing an existing runner container (image bump) stops and removes it
first. A crash-looping or wedged runner can take longer than the Docker
SDK's 60s default read timeout to stop+remove, failing the first playbook
run with 'UnixHTTPConnectionPool ... Read timed out (read timeout=60)' —
the daemon finishes the removal in the background, which is why an
immediate rerun succeeds.

Add github_runner_stop_timeout (default 10) to bound the graceful stop and
github_runner_docker_timeout (default 180) to give the API client room to
wait out a slow removal.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 10, 2026 19:05

Copilot AI left a comment

Copy link
Copy Markdown

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 make runner container replacement more reliable on hosts where an existing runner container is crash-looping or otherwise slow to stop/remove, by bounding container stop time and increasing the Docker client/API timeout during deployment.

Changes:

  • Add two new role defaults: github_runner_stop_timeout and github_runner_docker_timeout.
  • Apply the new stop/API timeout settings to the runner container deploy task.
  • Bump collection version to 0.1.4 and document the change in CHANGELOG.md and README.md.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
roles/github_runner/tasks/main.yml Adds stop/removal timing controls to the runner container deploy task.
roles/github_runner/defaults/main.yml Introduces defaults for stop timeout and Docker API/client timeout.
README.md Documents the two new role variables in the variable table.
galaxy.yml Bumps collection version to 0.1.4.
CHANGELOG.md Adds a 0.1.4 entry describing the fix and new variables.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread roles/github_runner/tasks/main.yml
@compscidr
compscidr merged commit 89c15e9 into main Aug 10, 2026
7 checks passed
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.

2 participants