client, test/suites: forward session timeout cause over websocket - #1519
client, test/suites: forward session timeout cause over websocket#1519shardool-patil wants to merge 2 commits into
Conversation
roosterfish
left a comment
There was a problem hiding this comment.
Thanks for taking a look at this, please see my comments on the test.
| echo "Initiate a MicroCloud cluster with a short session timeout and verify the joiner receives the timeout error" | ||
| export MULTI_NODE="yes" | ||
| export LOOKUP_IFACE="enp5s0" | ||
| export EXPECT_PEERS=1 |
There was a problem hiding this comment.
I guess what you would need here is export EXPECT_PEERS=2, then let only micro02 attempt to join. As micro01 is the initiator, it will wait for two peers, but only micro02 reaches out so it will cause the session to expire.
| validate_system_microovn ${m} | ||
| done | ||
| } | ||
| } No newline at end of file |
| lxc exec micro04 -- tail -1 out | grep "Failed waiting during join: Initiator aborted the setup" -q | ||
|
|
||
| # Initiate a MicroCloud cluster with a short session timeout and verify the joiner receives "Session timeout exceeded". | ||
| reset_systems 2 3 0 |
There was a problem hiding this comment.
2 is the number of peers, 3 number of disks, 0 number of extra interfaces.
As we never reach the config stage and don't require a disk, you can also do 2 0 0 here.
There was a problem hiding this comment.
Pull request overview
This PR improves MicroCloud’s WebSocket session handling so that when a trust establishment session expires, the client receives the real cancellation cause (e.g., “Session timeout exceeded”) rather than a generic abnormal WebSocket EOF error, aligning behavior with issue #1245.
Changes:
- Adjusts the WebSocket gateway close-path to reliably send a
ControlClosemessage even when the gateway context is canceled. - Improves receive behavior to surface the gateway context cause when the receive channel closes.
- Adds a system test intended to validate that both initiator and joiner surface the timeout error.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| client/websocket.go | Ensures close-cause forwarding works reliably and improves receive-side error reporting when the socket closes. |
| test/suites/basic.sh | Adds an interactive test case intended to validate session-timeout error propagation to initiator/joiner. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| export SESSION_TIMEOUT="5" | ||
|
|
||
| ! join_session init micro01 micro02 || false |
| # Initiate a MicroCloud cluster with a short session timeout and verify the joiner receives "Session timeout exceeded". | ||
| reset_systems 2 3 0 | ||
| unset_interactive_vars | ||
|
|
||
| echo "Initiate a MicroCloud cluster with a short session timeout and verify the joiner receives the timeout error" |
| return context.Cause(w.ctx) | ||
| } | ||
|
|
||
| return errors.New("Websocket connection closed") |
|
@roosterfish i have addressed all the requested changes:
take a look whenever possible |
Signed-off-by: Shardool Patil <shardoolpatil999@gmail.com>
b287951 to
4ffe082
Compare
|
See the test failure https://github.com/canonical/microcloud/actions/runs/32477357735/job/96766897819?pr=1519#step:3:45500. |
4ffe082 to
14a4c0b
Compare
@roosterfish I have worked and handled the requested changes so take a look at the code. |
14a4c0b to
c3f95c6
Compare
|
@roosterfish I switched the test to |
Signed-off-by: Shardool Patil <shardoolpatil999@gmail.com>
c3f95c6 to
e98fe8e
Compare
|
@roosterfish I've updated
Please take a look at this setup before re-running the tests. |
Description
When a trust establishment session expires, the client previously received a generic connection error (
websocket: close 1006: unexpected EOF) instead of the actual cause (Session timeout exceeded)[cite: 5].Changes
client/websocket.go:WriteCloseto writeControlClosedirectly over the WebSocket underwriteLockso close frames are sent even whengwCtxis canceled on timeout[cite: 5].ReceiveWithContextto check channel closure and returncontext.Cause(w.ctx)[cite: 5].test/suites/basic.sh:test_interactivewithSESSION_TIMEOUT="5"verifying that both the initiator and joiner receive"Session timeout exceeded"[cite: 2].Checklist
Related issues
@roosterfish i have taken into consideration the insights you provided and resolved the issue, so take a look at it when you get time.