Repository navigation
fix(cli): retry transient connection failures during SSH setup - #24010
Conversation
23b6fee to
052d779
Compare
052d779 to
6667c95
Compare
e3d3703 to
b689ea8
Compare
3aaba90 to
d7e0867
Compare
|
This still feels half-baked.
|
d7e0867 to
ebe4912
Compare
|
The issue is this code here is very monolithic and sequential which makes the maintenance here harder than it should be.
True, if the dial fails there's no reason to re-resolve the workspace. The resolve result could be cached and only the dial retried. Right now the establishment function bundles resolve + dial together, so the retry re-does both. I can split it so the resolve happens once and only the dial is retried. Is this worth doing?
In interactive mode the user sees the error and can retry manually. In stdio mode, |
|
I agree that the code is not well structured and difficult to maintain. Let's not make the problem worse. I'm in the process of rearchitecting this code right now, to use a state machine and a new watch on the workspace to replace the workspace and agent resolution code. https://www.notion.so/coderhq/coder-ssh-watch-and-FSM-329d579be59280e3979bfae59051a54e?d=309d579be59283609af183ec14f89244 Still, there will be some initial API requests that get server settings and the like. If we need to include retries, I would much rather wrap individual steps in retries, with an overall context timeout so we don't retry forever. That way you can decide on a step-by-step basis what is transient/retryable, and you don't have to restart the whole process if you hit an error part way through. |
|
How about I add per-step retry, can be cancelled by the user (Ctrl + C or killing the parent process etc), and it retries up to X times for each step? I can add a total timeout but I'm not sure about this value because what if this process used to take 60s? 100s? Maybe even more (it had no timeout before). A follow up here is, do we want to retry only in |
Per step retry sounds fine. Total timeout might get tricky since we wait for the build, so a per-step retry count is probably fine.
I'd prefer to keep things going down the same code paths as we bring up the tunnel. |
ebe4912 to
8c14f28
Compare
Wrap each network step in the SSH connection flow with retryWithBackoff so transient errors (DNS, connection refused, server 5xx) are retried individually with exponential backoff. Both stdio and interactive modes retry identically since tunnel establishment is not an application-layer concern. Retried steps: workspace resolution, template version fetch, agent connection info, Coder Connect dial, and tailnet dial. Data transfer (copier.copy/Bicopy) is never retried.
8c14f28 to
8e19be8
Compare
When
coder sshconnects to a workspace after laptop wake, DNS or the control plane may be briefly unavailable. Previously this caused an immediate failure, which VS Code Remote SSH classified as permanent ("Reload Window").Wrap each network step (workspace resolution, template version fetch, agent connection info, Coder Connect dial, tailnet dial) with
retryWithIntervalso transient errors (DNS, connection refused, 5xx) are retried individually. Non-retryable errors (auth, 404) and context cancellation stop immediately. Data transfer is never retried.Fixes #24005