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
6 changes: 3 additions & 3 deletions docs/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ runs on the drukbox machine. It does not support Tailscale.
Prepare the host fully before drukbox starts. drukbox only connects to
the host:

1. Install Docker Engine and `docker-sbx`. Ubuntu 24.04+ with KVM is
necessary: `/dev/kvm` must exist, and the service user must be in the
`kvm` group.
1. Install Docker Engine and `docker-sbx` 0.48.0 or later. Ubuntu 24.04+
with KVM is necessary: `/dev/kvm` must exist, and the service user
must be in the `kvm` group.
2. Sign in one time with `sbx login`. Headless hosts use a device-code
flow.
3. Start the daemon: `sbx daemon start -d --policy balanced`.
Expand Down
6 changes: 2 additions & 4 deletions src/providers/docker_sbx/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ async def create_sandbox(
str(cpus),
"--memory",
memory,
"--quiet",
"shell",
workspace,
)
Expand Down Expand Up @@ -129,10 +128,9 @@ async def remove_template(self, template: str) -> None:
async def sandbox_count(self) -> int:
output = await self._run("ls", "--json")
try:
payload = json.loads(output)
# Go writes an empty list as null.
return len(payload["sandboxes"] or [])
except (json.JSONDecodeError, KeyError, TypeError) as error:
return len(json.loads(output) or [])
except json.JSONDecodeError as error:
raise DockerSbxTransportError(
f"sbx ls returned an unreadable sandbox list: {output.strip()!r}"
) from error
Expand Down
4 changes: 2 additions & 2 deletions src/providers/docker_sbx/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def fake_exec(*args, **kwargs):

@pytest.mark.asyncio
async def test_sandbox_count_reads_the_listing(monkeypatch):
listing = b'{"sandboxes": [{"name": "sb-a"}, {"name": "sb-b"}]}'
listing = b'[{"name": "sb-a"}, {"name": "sb-b"}]'
create = AsyncMock(return_value=_process(stdout=listing))
monkeypatch.setattr("providers.docker_sbx.api.asyncio.create_subprocess_exec", create)

Expand All @@ -178,7 +178,7 @@ async def test_sandbox_count_reads_the_listing(monkeypatch):
@pytest.mark.asyncio
async def test_sandbox_count_treats_a_null_list_as_empty(monkeypatch):
# Go writes an empty list as null. An unused daemon shows null.
create = AsyncMock(return_value=_process(stdout=b'{"sandboxes": null}'))
create = AsyncMock(return_value=_process(stdout=b"null"))
monkeypatch.setattr("providers.docker_sbx.api.asyncio.create_subprocess_exec", create)

assert await SbxCLI().sandbox_count() == 0
Expand Down
Loading