Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nextchanges/cli/aitools-hint-respects-opt-out.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* When the automatic installation of Databricks AI tools is turned off (for example by `databricks aitools auto-install disable` or `DATABRICKS_AITOOLS_AUTO_INSTALL=false`), the CLI no longer prints its install hint for coding agents or Claude Code's plugin install line. ([#8211](https://github.com/databricks/cli/pull/8211))
* When the automatic installation of Databricks AI tools is turned off (for example by `databricks aitools auto-install disable` or `DATABRICKS_AITOOLS_AUTO_INSTALL=false`), the CLI no longer prints its install hint for coding agents or Claude Code's plugin install line. ([#8194](https://github.com/databricks/cli/pull/8194), [#8211](https://github.com/databricks/cli/pull/8211))
1 change: 1 addition & 0 deletions .nextchanges/cli/sandbox-retirement-migration-hints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Show migration instructions when retired `sandbox register` or `sandbox ssh-key` commands are invoked, including with their legacy flags. ([#8180](https://github.com/databricks/cli/pull/8180))
392 changes: 197 additions & 195 deletions acceptance/cmd/sandbox/retired-key-commands/output.txt

Large diffs are not rendered by default.

50 changes: 45 additions & 5 deletions acceptance/cmd/sandbox/retired-key-commands/script
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,63 @@ mkdir -p "$TEST_TMP_DIR/.ssh"
cp legacy-ssh/* "$TEST_TMP_DIR/.ssh/"
trace musterr $CLI sandbox register
trace musterr $CLI sandbox register --name test-machine
trace musterr $CLI sandbox register --name=test-machine
trace musterr $CLI sandbox register --help
trace musterr $CLI sandbox register old-argument --unknown
trace musterr $CLI sandbox ssh-key
trace musterr $CLI sandbox ssh-key list
trace musterr $CLI sandbox ssh-key list --json
trace musterr $CLI sandbox ssh-key list --help
trace musterr $CLI sandbox ssh-key delete legacy-key-hash
trace musterr $CLI sandbox ssh-key delete legacy-key-hash --profile missing-profile --unknown
for file in config databricks-sandbox sandbox_ed25519 sandbox_ed25519.pub; do
trace cmp "legacy-ssh/$file" "$TEST_TMP_DIR/.ssh/$file"
done

trace test ! -s "$OUT_REQUESTS"

title "Sandbox help describes the supported connection path"
trace $CLI sandbox --help | contains.py 'ssh-setup' 'no separate SSH key registration is required' '! register ' '! ssh-key '
trace $CLI sandbox ssh --help
trace $CLI sandbox ssh-setup --help

title "Retired commands leave a fresh SSH directory absent"
mkdir "$TEST_TMP_DIR/fresh-home"
sethome "$TEST_TMP_DIR/fresh-home"
unset DATABRICKS_HOST DATABRICKS_TOKEN DATABRICKS_CONFIG_PROFILE DATABRICKS_CONFIG_FILE
export DATABRICKS_CONFIG_FILE="$TEST_TMP_DIR/fresh-home/missing-config"
export DATABRICKS_CONFIG_PROFILE=missing-profile
trace musterr $CLI sandbox register
trace musterr $CLI sandbox register --name fresh-machine
trace musterr $CLI sandbox register --name=fresh-machine
trace musterr $CLI sandbox register --help
trace musterr $CLI sandbox register old-argument --unknown
trace musterr $CLI sandbox ssh-key
trace musterr $CLI sandbox ssh-key list
trace musterr $CLI sandbox ssh-key list --json
trace musterr $CLI sandbox ssh-key list --help
trace musterr $CLI sandbox ssh-key delete legacy-key-hash
trace musterr $CLI sandbox ssh-key delete legacy-key-hash --profile missing-profile --unknown

title "Retired commands return the standard error exit status"
trace musterr $CLI sandbox register
printf '\nExit code: %s\n' "$MUSTERR_EXIT_CODE"
trace musterr $CLI sandbox ssh-key
printf '\nExit code: %s\n' "$MUSTERR_EXIT_CODE"

title "Sandbox help describes the supported connection path"
trace $CLI sandbox --help | contains.py 'ssh-setup' 'no separate SSH key registration is required' '! register ' '! ssh-key '
trace $CLI sandbox ssh --help
trace $CLI sandbox ssh-setup --help
trace $CLI help sandbox register
trace $CLI help sandbox ssh-key
title "Sandbox completion excludes retired commands"
# Merge Cobra's stderr diagnostic before filtering so it cannot race with buffered stdout.
# bash -c keeps the empty argument visible in trace without trailing whitespace.
trace bash -c '"$CLI" __complete sandbox ""' 2>&1 | contains.py 'ssh-setup' '!register' '!ssh-key'
trace $CLI __complete sandbox reg 2>&1 | contains.py '!register'
trace $CLI __complete sandbox ssh- 2>&1 | contains.py 'ssh-setup' '!ssh-key'
trace bash -c '"$CLI" __complete sandbox register ""' 2>&1 | contains.py ':4' 'ShellCompDirectiveNoFileComp'
trace bash -c '"$CLI" __complete sandbox ssh-key ""' 2>&1 | contains.py ':4' 'ShellCompDirectiveNoFileComp'

title "Commands leave the fresh home and request log unchanged"
trace test ! -e "$TEST_TMP_DIR/fresh-home/.ssh"
trace test ! -e "$TEST_TMP_DIR/fresh-home/.databrickscfg"
trace test ! -e "$TEST_TMP_DIR/fresh-home/.databricks"
trace ls -A "$TEST_TMP_DIR/fresh-home"
trace test ! -s "$OUT_REQUESTS"
4 changes: 4 additions & 0 deletions cmd/sandbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ and `databricks sandbox ssh-key delete` commands have been removed. SSH now uses
workspace OAuth authentication and sandbox port forwarding; separate registration
with the gateway key registry is no longer needed.

Invoking the retired commands, including their old flags, returns an error with
migration instructions. These hidden entrypoints perform no authentication,
key registration, key revocation, or SSH configuration changes.

Authenticate with `databricks auth login --host https://<workspace-host>`, then use
`databricks sandbox ssh SANDBOX_ID`. For editor Remote-SSH, `ssh`, `scp`, or `sftp`,
run `databricks sandbox ssh-setup SANDBOX_ID --name my-sandbox --profile PROFILE`
Expand Down
44 changes: 44 additions & 0 deletions cmd/sandbox/retired.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package sandbox

import (
"errors"

"github.com/spf13/cobra"
)

const retiredRegisterMessage = `sandbox register command has been retired, and is no longer required for sandbox SSH connection.
To connect, use: databricks sandbox ssh <sandbox>
For native SSH or editor setup, use: databricks sandbox ssh-setup <sandbox> --name ALIAS --profile PROFILE`

const retiredSSHKeyMessage = `sandbox ssh-key list/delete have been retired; these commands no longer manage the legacy gateway key registry.
While the legacy registry remains available, list existing keys using the original workspace profile:
databricks api get /api/2.0/lakebox/ssh-keys --profile PROFILE
To deliberately revoke a selected existing key, replace KEY_HASH with its keyHash and use:
databricks api delete /api/2.0/lakebox/ssh-keys/KEY_HASH --profile PROFILE`

func newRetiredRegisterCommand() *cobra.Command {
return &cobra.Command{
Use: "register",
Hidden: true,
Long: retiredRegisterMessage,
// Old flags must reach the retirement error instead of flag validation.
DisableFlagParsing: true,
ValidArgsFunction: cobra.NoFileCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
return errors.New(retiredRegisterMessage)
},
}
}

func newRetiredSSHKeyCommand() *cobra.Command {
return &cobra.Command{
Use: "ssh-key",
Hidden: true,
Long: retiredSSHKeyMessage,
DisableFlagParsing: true,
ValidArgsFunction: cobra.NoFileCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
return errors.New(retiredSSHKeyMessage)
},
}
}
1 change: 1 addition & 0 deletions cmd/sandbox/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Common workflows:
databricks sandbox forward -L 8080:10080 # open sandbox port 10080 at localhost:8080
`

cmd.AddCommand(newRetiredRegisterCommand(), newRetiredSSHKeyCommand())
cmd.AddCommand(newSetDefaultCommand())
cmd.AddCommand(newForwardCommand())
cmd.AddCommand(newListCommand())
Expand Down
Loading