#1874

[Bug]: `container-ip` routes go stale when a container's IP changes, and nothing refreshes them (502 until `routing/retry`)

Opentuurboopened 11d ago

Existing issue

  • I have searched the existing issues and found no duplicate.

Problem description

With routeStrategy: container-ip, the edge vhosts proxy to the routed container's bridge IP. If that container comes back with a different IP, the vhosts keep the old one and the domain returns 502 indefinitely. No background job notices or repairs it. Only POST /api/projects/:id/routing/retry (or a redeploy) rewrites the vhosts with the live IP.

Expected: Openship notices the routed container's IP changed and rewrites the vhost, or at least reports a routing issue.

Actual:

  • The edge logs connect() failed (113: Host is unreachable) while connecting to upstream against the old IP, and the domain returns 502.
  • In our case this lasted over an hour, until we called routing/retry by hand.
  • Meanwhile everything reported healthy:
    • the containers were all running;
    • routing/edge-status said ready;
    • edge-config showed no drift.

A plain docker restart and a plain host reboot did not reproduce it for us. Docker returned the same IPs both times. It appears only when the IP actually changes.

Steps to reproduce

  1. Deploy a project with routeStrategy: container-ip and confirm its domain serves.
  2. Make the routed container come back with a different bridge IP. Any of these does it:
    • power the deployment server off and on so containers restart in a different order (in our case, during a droplet resize);
    • or simulate it: docker network disconnect <project-network> <container>, start a placeholder container on that network with --ip <old-ip>, then docker network connect <project-network> <container>.
  3. Request the domain.

Environment

  • OpenShip version/commit: v1.0.1
  • Deployment method: self-hosted; the controller and the deployment server are separate machines, and the deployment server runs the containerized edge. A Compose (multi-service) project with routeStrategy: container-ip, where one exposed service owns the custom domains.
  • Operating system: Ubuntu 26.04 (deployment server)
  • Browser (if applicable): n/a

Logs and screenshots

Edge log while the route was stale:

connect() failed (113: Host is unreachable) while connecting to upstream, upstream: "http://<old-container-ip>:80/..."

Additional context

Cause, from reading the source at v1.0.1

  • The generated vhosts contain a literal proxy_pass http://<container-ip>:<port>, with no resolver or Lua balancer.
  • None of the background paths re-resolve it:
    • The health watch (packages/platform/src/engine/modules/jobs/job.registry.ts) and Docker container events (monitoring/container-events.ts) only check that containers are running.
    • routing/edge-status (apps/api/src/modules/domains/ensure-edge.controller.ts) only checks that the edge container is running.
    • edge-config (projects/edge-config.service.ts) compares proxy tunables, not proxy_pass.
    • The startup hooks reconcile only Openship's own routes.
  • routing/retry → project-runtime.service.ts re-inspects the live container IP (upstream-url.ts) and rewrites the vhosts. That's why it fixes the problem.

Suggested fix

  • On container start/restart events, or in the health watch, compare each container-ip route's upstream with the routed container's current IP. Rewrite the vhost when they differ, or at least raise an issue.
  • Report a stale upstream in routing/edge-status, so the dashboard shows it.

Activity

0

No activity yet.