fix(ssh-console): test_ssh_console_reconnect hang (#1150)#2615
Conversation
…hang (NVIDIA#1150) The mock API server dropped its picked port before re-binding it for the gRPC server, so under concurrency another test could take the port in that gap: the re-bind failed silently and ssh-console hung retrying a dead port. Bind the listener once and serve on it directly. Signed-off-by: Adnan Dosani <258082943+adnandnv@users.noreply.github.com>
…connect-test-hang Signed-off-by: Adnan Dosani <258082943+adnandnv@users.noreply.github.com>
Summary by CodeRabbit
WalkthroughThe mock API server startup in ChangesPre-bound TcpListener for mock server startup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🌿 Preview your docs: https://nvidia-preview-pull-request-2615.docs.buildwithfern.com/infra-controller |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/ssh-console-mock-api-server/src/lib.rs (1)
103-107: ⚡ Quick winUnnecessary address conversion chain.
listener.local_addr()already returnsSocketAddr. The subsequent.to_socket_addrs()?.next().expect(...)is redundant—SocketAddr::to_socket_addrs()merely wraps itself in a single-element iterator, making this conversion a no-op that obscures intent.♻️ Simplify address extraction
let listener = TcpListener::bind("127.0.0.1:0").await?; - let addr = listener - .local_addr()? - .to_socket_addrs()? - .next() - .expect("No socket available"); + let addr = listener.local_addr()?;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/ssh-console-mock-api-server/src/lib.rs` around lines 103 - 107, The address extraction in the listener initialization block performs a redundant conversion chain. The listener.local_addr() method already returns a SocketAddr, so the subsequent .to_socket_addrs()?.next().expect(...) calls are unnecessary and obscure intent. Simplify this by removing the redundant .to_socket_addrs()?.next().expect("No socket available") portion and directly use listener.local_addr()? to assign the SocketAddr to the addr variable.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/ssh-console-mock-api-server/src/lib.rs`:
- Around line 103-107: The address extraction in the listener initialization
block performs a redundant conversion chain. The listener.local_addr() method
already returns a SocketAddr, so the subsequent
.to_socket_addrs()?.next().expect(...) calls are unnecessary and obscure intent.
Simplify this by removing the redundant .to_socket_addrs()?.next().expect("No
socket available") portion and directly use listener.local_addr()? to assign the
SocketAddr to the addr variable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: df72820f-d4f0-46c1-aa75-97dd64bdb75d
📒 Files selected for processing (1)
crates/ssh-console-mock-api-server/src/lib.rs
Description
test_ssh_console_reconnectintermittently hangs in CI until the job times out.The mock API server bound
127.0.0.1:0, dropped the socket, then re-bound the sameport for its gRPC server. Under concurrency another test could take the port in that
gap, so the re-bind failed silently and ssh-console was left retrying a dead port --
hanging the test. Fix: bind the listener once and serve on it directly.
Related issues
#1150
Type of Change
Breaking Changes
Testing
Ran the ssh_console test 100 times locally. Before: 5 hangs, after: 0 hangs.
Additional Notes