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
3 changes: 1 addition & 2 deletions runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ Here's the steps to build `dstack-shim` and `dstack-runner` and run `dstack` wit
3. Start the shim:

```shell
./shim --shim-home $RUNNER_DIR --runner-binary-path $COMPILED_RUNNER_PATH --ssh-key $DSTACK_PUBLIC_KEY
./shim --shim-home $RUNNER_DIR --runner-binary-path $COMPILED_RUNNER_PATH
```

Notes:

* `$RUNNER_DIR` is any directory for storing runner files.
* `$DSTACK_PUBLIC_KEY` is `~/.dstack/ssh/id_rsa.pub` that allows the dstack CLI to connect to the ssh server inside the container.

Now you can call shim API:

Expand Down
2 changes: 0 additions & 2 deletions runner/cmd/shim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func main() {
Name: "runner-download-url",
Usage: "Set runner's download URL",
Destination: &args.Runner.DownloadURL,
Required: true,
EnvVars: []string{"DSTACK_RUNNER_DOWNLOAD_URL"},
},
&cli.PathFlag{
Expand Down Expand Up @@ -106,7 +105,6 @@ func main() {
&cli.StringFlag{
Name: "ssh-key",
Usage: "Public SSH key",
Required: true,
Destination: &args.Docker.ConcatinatedPublicSSHKeys,
EnvVars: []string{"DSTACK_PUBLIC_SSH_KEY"},
},
Expand Down
3 changes: 3 additions & 0 deletions runner/internal/shim/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
)

func (c *CLIArgs) DownloadRunner(ctx context.Context) error {
if c.Runner.DownloadURL == "" {
return nil
}
err := downloadRunner(ctx, c.Runner.DownloadURL, c.Runner.BinaryPath, false)
if err != nil {
return gerrors.Wrap(err)
Expand Down
11 changes: 11 additions & 0 deletions src/dstack/_internal/core/services/ssh/attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ def __init__(
}
else:
self.container_config = None
if local_backend:
self.container_config = None
self.host_config = {
"HostName": hostname,
"Port": container_ssh_port,
"User": "root", # TODO(#1535): support non-root images properly
"IdentityFile": self.identity_file,
"IdentitiesOnly": "yes",
"StrictHostKeyChecking": "no",
"UserKnownHostsFile": "/dev/null",
}
if self.container_config is not None and get_ssh_client_info().supports_multiplexing:
self.container_config.update(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def _process_provisioning_with_shim(
volume_mounts=volume_mounts,
instance_mounts=instance_mounts,
host_ssh_user=ssh_user,
host_ssh_keys=[ssh_key],
host_ssh_keys=[ssh_key] if ssh_key else [],
container_ssh_keys=public_keys,
)
else:
Expand Down
10 changes: 4 additions & 6 deletions src/dstack/_internal/server/services/runner/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,15 @@ def wrapper(
Returns:
is successful
"""

if job_provisioning_data.backend == BackendType.LOCAL:
# without SSH
port_map = {p: p for p in ports}
return func(port_map, *args, **kwargs)

# container:host mapping
container_ports_map = {port: port for port in ports}
if job_runtime_data is not None and job_runtime_data.ports is not None:
container_ports_map.update(job_runtime_data.ports)

if job_provisioning_data.backend == BackendType.LOCAL:
# without SSH
return func(container_ports_map, *args, **kwargs)

for attempt in range(retries):
last = attempt == retries - 1
# remote_host:local mapping
Expand Down