#1874
[Bug]: `container-ip` routes go stale when a container's IP changes, and nothing refreshes them (502 until `routing/retry`)
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 upstreamagainst the old IP, and the domain returns 502. - In our case this lasted over an hour, until we called
routing/retryby hand. - Meanwhile everything reported healthy:
- the containers were all running;
routing/edge-statussaid ready;edge-configshowed 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
- Deploy a project with
routeStrategy: container-ipand confirm its domain serves. - 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>, thendocker network connect <project-network> <container>.
- 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, notproxy_pass.- The startup hooks reconcile only Openship's own routes.
- The health watch (
routing/retry→project-runtime.service.tsre-inspects the live container IP (upstream-url.ts) and rewrites the vhosts. That's why it fixes the problem.
Suggested fix
- On container
start/restartevents, or in the health watch, compare eachcontainer-iproute'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
0No activity yet.