Repository navigation
fix: give each instance its own SSH lookup timeout during refresh - #483
Conversation
|
|
||
| workspace, err := resolveWorkspaceSSH(ctx, client, userID, workspaces[i]) | ||
| if ctx.Err() != nil { | ||
| log.Printf("workspace SSH access: lookup budget exhausted, using legacy configuration for the remaining instances") |
There was a problem hiding this comment.
What does it mean to "use the legacy configuration for the remaining instances"?
There was a problem hiding this comment.
@stephahart
"Legacy configuration" means the SSH details that already come with the instance list: hostname (public DNS), port and user, or the Cloudflare proxy hostname for tunnel-based instances. Before #424, ssh_config (and so brev shell) only used these.
Normally refresh looks up SSH Access for each running instance and replaces those values. If that lookup doesn't happen, the ssh_config entry is written from the instance-list values instead. Cert-auth instances may not connect until a later refresh, but brev shell already refreshes and retries on connection failure.
This is the same fallback main uses today: once its shared 10s runs out, every remaining lookup fails immediately and falls back, logging one line per instance. The PR gives each instance its own 10s with a 30s total, and once that's used up it stops calling and logs a single line.
Thanks
Issue
brev refresh looks up SSH access for every running instance in the org, one instance at a time. All of these lookups shared a single 10s timeout that was created before the loop, so the 10s was a budget for the whole org rather than a limit for each instance.
Once the earlier instances had used up that budget, the later ones failed immediately with context deadline exceeded and silently fell back to the legacy SSH config. For cert-auth instances, the fallback config has no SSH certificate block, so SSH to those instances fails.
Approach to fix
The SSH lookup timeout design changes:
Before: one 10s timeout shared across all instances.
After: 10s per instance, with the whole lookup capped at 30s.
Each instance's lookup now gets its own 10s timeout, created inside the loop and derived from a 30s overall budget. If the 30s budget is used up, the loop stops, logs one summary line, and leaves the remaining instances on the legacy config. Previously it logged one warning per instance.