Skip to content

Commit 2912826

Browse files
authored
SSH: bump serverless environment version and expose a flag for it (#4663)
## Changes Version 5 has been deployed recently, and SGC bumped their minimum to 4, breaking us. ## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> ## Tests <!-- How have you tested the changes? --> <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 08123e4 commit 2912826

4 files changed

Lines changed: 35 additions & 5 deletions

File tree

experimental/ssh/cmd/connect.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ the SSH server and handling the connection proxy.
3535
var userKnownHostsFile string
3636
var liteswap string
3737
var skipSettingsCheck bool
38+
var environmentVersion int
3839

3940
cmd.Flags().StringVar(&clusterID, "cluster", "", "Databricks cluster ID (for dedicated clusters)")
4041
cmd.Flags().DurationVar(&shutdownDelay, "shutdown-delay", defaultShutdownDelay, "Delay before shutting down the server after the last client disconnects")
@@ -67,6 +68,9 @@ the SSH server and handling the connection proxy.
6768
cmd.Flags().BoolVar(&skipSettingsCheck, "skip-settings-check", false, "Skip checking and updating IDE settings")
6869
cmd.Flags().MarkHidden("skip-settings-check")
6970

71+
cmd.Flags().IntVar(&environmentVersion, "environment-version", defaultEnvironmentVersion, "Environment version for serverless compute")
72+
cmd.Flags().MarkHidden("environment-version")
73+
7074
cmd.PreRunE = func(cmd *cobra.Command, args []string) error {
7175
// CLI in the proxy mode is executed by the ssh client and can't prompt for input
7276
if proxyMode {
@@ -101,6 +105,7 @@ the SSH server and handling the connection proxy.
101105
UserKnownHostsFile: userKnownHostsFile,
102106
Liteswap: liteswap,
103107
SkipSettingsCheck: skipSettingsCheck,
108+
EnvironmentVersion: environmentVersion,
104109
AdditionalArgs: args,
105110
}
106111
if err := opts.Validate(); err != nil {

experimental/ssh/cmd/constants.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package ssh
33
import "time"
44

55
const (
6-
defaultServerPort = 7772
7-
defaultMaxClients = 10
8-
defaultShutdownDelay = 10 * time.Minute
9-
defaultHandoverTimeout = 30 * time.Minute
6+
defaultServerPort = 7772
7+
defaultMaxClients = 10
8+
defaultShutdownDelay = 10 * time.Minute
9+
defaultHandoverTimeout = 30 * time.Minute
10+
defaultEnvironmentVersion = 4
1011

1112
serverTimeout = 24 * time.Hour
1213
taskStartupTimeout = 10 * time.Minute

experimental/ssh/internal/client/client.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var connectionNameRegex = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_-]*$`)
4444
const (
4545
sshServerTaskKey = "start_ssh_server"
4646
serverlessEnvironmentKey = "ssh_tunnel_serverless"
47+
minEnvironmentVersion = 4
4748

4849
VSCodeOption = "vscode"
4950
VSCodeCommand = "code"
@@ -98,6 +99,8 @@ type ClientOptions struct {
9899
Liteswap string
99100
// If true, skip checking and updating IDE settings.
100101
SkipSettingsCheck bool
102+
// Environment version for serverless compute.
103+
EnvironmentVersion int
101104
}
102105

103106
func (o *ClientOptions) Validate() error {
@@ -117,6 +120,9 @@ func (o *ClientOptions) Validate() error {
117120
if o.IDE != "" && o.IDE != VSCodeOption && o.IDE != CursorOption {
118121
return fmt.Errorf("invalid IDE value: %q, expected %q or %q", o.IDE, VSCodeOption, CursorOption)
119122
}
123+
if o.EnvironmentVersion > 0 && o.EnvironmentVersion < minEnvironmentVersion {
124+
return fmt.Errorf("environment version must be >= %d, got %d", minEnvironmentVersion, o.EnvironmentVersion)
125+
}
120126
return nil
121127
}
122128

@@ -182,6 +188,10 @@ func (o *ClientOptions) ToProxyCommand() (string, error) {
182188
proxyCommand += " --liteswap=" + o.Liteswap
183189
}
184190

191+
if o.EnvironmentVersion > 0 {
192+
proxyCommand += " --environment-version=" + strconv.Itoa(o.EnvironmentVersion)
193+
}
194+
185195
return proxyCommand, nil
186196
}
187197

@@ -508,7 +518,7 @@ func submitSSHTunnelJob(ctx context.Context, client *databricks.WorkspaceClient,
508518
{
509519
EnvironmentKey: serverlessEnvironmentKey,
510520
Spec: &compute.Environment{
511-
EnvironmentVersion: "3",
521+
EnvironmentVersion: strconv.Itoa(max(opts.EnvironmentVersion, minEnvironmentVersion)),
512522
},
513523
},
514524
}

experimental/ssh/internal/client/client_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ func TestValidate(t *testing.T) {
7676
name: "valid IDE cursor",
7777
opts: client.ClientOptions{ClusterID: "abc-123", IDE: "cursor"},
7878
},
79+
{
80+
name: "environment version too low",
81+
opts: client.ClientOptions{ClusterID: "abc-123", EnvironmentVersion: 3},
82+
wantErr: "environment version must be >= 4, got 3",
83+
},
84+
{
85+
name: "valid environment version",
86+
opts: client.ClientOptions{ClusterID: "abc-123", EnvironmentVersion: 4},
87+
},
7988
}
8089

8190
for _, tt := range tests {
@@ -140,6 +149,11 @@ func TestToProxyCommand(t *testing.T) {
140149
opts: client.ClientOptions{ClusterID: "abc-123", Liteswap: "test-env"},
141150
want: quoted + " ssh connect --proxy --cluster=abc-123 --auto-start-cluster=false --shutdown-delay=0s --liteswap=test-env",
142151
},
152+
{
153+
name: "with environment version",
154+
opts: client.ClientOptions{ClusterID: "abc-123", EnvironmentVersion: 4},
155+
want: quoted + " ssh connect --proxy --cluster=abc-123 --auto-start-cluster=false --shutdown-delay=0s --environment-version=4",
156+
},
143157
}
144158

145159
for _, tt := range tests {

0 commit comments

Comments
 (0)