fix(common-server): add listener bind to prevent blocking on multiport setup - #648
fix(common-server): add listener bind to prevent blocking on multiport setup#648stefan-ctrl wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new preflight check is skipped for TLS listeners even though production uses TLS MultiServer and serve.ServeTLS still binds inside the goroutine, so the same hang scenario can still occur.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR aims to prevent common-server/pkg/server multiport server tests (and potentially servers) from hanging when one listener fails to bind by adding a synchronous preflight bind-check before starting any serve goroutines.
Changes:
- Add a preflight
net.Listen/Closeloop for plain-HTTP listeners to fail fast on bind errors before goroutines are spawned. - Introduce
netimport and return a contextual error (listener "<addr>": ...) on preflight bind failure.
File summaries
| File | Description |
|---|---|
| common-server/pkg/server/multiport.go | Adds a preflight bind-check intended to prevent a shutdown race/hang when one of multiple listeners cannot bind. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ron96g
left a comment
There was a problem hiding this comment.
Really minor bug that probably cannot really happen in prod, unless we misconfigure ports. Just one comment
… and improve error handling
ron96g
left a comment
There was a problem hiding this comment.
some minor things. Mainly I would use the net.Listener over the addr in most cases
Goal
Fix the Timeout bug as seen in main: https://github.com/telekom/controlplane/actions/runs/33595609763/job/100138458027#step:6:58
Description
Issue
pkg/servertests could hang for 10 minutes:MultiServer.Runbound each listener lazily inside its own goroutine (app.Listen(addr)), while a separate goroutine shuts down all apps exactly once whenctxis cancelled.ctx.Shutdown()was a no-op on it (fiber only supports shutdown once serving has started).Accept()forever.Root Cause
According to AI:
This race has existed since
MultiServerwas introduced in #507 and just never lost the coin flip in CI Verified across ~30 recent runs — all green, ~5s each.Personal Note:
Seems kinda unlikely that nothing has changed and a "coin flip" was always in our favor, since it now fails constantly.
However, I would not consider it worth it to explore potential root causes even further, and instead fix this issue and move on.