Skip to content

fix(routing): fall back to container IP when loopback port is not published - #508

Closed
santhiprakash wants to merge 1 commit into
oblien:mainfrom
santhiprakash:fix/migration-auto-loopback-506
Closed

fix(routing): fall back to container IP when loopback port is not published#508
santhiprakash wants to merge 1 commit into
oblien:mainfrom
santhiprakash:fix/migration-auto-loopback-506

Conversation

@santhiprakash

Copy link
Copy Markdown
Contributor

Summary

Fixes #506.

Same-server migrations that attach the running container in place (reuse) never publish a 127.0.0.1 host port, so the default Auto → loopback-port strategy left the app unreachable through its custom domain. The edge had no loopback binding to dial.

Change

Make the live route-apply paths inspect the container first, then fall back to the container's bridge/host IP when no loopback host port is bound:

  • resolveUpstreamUrl now falls through from a loopback host port to the container IP when hostPort is absent.
  • applyProjectRouting resolves a live upstream per service_deployment row, using getContainerInfo for the current host port and getContainerIp as the fallback.
  • service.service updateService does the same live resolution when publishing or editing a service route, so migrated domains register with the correct container-IP target instead of a missing loopback port.

Test plan

  • apps/api/src/lib/upstream-url.test.ts – unit tests for buildUpstreamUrl and resolveUpstreamUrl, including the loopback → container-IP fallback.
  • apps/api/src/modules/domains/routing-apply.service.test.ts – tests that applyProjectRouting falls back to the container IP when the migrated container has no loopback host port, uses the live loopback port when present, and still falls back when live inspection fails.
  • bun run lint (tsc --noEmit) passes.
  • Targeted bun vitest run src/modules/migration passes.

…lished

Same-server migrations that attach the running container in place (reuse)
never publish a 127.0.0.1 host port, so the default "Auto → loopback-port"
strategy left the app unreachable through its custom domain. The edge could
not reach the container because it had no loopback binding to dial.

Make the live route-apply paths inspect the container first, then fall back
to the container's bridge/host IP when no loopback host port is bound:

- resolveUpstreamUrl now falls through from a loopback host port to the
  container IP when hostPort is absent.
- applyProjectRouting resolves a live upstream per service_deployment row,
  using getContainerInfo for the current host port and getContainerIp as the
  fallback.
- service.service updateService does the same live resolution when publishing
  or editing a service route, so migrated domains register with the correct
  container IP target instead of a missing loopback port.

Adds focused tests for the fallback in upstream-url and routing-apply.
@santhiprakash

Copy link
Copy Markdown
Contributor Author

Closing — upstream main now resolves route upstreams from the live container (resolveLiveUpstreamUrl in apps/api/src/modules/domains/routing-apply.service.ts) so workloads without a published loopback port route at their container IP, which is what this PR implemented for #506.

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.

[Bug] Same-server migration leaves app unreachable — "Auto" routing mode doesn't publish a loopback port

1 participant