Skip to content

Commit 4adee6a

Browse files
authored
Make --accelerator flag optional for ssh connect (#4947)
## Summary - Remove the validation requiring `--accelerator` when using `--name` (serverless mode) in `ssh connect` - Add a proactive yellow warning at connect time when `--accelerator` is omitted, informing users that serverless CPU is in private preview - Add a reactive hint appended to the error message when the server fails to start without an accelerator ## Test plan - [x] Unit tests pass (`go test ./experimental/ssh/internal/client/`) - [x] Build succeeds (`make build`) - [x] Manual test: `./cli ssh connect --name test-conn --profile p` shows warning and submits job without `--accelerator` - [x] Existing `--accelerator` usage is unaffected (validation for valid values still in place) This pull request was AI-assisted by Isaac.
1 parent 6045ca9 commit 4adee6a

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

experimental/ssh/internal/client/client.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/databricks/databricks-sdk-go/service/compute"
3232
"github.com/databricks/databricks-sdk-go/service/jobs"
3333
"github.com/databricks/databricks-sdk-go/service/workspace"
34+
"github.com/fatih/color"
3435
"github.com/gorilla/websocket"
3536
)
3637

@@ -105,16 +106,9 @@ func (o *ClientOptions) Validate() error {
105106
if o.Accelerator != "" && o.ConnectionName == "" {
106107
return errors.New("--accelerator flag can only be used with serverless compute (--name flag)")
107108
}
108-
// Consider removing this check when we enable serverless CPU connections. Ideally Jobs API should do the validation
109-
// for us, but they don't plan on doing it in the nearest future. For now we should not forget to check if there are
110-
// any other possible values that can be here.
111109
if o.Accelerator != "" && o.Accelerator != "GPU_1xA10" && o.Accelerator != "GPU_8xH100" {
112110
return fmt.Errorf("invalid accelerator value: %q, expected %q or %q", o.Accelerator, "GPU_1xA10", "GPU_8xH100")
113111
}
114-
// TODO: Remove when we add support for serverless CPU
115-
if o.ConnectionName != "" && o.Accelerator == "" {
116-
return errors.New("--name flag requires --accelerator to be set (for now we only support serverless GPU compute)")
117-
}
118112
if o.ConnectionName != "" && !connectionNameRegex.MatchString(o.ConnectionName) {
119113
return fmt.Errorf("connection name %q must consist of letters, numbers, dashes, and underscores", o.ConnectionName)
120114
}
@@ -215,6 +209,9 @@ func Run(ctx context.Context, client *databricks.WorkspaceClient, opts ClientOpt
215209

216210
if !opts.ProxyMode {
217211
cmdio.LogString(ctx, fmt.Sprintf("Connecting to %s...", sessionID))
212+
if opts.IsServerlessMode() && opts.Accelerator == "" {
213+
cmdio.LogString(ctx, color.YellowString("WARNING: serverless compute without an accelerator is in private preview. If you are not enrolled, this command will likely time out with an error. Contact your Databricks account team to enroll."))
214+
}
218215
}
219216

220217
if opts.IDE != "" && !opts.ProxyMode {
@@ -294,6 +291,10 @@ func Run(ctx context.Context, client *databricks.WorkspaceClient, opts ClientOpt
294291
}
295292
userName, serverPort, clusterID, err = ensureSSHServerIsRunning(ctx, client, version, secretScopeName, opts)
296293
if err != nil {
294+
if opts.IsServerlessMode() && opts.Accelerator == "" && errors.Is(err, errServerMetadata) {
295+
return fmt.Errorf("failed to ensure that ssh server is running: %w\n\n"+
296+
color.YellowString("This may be because serverless compute without an accelerator is in private preview.\nContact your Databricks account team to enroll."), err)
297+
}
297298
return fmt.Errorf("failed to ensure that ssh server is running: %w", err)
298299
}
299300
} else {

experimental/ssh/internal/client/client_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ func TestValidate(t *testing.T) {
3636
wantErr: "--accelerator flag can only be used with serverless compute (--name flag)",
3737
},
3838
{
39-
name: "connection name without accelerator",
40-
opts: client.ClientOptions{ConnectionName: "my-conn"},
41-
wantErr: "--name flag requires --accelerator to be set (for now we only support serverless GPU compute)",
39+
name: "connection name without accelerator",
40+
opts: client.ClientOptions{ConnectionName: "my-conn"},
4241
},
4342
{
4443
name: "invalid connection name characters",

0 commit comments

Comments
 (0)