Skip to content

Commit 2f17742

Browse files
committed
Update description, add comments
1 parent c95c8df commit 2f17742

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

cmd/ssh/connect.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212
func newConnectCommand() *cobra.Command {
1313
cmd := &cobra.Command{
1414
Use: "connect",
15-
Short: "Connect to a Databricks cluster via SSH",
16-
Long: `Connect to a Databricks cluster via SSH.
15+
Short: "Connect to Databricks compute via SSH",
16+
Long: `Connect to Databricks compute via SSH.
1717
18-
This command establishes an SSH connection to a Databricks cluster, setting up
19-
the necessary SSH server on the cluster and handling the connection proxy.
18+
This command establishes an SSH connection to Databricks compute, setting up
19+
the SSH server and handling the connection proxy.
2020
2121
` + disclaimer,
2222
}

libs/ssh/client.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,30 @@ var sshServerBootstrapScript string
3737
var errServerMetadata = errors.New("server metadata error")
3838

3939
type ClientOptions struct {
40-
ClusterID string
41-
ProxyMode bool
42-
ServerMetadata string
43-
ShutdownDelay time.Duration
44-
MaxClients int
45-
HandoverTimeout time.Duration
46-
ReleasesDir string
47-
SSHKeysDir string
48-
AdditionalArgs []string
40+
// Id of the cluster to connect to
41+
ClusterID string
42+
// Delay before shutting down the server after the last client disconnects
43+
ShutdownDelay time.Duration
44+
// Maximum number of SSH clients
45+
MaxClients int
46+
// Indicates that the CLI runs as a ProxyCommand - it should establish ws connection
47+
// to the cluster and proxy all traffic through stdin/stdout.
48+
// In the non proxy mode the CLI spawns an ssh client with the ProxyCommand config.
49+
ProxyMode bool
50+
// Expected format: "<user_name>,<port>".
51+
// If present, the CLI won't attempt to start the server.
52+
ServerMetadata string
53+
// How often the CLI should reconnect to the server with new auth.
54+
HandoverTimeout time.Duration
55+
// Directory for local SSH tunnel development releases.
56+
// If not present, the CLI will use github releases with the current version.
57+
ReleasesDir string
58+
// Directory for local SSH keys. Defaults to ~/.databricks/ssh-tunnel-keys
59+
SSHKeysDir string
60+
// Name of the client public key file to be used in the ssh-tunnel secrets scope.
4961
ClientPublicKeyName string
62+
// Additional arguments to pass to the SSH client in the non proxy mode.
63+
AdditionalArgs []string
5064
}
5165

5266
func RunClient(ctx context.Context, client *databricks.WorkspaceClient, opts ClientOptions) error {

libs/ssh/proxy.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import (
1515
"golang.org/x/sync/errgroup"
1616
)
1717

18-
var (
19-
errProxyEOF = errors.New("proxy EOF error")
18+
var errProxyEOF = errors.New("proxy EOF error")
19+
20+
const (
21+
proxyBufferSize = 4 * 1024 // Same as gorilla/websocket default read/write buffer sizes. Bigger payloads will be split into multiple ws frames.
2022
proxyHandoverInitTimeout = 30 * time.Second
2123
proxyHandoverAcceptTimeout = 25 * time.Second
2224
proxyHandoverAckCloseConnTimeout = 15 * time.Second
@@ -85,7 +87,7 @@ func (pc *proxyConnection) runSendingLoop(ctx context.Context, src io.Reader) er
8587
if ctx.Err() != nil {
8688
return ctx.Err()
8789
}
88-
b := make([]byte, 32*1024)
90+
b := make([]byte, proxyBufferSize)
8991
n, readErr := src.Read(b)
9092
if n > 0 {
9193
// This will block during handover - we stop sending anything except the close message.

0 commit comments

Comments
 (0)