Skip to content
Merged
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
8 changes: 6 additions & 2 deletions sdk/go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,15 @@ sb, err := client.Create(ctx, cubesandbox.CreateOptions{
When `CUBE_PROXY_NODE_IP` is set, data-plane requests connect directly to that IP and port while preserving the virtual sandbox host:

```text
URL: <CUBE_PROXY_SCHEME>://49999-<sandboxID>.<CUBE_SANDBOX_DOMAIN>/<envd-endpoint>
URL: <CUBE_PROXY_SCHEME>://49983-<sandboxID>.<CUBE_SANDBOX_DOMAIN>/<envd-endpoint>
TCP: <CUBE_PROXY_NODE_IP>:<CUBE_PROXY_PORT_HTTP>
Host: 49999-<sandboxID>.<CUBE_SANDBOX_DOMAIN>
Host: 49983-<sandboxID>.<CUBE_SANDBOX_DOMAIN>
```

The host prefix is the sandbox's internal service port: `49983` (envd) for
commands/filesystem/files/PTY, and `49999` (Jupyter) for the code interpreter
(`RunCode` / `/execute`).

You can also set it directly:

```go
Expand Down
2 changes: 1 addition & 1 deletion sdk/go/envd.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func multipartFileBody(path string, data []byte) (io.Reader, string, error) {
func (s *Sandbox) newEnvdRequest(ctx context.Context, method, path string, query url.Values, body io.Reader) (*http.Request, error) {
target := url.URL{
Scheme: s.client.config.ProxyScheme,
Host: s.GetHost(JupyterPort),
Host: s.GetHost(EnvdPort),
Path: path,
RawQuery: query.Encode(),
}
Expand Down
10 changes: 9 additions & 1 deletion sdk/go/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ import (
"time"
)

const JupyterPort = 49999
const (
// JupyterPort is the code-interpreter (Jupyter) port, used only by the
// /execute endpoint (RunCode).
JupyterPort = 49999
// EnvdPort is the envd daemon port. All envd data-plane RPCs — commands,
// filesystem, files, and PTY — route here, matching the Python/Node SDKs
// (ENVD_PORT = 49983). Sending these to JupyterPort yields 404s.
EnvdPort = 49983
)

func (s *Sandbox) GetHost(port int) string {
domain := s.Domain
Expand Down
6 changes: 3 additions & 3 deletions sdk/go/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ func TestCommandsRunUsesEnvdProcessStart(t *testing.T) {
t.Fatalf("Run: %v", err)
}

if gotHost != "49999-sb-proc.cube.test" {
if gotHost != "49983-sb-proc.cube.test" {
t.Fatalf("Host=%q", gotHost)
}
if gotHeaders.Get("Content-Type") != connectContentType || gotHeaders.Get("Connect-Protocol-Version") != connectProtocolVersion {
Expand Down Expand Up @@ -721,7 +721,7 @@ func TestFilesReadUsesEnvdHTTPFileAPI(t *testing.T) {
if content != "file content" {
t.Fatalf("content=%q", content)
}
if gotHost != "49999-sb-files.cube.test" || gotPath != "/tmp/foo bar.txt" || gotToken != "envd-token" {
if gotHost != "49983-sb-files.cube.test" || gotPath != "/tmp/foo bar.txt" || gotToken != "envd-token" {
t.Fatalf("host/path/token=%q/%q/%q", gotHost, gotPath, gotToken)
}
}
Expand Down Expand Up @@ -944,7 +944,7 @@ func TestFilesListUsesEnvdFilesystemRPC(t *testing.T) {
if len(entries) != 1 || entries[0].Name != "a.txt" || entries[0].Size != 10 || entries[0].IsDir() {
t.Fatalf("entries=%#v", entries)
}
if gotHost != "49999-sb-fs.cube.test" || gotPath != "/filesystem.Filesystem/ListDir" || gotCT != "application/json" {
if gotHost != "49983-sb-fs.cube.test" || gotPath != "/filesystem.Filesystem/ListDir" || gotCT != "application/json" {
t.Fatalf("host/path/ct=%q/%q/%q", gotHost, gotPath, gotCT)
}
}
Expand Down
Loading