-
Notifications
You must be signed in to change notification settings - Fork 150
Auto-generate session names for serverless SSH connect #4701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anton-107
wants to merge
10
commits into
main
Choose a base branch
from
antonnek/auto-session-names
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
351ca74
Hide verbose SSH connect output behind --log-level, add spinners
anton-107 0d2ce6e
Address review comments: fix spinner cleanup and keep run ID visible
anton-107 d6b28ab
Add elapsed time display (MM:SS) to spinners
anton-107 d775a8b
Address review: elapsed time as prefix, initialized at construction time
anton-107 b27e7cf
Replace --name flag with auto-generated session names and reconnect s…
anton-107 083521b
fix lint
anton-107 e8fa14a
Address review comments: identity tracking, safe cleanup, no StrictHo…
anton-107 feae597
fix lint
anton-107 c73e523
fix unit test
anton-107 6575760
Improve IDE settings prompt formatting and default to yes (#4705)
anton-107 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package sessions | ||
|
|
||
| import ( | ||
| "crypto/md5" | ||
| "crypto/rand" | ||
| "encoding/hex" | ||
| "fmt" | ||
| "strings" | ||
| "time" | ||
| ) | ||
|
|
||
| // acceleratorPrefixes maps known accelerator types to short human-readable prefixes. | ||
| var acceleratorPrefixes = map[string]string{ | ||
| "GPU_1xA10": "gpu-a10", | ||
| "GPU_8xH100": "gpu-h100", | ||
| } | ||
|
|
||
| // GenerateSessionName creates a human-readable session name from the accelerator type | ||
| // and workspace host. The workspace host is hashed into the name to avoid SSH known_hosts | ||
| // conflicts when connecting to different workspaces. | ||
| // Format: databricks-<prefix>-<date>-<workspace_hash><random_hex>. | ||
| func GenerateSessionName(accelerator, workspaceHost string) string { | ||
| prefix, ok := acceleratorPrefixes[accelerator] | ||
| if !ok { | ||
| prefix = strings.ToLower(strings.ReplaceAll(accelerator, "_", "-")) | ||
| } | ||
|
|
||
| date := time.Now().Format("20060102") | ||
|
|
||
| // Include a short hash of the workspace host to avoid known_hosts conflicts | ||
| // when connecting to different workspaces. | ||
| wsHash := md5.Sum([]byte(workspaceHost)) | ||
| wsHashStr := hex.EncodeToString(wsHash[:])[:4] | ||
|
|
||
| b := make([]byte, 3) | ||
| if _, err := rand.Read(b); err != nil { | ||
| panic(fmt.Sprintf("crypto/rand.Read failed: %v", err)) | ||
| } | ||
| return "databricks-" + prefix + "-" + date + "-" + wsHashStr + hex.EncodeToString(b) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Agent Swarm Review] [Critical]
Any probe error is treated as proof that the session is stale.
resolveServerlessSession()callscleanupStaleSession()for everygetServerMetadata()failure. That probe can fail for transient auth, network, workspace API, or version-mismatch reasons. In those cases the CLI will delete local SSH config, remove the session from state, and best-effort delete secret scopes and workspace content for a session that may still be alive.Both reviewers flagged this. Isaac confirmed Critical in cross-review due to irreversible blast radius.
Suggestion: Only run destructive cleanup on definitive stale signals (e.g., 404/not-found). For transient errors, keep the session and surface a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Now only
errServerMetadata(definitive not-found) triggers cleanup. Transient errors (network, auth) are logged as warnings and the session is kept.