You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Consolidates the gateway-resolution path simplification into a single
PR. Now that the server stamps `gateway_host` on every SshKey and
Sandbox response, `register` always populates the cache, every
subsequent operation that touches the API gets the workspace's real
gateway directly, and a bunch of compensating code falls out as dead
weight.
## What changes
### Code that goes away
- **`resolveGatewayHost(workspaceHost string) string`** — the hardcoded
heuristic that returned `uw2.dbrx.dev` for non-staging and
`ue1.s.dbrx.dev` for staging. Wrong for any workspace whose gateway
doesn't match those two values.
- **`defaultGatewayHost` + `stagingDefaultGatewayHost`** — the two
constants behind the heuristic.
- **`--gateway` flag on `sandbox ssh`** — a manual override that made
sense only when the CLI couldn't learn the gateway itself. With the
cache always populated post-register, the only thing the flag does now
is let a user typo their way into dialing a random host.
- **The "Connecting…" Bubble Tea spinner before `execSSHDirect`** — it
hid the terminal cursor at init (`initTerminal()`) and the deferred
`Close()` never ran because `execv` replaces the CLI process. Result:
cursor invisible for the entire ssh session and after it exited.
Co-authored with Anwell — pulled in from #5545.
- **Synthetic `Host sandbox-gw` alias** — UI deep links use the literal
gateway hostname, so the alias was buying nothing and adding an
indirection the UI had to know about.
### New behavior
- **Server-stamped gateway flows through to the SSH config.**
`registerKey` now returns `*sshKeyEntry` carrying `GatewayHost`;
`register` caches it via `setGatewayHost` and passes it to
`maybeWriteSSHConfig`.
- **One Host stanza per cached gateway.** A user with profiles in
multiple regions accumulates one block per unique gateway, instead of
the second `register` overwriting the first's block. New
`allGatewayHosts` helper in `state.go` returns the deduplicated set.
- **`saveState` is atomic** (tmp + Rename) — concurrent CLI invocations
can't see a half-written `sandbox.json` and trip a parse error that
`loadState` silently swallows.
- **Post-register hint branches on `getDefault`** — suggests `databricks
sandbox create` when no default exists, `databricks sandbox ssh` when
one does.
- **Path output uses forward slashes on Windows** — `filepath.ToSlash`
on the `Generated SSH key at …` line so acceptance goldens are stable
across Linux/macOS/Windows.
### New SSH config block shape
Before (9 lines, synthetic alias, several overrides):
```
# Managed by `databricks sandbox register`.
Host sandbox-gw
HostName uw2.dbrx.dev
Port 2222
IdentityFile ~/.ssh/sandbox_ed25519
IdentitiesOnly yes
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel ERROR
```
After (literal hostname, one stanza per gateway, only the directives
that actually differ from SSH defaults):
```
# Managed by `databricks sandbox register`. Manual edits will be overwritten.
Host us-west-2.service-direct.dev.databricks.com
Port 2222
IdentityFile ~/.ssh/sandbox_ed25519
IdentitiesOnly yes
Host us-east-1.service-direct.prod.databricks.com
Port 2222
IdentityFile ~/.ssh/sandbox_ed25519
IdentitiesOnly yes
```
Mirrors the workspace UI's "First time setup?" snippet exactly, so CLI
users and paste-the-snippet users converge.
### New resolution chain in `sandbox ssh`
Fresh API response → cached value. If both are empty:
```
Error: could not resolve the sandbox SSH gateway — run `databricks sandbox register` first
```
## Tests
- `acceptance/cmd/sandbox/register/success/` — pins the new contract:
registerKey returns SshKey with gateway_host, register caches it, prints
the consent-skip notice in the non-interactive acceptance path. Parent
`test.toml` Ignores `.ssh`.
- `TestMaybeWriteSSHConfigSkipsWhenNoGatewaysCached` — pins the
no-gateway short-circuit.
- `TestBuildSSHConfigBlockMultipleGateways` — pins per-gateway
repetition in the new block shape.
## Test plan
- [x] `go test ./cmd/sandbox/...` passes
- [x] `go test ./acceptance -run TestAccept/cmd/sandbox` passes
- [x] `go build ./...` clean
- [x] `./task lint` clean
- [x] Windows variant passes (after `filepath.ToSlash` fix)
This pull request and its description were written by Isaac.
---------
Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
0 commit comments