Skip to content

fix(updater): block updates that would stop WUDup's Docker endpoint - #888

Merged
magrhino merged 2 commits into
mainfrom
claude/recursing-taussig-50dde9
Oct 16, 2026
Merged

magrhino merged 2 commits into
mainfrom
claude/recursing-taussig-50dde9

Conversation

@magrhino

Copy link
Copy Markdown
Owner

Summary

In a production run, one stack's update scope included both WUD and the socket proxy that serves WUDup's DOCKER_HOST (tcp://<proxy>:2375). When the stop phase took the proxy down, every later Docker call failed, and recovery and rollback both failed. The existing self-protection guard only covers WUDup's own image and container, so it missed this. This PR makes the updater preflight fail closed before any mutation when a recreate scope would stop or recreate the container serving WUDup's Docker endpoint.

  • validate_self_update_scope (src/wudup/updater_preflight.py): when DOCKER_HOST is tcp/http/https, inspect the running containers in each stack's scope and block the stack with the new reason docker-endpoint-recreate-blocked and a plain-language message if the host matches a container name, network alias/DNS name, IP, or ID prefix. A failed compose ps or inspect also blocks the stack.
  • The check also runs for CLI runs when DOCKER_HOST is a network endpoint. Before this, the function returned early when protected_container was unset. A CLI run inside the WUDup container hits the same failure, and those runs now reuse the strictly verified scope.
  • WUD itself is not blocked: WUDup keeps Docker access while WUD restarts. The end-of-run WUD API refresh is already best-effort; tests/test_python_web_jobs.py covers a WUD error and a degraded snapshot.
  • New helpers: docker_endpoint_host / container_dns_names (container_identity.py) and DockerCli.container_dns_details, which uses a narrow inspect template, so the container env is never read.
  • Docs: docs/wiki/webui-container.md describes the guard and its limits.

Scope

  • This PR has one reviewable objective
  • Follow-up work, stacked PRs, or intentionally deferred changes are called out here:
    • Like the existing self guard, a blocked stack fails the whole run before mutation. Other selected stacks are recorded as preflight-skipped and stay pending; they are not applied in the same run.
    • Matching does not detect an endpoint reached through a published host port, a proxy that shares another container's network via network_mode, or a DOCKER_CONTEXT endpoint. The docs say so. A same-named service on a network WUDup is not attached to can still be blocked (fails closed).
    • The retag apply path has no self/endpoint guard: Retag apply can stop WUDup or its Docker endpoint socket proxy without a recreate-scope guard #887.

Checklist

  • Tests added or updated
  • README.md or docs/ updated if install, deployment, config, or user-facing behavior changed
  • docs/examples/template.env or docs/examples/webui.env.example updated if environment variables or example config changed: N/A - no new variables
  • Release Please/changelog impact considered; no manual CHANGELOG.md edit needed outside release prep

Test plan

  • tests/run-all.sh: N/A - ran the Python subset below
  • tests/run-all.sh --python (2191 passed, 1 skipped)
  • ruff check .
  • Focused test(s):
    • tests/test_python_update_from_wud_docker_endpoint.py (endpoint scope blocked before rewrite/pull/stop; WUD-only scope passes; unix socket unaffected; inspect, malformed output and compose ps failures fail closed; WebUI path; dry-run)
    • tests/test_python_update_from_wud_recreate.py
    • tests/test-docker-update-from-wud.sh
  • Docker or Compose validation, if container behavior changed: N/A - no local Docker daemon. The inspect template has not been run against real Docker output.

When DOCKER_HOST points at a network endpoint such as a socket proxy, the self-protection preflight now inspects the running containers in each stack's recreate scope and blocks the stack (docker-endpoint-recreate-blocked) if one of them serves that endpoint. Stopping it would cut WUDup off from Docker so it could not finish or roll back. Lookup failures fail closed; unix-socket DOCKER_HOST is unaffected and WUD itself stays updatable.
@sourcery-ai

sourcery-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown

Sorry @magrhino, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 16 hours and 14 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c9d74c09-935c-4f54-b32d-38d7ad43140a
📥 Commits

Reviewing files that changed from the base of the PR and between f6201db and d052ea2.

📒 Files selected for processing: 7
  • docs/wiki/webui-container.md
  • src/wudup/container_identity.py
  • src/wudup/docker_cli.py
  • src/wudup/updater_preflight.py
  • tests/fakes/docker
  • tests/test_python_update_from_wud_docker_endpoint.py
  • tests/update_from_wud_helpers.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

For network DOCKER_HOST endpoints, scoped containers are checked against the endpoint host during update preflight. Matching or uninspectable containers block mutation. Unix-socket endpoints skip the check, while WUD-only updates remain allowed.

Changes: Docker Endpoint Update Protection

Layer / File(s) Summary
Endpoint and container identity
src/wudup/container_identity.py, src/wudup/docker_cli.py, tests/fakes/docker, tests/test_python_update_from_wud_docker_endpoint.py
Helpers parse supported endpoint hosts and collect normalized container names, IDs, aliases, DNS names, and addresses. DockerCli retrieves container network details as JSON. The fake Docker command and tests cover these details.
Preflight protection and validation
src/wudup/updater_preflight.py, tests/test_python_update_from_wud_docker_endpoint.py, tests/update_from_wud_helpers.py, docs/wiki/webui-container.md
The preflight blocks scopes that include the protected WUD container or a container matching the endpoint host. Lookup and scope-verification failures also block the update. Tests cover failure handling, dry runs, Unix-socket endpoints, and WUD-only updates. The documentation describes the check and its limits.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Preflight as validate_self_update_scope
  participant DockerCli
  participant DockerDaemon as Docker daemon
  Preflight->>DockerCli: retrieve scoped container IDs
  DockerCli->>DockerDaemon: inspect container network details
  DockerDaemon-->>DockerCli: return container details as JSON
  DockerCli-->>Preflight: provide parsed container details
  Preflight->>Preflight: compare container DNS names with endpoint host
  Preflight-->>Preflight: block matching or uninspectable scope
Loading
Merge Risk: ⚪ Minimal · up to d052e

The change adds a fail-closed preflight check that blocks updates which would stop the Docker endpoint serving WUDup. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the main change: blocking updates that would stop WUDup's Docker endpoint.
Description check Passed The description follows the required template. It explains the production failure, lists implementation changes, defines scope and deferred work, records checklist status, and reports test results and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR extends updater preflight self-protection to detect and block recreate scopes that would terminate the container serving WUDup’s network-based DOCKER_HOST, using narrowly scoped container inspection and fail-closed error handling, with comprehensive tests and deployment documentation.

File-Level Changes

Change Details Files
Adds fail-closed preflight protection for network-based Docker endpoints used by WUDup.
  • Parses network DOCKER_HOST values while leaving Unix sockets and unsupported endpoint types unchanged.
  • Inspects scoped containers using a narrow Docker inspect template and matches endpoint hosts against container names, aliases, DNS names, IPs, and ID prefixes.
  • Blocks affected stacks before compose mutations with a dedicated failure reason and actionable message; inspection and compose lookup failures also block.
  • Applies the endpoint check to CLI and WebUI flows while allowing WUD-only updates and preserving existing self-update protection.
src/wudup/container_identity.py
src/wudup/docker_cli.py
src/wudup/updater_preflight.py
Adds coverage for endpoint matching, fail-closed behavior, and update-path compatibility.
  • Tests blocking before pull, stop, rewrite, or other mutation when the endpoint container is selected.
  • Covers WUD-only updates, Unix socket hosts, WebUI and dry-run behavior, malformed inspect output, inspect failures, and compose ps failures.
  • Updates Docker fakes and test setup to support endpoint metadata and isolate DOCKER_HOST.
tests/test_python_update_from_wud_docker_endpoint.py
tests/fakes/docker
tests/update_from_wud_helpers.py
Documents the endpoint guard, supported matching behavior, and known deployment limitations.
  • Explains that network endpoint containers in recreate scopes are blocked before mutation.
  • Documents unsupported published-port, network_mode, Docker context, and same-network assumptions, plus the continued ability to update WUD itself.
docs/wiki/webui-container.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Warnings
⚠️

Docker, Compose, or socket-adjacent files changed. Confirm Docker/Compose validation in the PR test plan, or add Danger: docker-review-complete with the reason.

Changed: src/wudup/docker_cli.py

⚠️

tests/test_python_update_from_wud_docker_endpoint.py adds Docker/socket-adjacent text. Confirm socket-proxy/raw-socket assumptions, read-only defaults, and Docker validation.

Add Danger: docker-socket-review-complete if reviewed.

⚠️

docs/wiki/webui-container.md adds Docker/socket-adjacent text. Confirm socket-proxy/raw-socket assumptions, read-only defaults, and Docker validation.

Add Danger: docker-socket-review-complete if reviewed.

⚠️

src/wudup/container_identity.py adds Docker/socket-adjacent text. Confirm socket-proxy/raw-socket assumptions, read-only defaults, and Docker validation.

Add Danger: docker-socket-review-complete if reviewed.

⚠️

src/wudup/updater_preflight.py adds Docker/socket-adjacent text. Confirm socket-proxy/raw-socket assumptions, read-only defaults, and Docker validation.

Add Danger: docker-socket-review-complete if reviewed.

⚠️

tests/update_from_wud_helpers.py adds Docker/socket-adjacent text. Confirm socket-proxy/raw-socket assumptions, read-only defaults, and Docker validation.

Add Danger: docker-socket-review-complete if reviewed.

Generated by 🚫 dangerJS against d052ea2

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/wudup/container_identity.py 93.10% 0 Missing and 2 partials ⚠️
src/wudup/updater_preflight.py 95.83% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@magrhino
magrhino added this pull request to stack #892 October 16, 2026 03:22
@magrhino
magrhino merged commit f59014f into main Oct 16, 2026
25 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.

1 participant