Skip to content

fix: give each instance its own SSH lookup timeout during refresh - #483

Merged
stephahart merged 1 commit into
mainfrom
BREV-11815/ssh-lookup-per-instance-timeout
Oct 8, 2026
Merged

stephahart merged 1 commit into
mainfrom
BREV-11815/ssh-lookup-per-instance-timeout

Conversation

@shivamj-del

Copy link
Copy Markdown
Contributor

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.

@shivamj-del shivamj-del self-assigned this Sep 28, 2026

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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean to "use the legacy configuration for the remaining instances"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

@shivamj-del
shivamj-del marked this pull request as ready for review September 30, 2026 06:25
@shivamj-del
shivamj-del requested a review from a team as a code owner September 30, 2026 06:25
@stephahart
stephahart merged commit 321c324 into main Oct 8, 2026
9 checks passed
@stephahart
stephahart deleted the BREV-11815/ssh-lookup-per-instance-timeout branch October 8, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants