Skip to content

Remove legacy sandbox SSH key registration commands - #8098

Merged
HsingTang merged 3 commits into
mainfrom
HsingTang/remove-sandbox-ssh-key-registration
Nov 27, 2026
Merged

HsingTang merged 3 commits into
mainfrom
HsingTang/remove-sandbox-ssh-key-registration

Conversation

@HsingTang

@HsingTang HsingTang commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Remove sandbox register and sandbox ssh-key list/delete, including their dedicated registry HTTP calls, key generation, key hashing, completion, and gateway SSH-config writer. Retired commands return an error. Document migration to port-forwarding-backed sandbox ssh and sandbox ssh-setup; existing local keys, SSH configuration, and server registrations remain untouched.

Why

Sandbox SSH uses authenticated port forwarding, so separate gateway key registration is no longer part of the supported connection path.

Tests

  • All 30 affected sandbox acceptance cases pass against the local fake server. The retirement case checks error exits, no registry HTTP requests, unchanged pre-existing key/config files, a fresh home, and supported SSH help. Existing lifecycle, forwarding, filesystem, and ssh-setup coverage passes.
  • 61 sandbox/root unit tests and 14 focused OAuth SSH/ssh-setup/identity/config tests pass; pinned Go formatting, sandbox lint, changed-file whitespace, and changelog validation pass. Test subprocesses isolate an inherited Databricks profile; the initial profile-dependent failure was reproduced with unchanged main state logic.
  • Local Isaac review completed with no remaining findings after correcting the command error handling and acceptance coverage. No live sandbox validation was run. Remote CI/review status is separate from these local results; the PR is ready for review.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: 4b7820579 | Workflow run

Selected 2 changed tests (limit=20, 0 not selected)

2 tests: regression=1 unreleased=0 coverage=1 failing=0
test branch main (daf81c6) latest (v1.28.0)
TestAccept/cmd/sandbox/legacy-key-revocation ✅ ✅ ✅
TestAccept/cmd/sandbox/retired-key-commands ✅ ❌ ❌
TestAccept/cmd/sandbox/retired-key-commands: branch ✅ | main (daf81c6) ❌ | latest (v1.28.0) ❌

main (daf81c6):

server.go:281: No handler for URL: /api/2.0/lakebox/ssh-keys
        Body: [77 bytes] {"public_key":"synthetic legacy public key fixture\n","name":"runnervmeozm8"}
        
        For acceptance tests, add this to test.toml:
        [[Server]]
        Pattern = "POST /api/2.0/lakebox/ssh-keys"
        Response.Body = '<response body here>'
        # Response.StatusCode = <response code if not 200>
    server.go:281: No handler for URL: /api/2.0/lakebox/ssh-keys
        Body: [76 bytes] {"public_key":"synthetic legacy public key fixture\n","name":"test-machine"}
        
        For acceptance tests, add this to test.toml:
        [[Server]]
        Pattern = "POST /api/2.0/lakebox/ssh-keys"
        Response.Body = '<response body here>'
        # Response.StatusCode = <response code if not 200>
    server.go:281: No handler for URL: /api/2.0/lakebox/ssh-keys
        Body: [0 bytes] 
        
        For acceptance tests, add this to test.toml:
        [[Server]]
        Pattern = "GET /api/2.0/lakebox/ssh-keys"
        Response.Body = '<response body here>'
        # Response.StatusCode = <response code if not 200>
    server.go:281: No handler for URL: /api/2.0/lakebox/ssh-keys/legacy-key-hash
        Body: [0 bytes] 
        
        For acceptance tests, add this to test.toml:
        [[Server]]
        Pattern = "DELETE /api/2.0/lakebox/ssh-keys/legacy-key-hash"
        Response.Body = '<response body here>'
        # Response.StatusCode = <response code if not 200>
    acceptance_test.go:1402: Diff:
        --- cmd/sandbox/retired-key-commands/output.txt
        +++ /tmp/TestAcceptcmdsandboxretired-key-commands2303625932/002/output.txt
        @@ -2,137 +2,22 @@
         === Retired commands reject requests without touching existing SSH files
         
         >>> musterr [CLI] sandbox register
        -Error: unknown command "register" for "databricks sandbox"
        +  key        [TEST_TMP_DIR]/.ssh/sandbox_ed25519
        +  ✗ Failed to register key
        +Error: failed to register key: No stub found for pattern: POST /api/2.0/lakebox/ssh-keys
         
        -Usage:
        -  databricks sandbox [flags]
        -  databricks sandbox [command]
        -
        -Available Commands:
        -  config      Configure a Sandbox's name and auto-stop policy
        -  create      Create a new Sandbox environment
        -  default     Set the default Sandbox for SSH
        -  delete      Delete a Sandbox environment
        -  forward     Forward local ports to apps in a Sandbox environment
        -  fs          Filesystem related commands
        -  list        List your Sandbox environments
        -  ssh         SSH into a Sandbox environment
        -  ssh-setup   Configure native SSH tools for a sandbox
        -  start       Start a stopped Sandbox environment
        -  status      Show Sandbox environment status
        -  stop        Stop a running Sandbox environment
        -
        -Flags:
        -  -h, --help[=true|false]   help for sandbox
        -
        -Global Flags:
        -      --debug[=true|false]   enable debug logging
        -  -o, --output type          output type: text or json (default text)
        -  -p, --profile string       ~/.databrickscfg profile
        -  -t, --target string        bundle target to use (if applicable)
        -
        -Use "databricks sandbox [command] --help" for more information about a command.
        -
        -
         >>> musterr [CLI] sandbox register --name test-machine
        -Error: unknown flag: --name
        +  key        [TEST_TMP_DIR]/.ssh/sandbox_ed25519
        +  ✗ Failed to register key
        +Error: failed to register key: No stub found for pattern: POST /api/2.0/lakebox/ssh-keys
         
        -Usage:
        -  databricks sandbox [flags]
        -  databricks sandbox [command]
        -
        -Available Commands:
        -  config      Configure a Sandbox's name and auto-stop policy
        -  create      Create a new Sandbox environment
        -  default     Set the default Sandbox for SSH
        -  delete      Delete a Sandbox environment
        -  forward     Forward local ports to apps in a Sandbox environment
        -  fs          Filesystem related commands
        -  list        List your Sandbox environments
        -  ssh         SSH into a Sandbox environment
        -  ssh-setup   Configure native SSH tools for a sandbox
        -  start       Start a stopped Sandbox environment
        -  status      Show Sandbox environment status
        -  stop        Stop a running Sandbox environment
        -
        -Flags:
        -  -h, --help[=true|false]   help for sandbox
        -
        -Global Flags:
        -      --debug[=true|false]   enable debug logging
        -  -o, --output type          output type: text or json (default text)
        -  -p, --profile string       ~/.databrickscfg profile
        -  -t, --target string        bundle target to use (if applicable)
        -
        -Use "databricks sandbox [command] --help" for more information about a command.
        -
        -
         >>> musterr [CLI] sandbox ssh-key list
        -Error: unknown command "ssh-key" for "databricks sandbox"
        +Error: failed to list ssh keys: No stub found for pattern: GET /api/2.0/lakebox/ssh-keys
         
        -Usage:
        -  databricks sandbox [flags]
        -  databricks sandbox [command]
        -
        -Available Commands:
        -  config      Configure a Sandbox's name and auto-stop policy
        -  create      Create a new Sandbox environment
        -  default     Set the default Sandbox for SSH
        -  delete      Delete a Sandbox environment
        -  forward     Forward local ports to apps in a Sandbox environment
        -  fs          Filesystem related commands
        -  list        List your Sandbox environments
        -  ssh         SSH into a Sandbox environment
        -  ssh-setup   Configure native SSH tools for a sandbox
        -  start       Start a stopped Sandbox environment
        -  status      Show Sandbox environment status
        -  stop        Stop a running Sandbox environment
        -
        -Flags:
        -  -h, --help[=true|false]   help for sandbox
        -
        -Global Flags:
        -      --debug[=true|false]   enable debug logging
        -  -o, --output type          output type: text or json (default text)
        -  -p, --profile string       ~/.databrickscfg profile
        -  -t, --target string        bundle target to use (if applicable)
        -
        -Use "databricks sandbox [command] --help" for more information about a command.
        -
        -
         >>> musterr [CLI] sandbox ssh-key delete legacy-key-hash
        -Error: unknown command "ssh-key" for "databricks sandbox"
        +  ✗ Failed to delete key
        +Error: failed to delete ssh key legacy-key-hash: No stub found for pattern: DELETE /api/2.0/lakebox/ssh-keys/legacy-key-hash
         
        -Usage:
        -  databricks sandbox [flags]
        -  databricks sandbox [command]
        -
        -Available Commands:
        -  config      Configure a Sandbox's name and auto-stop policy
        -  create      Create a new Sandbox environment
        -  default     Set the default Sandbox for SSH
        -  delete      Delete a Sandbox environment
        -  forward     Forward local ports to apps in a Sandbox environment
        -  fs          Filesystem related commands
        -  list        List your Sandbox environments
        -  ssh         SSH into a Sandbox environment
        -  ssh-setup   Configure native SSH tools for a sandbox
        -  start       Start a stopped Sandbox environment
        -  status      Show Sandbox environment status
        -  stop        Stop a running Sandbox environment
        -
        -Flags:
        -  -h, --help[=true|false]   help for sandbox
        -
        -Global Flags:
        -      --debug[=true|false]   enable debug logging
        -  -o, --output type          output type: text or json (default text)
        -  -p, --profile string       ~/.databrickscfg profile
        -  -t, --target string        bundle target to use (if applicable)
        -
        -Use "databricks sandbox [command] --help" for more information about a command.
        -
        -
         >>> cmp legacy-ssh/config [TEST_TMP_DIR]/.ssh/config
         
         >>> cmp legacy-ssh/databricks-sandbox [TEST_TMP_DIR]/.ssh/databricks-sandbox
        @@ -143,217 +21,4 @@
         
         >>> test ! -s [OUTPUT_DIR]/out.requests.txt
         
        -=== Sandbox help describes the supported connection path
        -
        ->>> [CLI] sandbox --help
        -Manage Databricks Sandbox environments.
        -
        -Sandbox provides SSH-accessible development environments backed by
        -microVM isolation. Each sandbox is a personal sandbox with pre-installed
        -tooling (Python, Node.js, Rust, Databricks CLI) and persistent storage.
        -
        -SSH uses workspace authentication; no separate SSH key registration is required.
        -For editor Remote-SSH or native SSH tools, use databricks sandbox ssh-setup.
        -
        -Getting started:
        -  databricks auth login --host https://...   # authenticate to a Databricks workspace
... (203 more lines truncated, raise DATABRICKS_CLI_TEST_MAX_LOG to see more)

latest (v1.28.0): same output as main (daf81c6)

@HsingTang
HsingTang marked this pull request as ready for review November 27, 2026 07:54
@HsingTang
HsingTang requested review from a team as code owners November 27, 2026 07:54

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at d92df5f. Each finding was verified against the code.

Not ready yet: 1 open question(s) about a change users could be hurt by.

This PR removes sandbox register and sandbox ssh-key list/delete, along with the key-registry API calls, key hashing, the gateway SSH-config writer, and their tests. In their place it adds a retirement acceptance test and migration notes that point to the OAuth-backed sandbox ssh and ssh-setup. The removal is consistent and nothing left behind references the deleted code. Two questions remain: how users revoke legacy keys that are still registered on the server, and whether the retired commands should print a migration hint instead of cobra's generic unknown-command error. There is also one wording nit in the help text.

Questions

  1. [blocking] Removing ssh-key delete takes away the only CLI path to DELETE /api/2.0/lakebox/ssh-keys/{hash}. The new README says server registrations are not revoked and that existing gateway aliases (which still point IdentityFile at ~/.ssh/sandbox_ed25519) stay as they are. If the gateway still accepts these keys, should ssh-key list/delete stay as hidden or deprecated commands until the registry is shut down? The other option is for the README to explain how to revoke a key without the CLI.
  2. After this change, sandbox register and sandbox ssh-key ... fail with cobra's generic unknown command plus the full usage text, and sandbox register --name x fails with unknown flag: --name. None of these errors mentions the retirement or ssh-setup. Should these be hidden stubs (with DisableFlagParsing) that return an error pointing to databricks sandbox ssh / ssh-setup? The acceptance test could then assert that message once per command instead of repeating the usage block seven times. Or is the generic error acceptable? (non-blocking)

Comment thread cmd/sandbox/sandbox.go Resolved
@HsingTang

Copy link
Copy Markdown
Contributor Author

The existing generic API command retains an explicit revocation path. I added a README section showing databricks api get /api/2.0/lakebox/ssh-keys --profile PROFILE and databricks api delete /api/2.0/lakebox/ssh-keys/KEY_HASH --profile PROFILE, with instructions to select the returned keyHash from the original workspace profile. This remains available while the legacy registry is available and is optional cleanup; the retirement itself does not revoke any registrations.

The new legacy-key-revocation acceptance case drives the real generic API command against the local fake server and records the expected GET and DELETE routes. All 31 sandbox acceptance cases, scoped formatting/lint, and the local review pass. No real registered key was changed.

For the non-blocking migration-stub question, I kept the retired command names absent and used the existing unknown-subcommand error handler, with the supported connection path documented in sandbox help and the README. The help now spells out databricks sandbox ssh-setup in full.

@HsingTang
HsingTang added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 9f4d562 Nov 27, 2026
25 checks passed
@HsingTang
HsingTang deleted the HsingTang/remove-sandbox-ssh-key-registration branch November 27, 2026 15:24
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