solari-runloop-compat 0.2.12__tar.gz → 0.2.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/COMPAT.md +4 -2
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/PKG-INFO +1 -1
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/pyproject.toml +1 -1
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/__init__.py +1 -1
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_gateway.py +24 -3
- solari_runloop_compat-0.2.13/solari_runloop/_vendor_user.py +66 -0
- solari_runloop_compat-0.2.12/solari_runloop/_vendor_user.py +0 -45
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/.gitignore +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/LICENSE +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/NOTICE +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/README.md +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_branding.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_client.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_config.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_context.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_dockerfile.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_exceptions.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_loop.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_mapping.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_models.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_options.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_redact.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_resources.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_sync.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/_types.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/lib/__init__.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/lib/polling.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/pagination.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/sdk.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/__init__.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/blueprint_build_log.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/blueprint_build_logs_list_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/blueprint_build_parameters.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/blueprint_list_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/blueprint_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devbox_async_execution_detail_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devbox_execution_detail_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devbox_snapshot_list_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devbox_snapshot_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devbox_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devboxes/__init__.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devboxes/devbox_logs_list_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devboxes/devbox_snapshot_async_status_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devboxes/execution_update_chunk.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/object_download_url_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/object_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/secret_list_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/secret_view.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/shared/__init__.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/shared/after_idle.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/shared/code_mount_parameters.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/shared/launch_parameters.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/shared/lifecycle_configuration.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/shared/lifecycle_hooks.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/shared/resume_triggers.py +0 -0
- {solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/tunnel_view.py +0 -0
|
@@ -45,7 +45,7 @@ gateway endpoint (see `GATEWAY-ENDPOINTS.md`); **NO** raises `SolariCompatUnsupp
|
|
|
45
45
|
| `blueprint.create(name, dockerfile=, system_setup_commands=, file_mounts=, base_blueprint_name=/id=, build_args=, build_context=, launch_parameters=)` | DIFF, live | Builds a Solari template from a **Dockerfile subset** and waits for it (`FROM` ubuntu/debian = the native base; **any other public image** (e.g. `python:3.12-alpine`) is built natively by the gateway (`compiled.fromImage`), see the limits below; `RUN ENV ARG WORKDIR ENTRYPOINT CMD`; `SHELL` (JSON form; later shell-form `RUN` / `CMD` / `ENTRYPOINT` run under it); `EXPOSE` (validated; every guest port is reachable through the tunnel, so a TCP port needs nothing more); `COPY`/`ADD` with a `build_context` (see below)). `ENTRYPOINT`/`CMD` are recorded in the image and not started (pass `entrypoint=` to `devboxes.create`). **`LABEL` and `MAINTAINER`** are metadata only: accepted, with one warning per Dockerfile that they are ignored. **Refused by name, never dropped:** `STOPSIGNAL` (a Solari template has no stop signal: remove the line), `EXPOSE .../udp`, `FROM --platform` other than linux/amd64, multi-stage, `USER`, `VOLUME`, `HEALTHCHECK`, `ONBUILD`. `launch_parameters` on a blueprint carries the **size** only (`resource_size_request`, `custom_cpu_cores`, `custom_gb_memory`, `custom_disk_size`, which now also sends the disk size, plus `architecture: x86_64` and `provisioning_tier: standard`); `launch_commands`, `keep_alive_time_seconds`, `after_idle`, `lifecycle`, `user_parameters`, `available_ports`... raise and say to pass them to `devboxes.create`. `metadata`, `code_mounts`, `services`, `secrets`, `network_policy_id` raise. See `BLUEPRINTS.md`. |
|
|
46
46
|
| `blueprint.from_id / list`, `Blueprint.get_info / logs / delete` | OK, live | `list()` returns your org's custom templates only; `name` (substring), `status`, `limit`, `starting_after` and `include_total_count` are honoured (the count is exact when asked for). `blueprints.list_public()` is Solari's built-in sandbox templates (`base`, ...): the ones every account can create from. `logs()` has no timestamps/levels (Solari returns plain lines). `blueprints.preview` -> NO. |
|
|
47
47
|
| `storage_object.create / upload_from_dir / upload_from_bytes / upload_from_text / upload_from_file / list / from_id`, `StorageObject.refresh / complete / upload_content / get_download_url / download_as_bytes / download_as_text / delete`, `as_build_context()` | DIFF | On a gateway with storage objects these are real: `create` opens an object and returns its `upload_url` (`upload_content` PUTs to it, `complete` finishes it), `ttl` (a `timedelta`) or `ttl_ms` sets the expiry, views are Runloop's `ObjectView` (state `UPLOADING` / `READ_ONLY` / `DELETED`; the MIME type maps to `text` / `gzip` / `tgz` / `tar` / `binary`). `metadata` has nowhere to live and `list(search=, starting_after=, state=)`, `get_download_url(duration_seconds=)` have no equivalent: they raise. Without storage objects on the gateway, `upload_from_dir` makes a deterministic `.tar.gz` build context **held by this client** and embedded in the build recipe (capped at ~700 KB compressed, honours `.dockerignore`; `COPY`/`ADD` incl. `--chown`, `--chmod`, globs, `ADD` of a local tar copy from it; `COPY --from`, URLs, `../` sources are refused); the other calls raise `SolariCompatUnsupported`. A context from another process is `SolariCompatUnsupported`. |
|
|
48
|
-
| `secret.create / from_name / from_id / update / list / delete`, `Secret.get_info / update / delete`, `SecretById`, `client.secrets.*` (including `*_by_id`), create `secrets={ENV: secret_name}` | DIFF | Solari account secrets: **write-only** (no route returns a value), names `[A-Za-z][A-Za-z0-9_.-]{0,63}` double as ids (so `from_id(x)` is `from_name(x)` and `retrieve_by_id` is `retrieve`), values up to 16 KiB, 200 per org, at most 20 per create, reserved env names (`LD_*`, `PATH`, `HOME`...) refused. `list(limit=)` says `has_more` when others follow and leaves `total_count` `None` rather than guess; the gateway pages at 100, so a larger `limit` returns one page of 100 with `has_more` set. Not exercised on staging yet: the gateway answers 501 until the org-secrets key exists, and the shim then raises `SolariCompatUnsupported`. |
|
|
48
|
+
| `secret.create / from_name / from_id / update / list / delete`, `Secret.get_info / update / delete`, `SecretById`, `client.secrets.*` (including `*_by_id`), create `secrets={ENV: secret_name}` | DIFF | Solari account secrets: **write-only** (no route returns a value), names `[A-Za-z][A-Za-z0-9_.-]{0,63}` double as ids (so `from_id(x)` is `from_name(x)` and `retrieve_by_id` is `retrieve`), values up to 16 KiB, 200 per org, at most 20 per create, reserved env names (`LD_*`, `PATH`, `HOME`...) refused. `delete` returns the deleted secret and raises `NotFoundError` for a name that does not exist, as in Runloop. `list(limit=)` says `has_more` when others follow and leaves `total_count` `None` rather than guess; the gateway pages at 100, so a larger `limit` returns one page of 100 with `has_more` set. Not exercised on staging yet: the gateway answers 501 until the org-secrets key exists, and the shim then raises `SolariCompatUnsupported`. |
|
|
49
49
|
| `agent`, `axon`, `network_policy`, `gateway_config`, `mcp_config` | NO | Runloop platform features. |
|
|
50
50
|
|
|
51
51
|
## REST layer (`client.devboxes.*`)
|
|
@@ -127,6 +127,7 @@ import) keep working but still lack the image's `ENV`: rebuild them.
|
|
|
127
127
|
`DevboxView` fields Solari does not have are synthesized: `create_time_ms` from `createdAt`, one `state_transitions`
|
|
128
128
|
entry, `launch_parameters` from the real `cpu`/`memMb`, `capabilities=[]`.
|
|
129
129
|
- Solari's `stopped` state (guest powered itself off; `POST /sandboxes/:id/start`) has no Runloop equivalent: there is no `Devbox.start`, and a `stopped` sandbox reports status `shutdown` (same as the TypeScript package). Use `solari_sandbox`'s `start()` directly.
|
|
130
|
+
- Starting a command or a file call on a devbox that is already suspended (`cmd.exec`, `execute_async`, file calls) raises `ConflictError` (409, `code: "SandboxPaused"`) that says the devbox is suspended and to resume it first: Solari's own answer for the same request over REST. It used to be an opaque `APIConnectionError` ("WebSocket error"), because the gateway refuses a suspended devbox's control channel with a bare 409.
|
|
130
131
|
- A suspend ends the command a client is following: the process is saved with the devbox and runs on after a resume, but the execution
|
|
131
132
|
the gateway kept (or the control channel it was read through) is closed. `result()` then raises an `APIError` that says so,
|
|
132
133
|
`exit_status` stays `None`, and `get_state()` says `running` (the process is alive; it is not `completed`) (it used to return at once with `exit_status=None`, which read as success).
|
|
@@ -162,7 +163,7 @@ Last run 2026-10-21 against the F15 integration build `desktop-gateway:staging-1
|
|
|
162
163
|
list/retrieve/pagination, suspend/resume state, snapshot -> create from snapshot, errors, size capping. See the PR for the latest run.
|
|
163
164
|
|
|
164
165
|
## Default user and home directory (matching Runloop)
|
|
165
|
-
**Sandboxes run as `user` in `/home/user` on the hosted Solari API, matching Runloop's default** (checked on staging and production on 2026-11-03).
|
|
166
|
+
**Sandboxes run as `user` in `/home/user` on the hosted Solari API, matching Runloop's default** (checked on staging and production on 2026-11-03). A template built from a container image (Alpine, Ubuntu, any image base), and a gateway or template that predates user support, fall back to root, as below.
|
|
166
167
|
|
|
167
168
|
Here, Runloop sandboxes run as `user` in `/home/user`; commands, code and files all start there, and relative paths resolve against it. This package
|
|
168
169
|
asks the gateway for exactly that at create time (`user: "user"`, `cwd: "/home/user"`; the gateway creates the user at first boot with passwordless
|
|
@@ -171,6 +172,7 @@ sudo). Restores from a snapshot keep the snapshot's own user.
|
|
|
171
172
|
- **Gateway that predates `user` / `cwd`** (it answers 400 naming them, or ignores them): the plain create is used and the sandbox runs as **root in
|
|
172
173
|
`/home/root`**, which is what this package did before. Check `whoami` if code depends on it.
|
|
173
174
|
- **Template or snapshot made before user support** (the server answers 400 naming `user`): the plain create is used, the sandbox runs as **root**, and one warning says so. Rebuild templates and snapshots to get the vendor user.
|
|
175
|
+
- **Template built from a container image** (a blueprint with a Dockerfile `FROM` image; the server answers 400 naming `user` with "not available on a template built from an image"): the guest cannot add `user` to an image's own user database, so the plain create is used and commands run as the image's default user: **root** unless the image sets `USER` (Alpine and most base images do not). One warning names this cause. Rebuilding does not change it; use a blueprint built on Solari's base image to get `user`. (Checked against the gateway and guest code, 2026-11-16.)
|
|
174
176
|
- Shared isolation is commands and code only and takes no `user` / `cwd`; the compat packages never create shared sandboxes. (Runloop's own docs: the default user is `user` with home `/home/user`.)
|
|
175
177
|
|
|
176
178
|
## Snapshots and output (0.2.2)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "solari-runloop-compat"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.13"
|
|
8
8
|
description = "Runloop-compatible Python interface over Solari Sandboxes. Not affiliated with Runloop."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -33,7 +33,7 @@ from ._types import NOT_GIVEN, NoneType, NotGiven, Omit, Timeout, not_given, omi
|
|
|
33
33
|
from .lib.polling import PollingConfig, PollingTimeout
|
|
34
34
|
from .sdk import AsyncRunloopSDK, RunloopSDK
|
|
35
35
|
|
|
36
|
-
__version__ = "0.2.
|
|
36
|
+
__version__ = "0.2.13"
|
|
37
37
|
Client = Runloop
|
|
38
38
|
AsyncClient = AsyncRunloop
|
|
39
39
|
|
|
@@ -20,7 +20,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple
|
|
|
20
20
|
from urllib.parse import quote, urlencode
|
|
21
21
|
|
|
22
22
|
from solari_core import errors as core_errors
|
|
23
|
-
from solari_core._http import HttpTransport, new_idempotency_key
|
|
23
|
+
from solari_core._http import PAUSE_RETRY_WINDOW_MS, HttpTransport, new_idempotency_key
|
|
24
24
|
from solari_core.sandbox import Sandbox
|
|
25
25
|
from solari_sandbox import SandboxClient
|
|
26
26
|
|
|
@@ -345,11 +345,15 @@ class Gateway:
|
|
|
345
345
|
|
|
346
346
|
async def suspend(self, devbox_id: str, polling: Optional[PollingConfig] = None) -> DevboxView:
|
|
347
347
|
await self._drop_handle(devbox_id)
|
|
348
|
-
|
|
348
|
+
# Pause is idempotent on the gateway; the key is what makes the transport retry a POST at all, so a retryable 503
|
|
349
|
+
# PauseRetryable (the host cut the pause short and left the devbox running) is retried, with ONE key, for up to 120 s.
|
|
350
|
+
await self._req("POST", f"/sandboxes/{_q(devbox_id)}/pause", idempotency_key=new_idempotency_key(), retry_window_ms=PAUSE_RETRY_WINDOW_MS)
|
|
349
351
|
return await self.await_state(devbox_id, "suspended", polling)
|
|
350
352
|
|
|
351
353
|
async def resume(self, devbox_id: str, polling: Optional[PollingConfig] = None) -> DevboxView:
|
|
352
354
|
await self._drop_handle(devbox_id)
|
|
355
|
+
# Not keyed, on purpose, as in solari-sandbox: the gateway only marks a failed resume retryable while no VM runs, and a
|
|
356
|
+
# transport retry of a 502/503 after the host resumed would re-enter the host's resume (gateway vm-lifecycle.ts resumeVmLocked).
|
|
353
357
|
await self._req("POST", f"/sandboxes/{_q(devbox_id)}/resume")
|
|
354
358
|
return await self.await_state(devbox_id, "running", polling)
|
|
355
359
|
|
|
@@ -394,10 +398,15 @@ class Gateway:
|
|
|
394
398
|
resume), drop the handle, reconnect and retry. Core errors are translated to Runloop's."""
|
|
395
399
|
last: Optional[BaseException] = None
|
|
396
400
|
for attempt in range(4):
|
|
397
|
-
|
|
401
|
+
try:
|
|
402
|
+
h = await self._handle(devbox_id)
|
|
403
|
+
except ex.APIConnectionError as e:
|
|
404
|
+
await self._raise_if_suspended(devbox_id, e)
|
|
405
|
+
raise
|
|
398
406
|
try:
|
|
399
407
|
return await fn(h)
|
|
400
408
|
except core_errors.ConnectionError as e:
|
|
409
|
+
await self._raise_if_suspended(devbox_id, e)
|
|
401
410
|
last = e
|
|
402
411
|
await self._drop_handle(devbox_id)
|
|
403
412
|
await asyncio.sleep(0.4 * (attempt + 1))
|
|
@@ -405,6 +414,18 @@ class Gateway:
|
|
|
405
414
|
raise mp.map_error(e) from e
|
|
406
415
|
raise mp.map_error(last) from last # type: ignore[arg-type]
|
|
407
416
|
|
|
417
|
+
async def _raise_if_suspended(self, devbox_id: str, cause: BaseException) -> None:
|
|
418
|
+
"""A suspended devbox has no control channel (the gateway refuses the upgrade with a bare 409, an opaque connection
|
|
419
|
+
error): raise Solari's REST answer for the same request (409 ``SandboxPaused``, "resume first") as Runloop's
|
|
420
|
+
ConflictError instead. Nothing happens when the devbox is not suspended or its state cannot be read."""
|
|
421
|
+
try:
|
|
422
|
+
state = (await self.get_raw(devbox_id)).get("state")
|
|
423
|
+
except Exception: # noqa: BLE001 - the original error is the one to report then
|
|
424
|
+
return
|
|
425
|
+
if state in ("paused", "archived"):
|
|
426
|
+
msg = "The devbox is suspended: resume it (devbox.resume() or devboxes.resume(id)) before running commands or using its files."
|
|
427
|
+
raise ex.ConflictError(msg, status_code=409, body={"code": "SandboxPaused", "message": msg}) from cause
|
|
428
|
+
|
|
408
429
|
async def _is_native(self, devbox_id: str) -> bool:
|
|
409
430
|
"""3b: the guest agent chroots natively, so exec/fs can't see the host markers. The gateway says so on the sandbox view
|
|
410
431
|
(`fromImage` / `rootDir`): then no wrapper, no path prefix, no cwd from us, and no bash (an Alpine image has none) or
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Create sandboxes that run as Runloop's default user (commands, code and files default to its home)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
import warnings
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from solari_core.errors import GatewayError
|
|
10
|
+
|
|
11
|
+
from ._exceptions import SolariCompatUnsupported
|
|
12
|
+
|
|
13
|
+
VENDOR_USER = "user"
|
|
14
|
+
VENDOR_HOME = "/home/user"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _refuses_user_fields(e: BaseException) -> bool:
|
|
18
|
+
return isinstance(e, GatewayError) and e.status == 400 and re.search(r"\b(user|cwd)\b", repr(getattr(e, "body", None)), re.I) is not None
|
|
19
|
+
|
|
20
|
+
def _reason_of(e: BaseException) -> str:
|
|
21
|
+
"""The gateway's reason for refusing ``user`` (its 400 says why), so the warning names the real cause."""
|
|
22
|
+
body = getattr(e, "body", None)
|
|
23
|
+
for s in (getattr(body, "error", None), getattr(body, "message", None), str(e)):
|
|
24
|
+
if isinstance(s, str) and s:
|
|
25
|
+
return s
|
|
26
|
+
return ""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def root_warning_text(reason: str) -> str:
|
|
30
|
+
"""The warning for a sandbox that runs as root because the gateway would not give it the vendor user, built from the
|
|
31
|
+
gateway's reason. A template built from a container image (Alpine, Ubuntu, any ``FROM`` image) keeps the image's own
|
|
32
|
+
accounts: the guest cannot add a user there, and rebuilding does not change that."""
|
|
33
|
+
head = f"solari-runloop-compat: the sandbox runs as root instead of '{VENDOR_USER}'"
|
|
34
|
+
if re.search(r"built from an image|rootDir", reason, re.I):
|
|
35
|
+
return (
|
|
36
|
+
f"{head} because its template was built from a container image (for example Alpine), and Solari cannot add the "
|
|
37
|
+
f"'{VENDOR_USER}' account to an image's own user database: commands run as the image's default user (root unless the "
|
|
38
|
+
f"image sets USER). Rebuilding the template does not change this; use a blueprint built on Solari's base image to get '{VENDOR_USER}'."
|
|
39
|
+
)
|
|
40
|
+
if re.search(r"predates user support", reason, re.I):
|
|
41
|
+
return f"{head} because the template or snapshot was made before user support shipped. Rebuild it to get the vendor user."
|
|
42
|
+
if re.search(r"host pool", reason, re.I):
|
|
43
|
+
return f"{head} because this server's host pool cannot run sandboxes as a chosen user yet. Nothing in your template causes this."
|
|
44
|
+
return f"{head} because the server would not create the user" + (f" ({reason})." if reason else ".")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _warn_root(e: BaseException) -> None:
|
|
48
|
+
warnings.warn(root_warning_text(_reason_of(e)), RuntimeWarning, stacklevel=4)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
async def create_as_vendor_user(solari: Any, **opts: Any) -> Any:
|
|
52
|
+
"""``solari.create(**opts)`` with ``user`` / ``cwd`` set to Runloop's defaults. A gateway that predates them (it answers 400
|
|
53
|
+
naming them) gets the plain create, and the sandbox runs as root there (COMPAT.md). Restores from a snapshot keep the
|
|
54
|
+
snapshot's own user and are sent without them."""
|
|
55
|
+
if opts.get("from_snapshot") is not None:
|
|
56
|
+
return await solari.create(**opts)
|
|
57
|
+
explicit = opts.get("user") is not None # a user the caller named (launch_parameters.user_parameters) wins
|
|
58
|
+
try:
|
|
59
|
+
return await solari.create(**{"user": VENDOR_USER, "cwd": VENDOR_HOME, **opts})
|
|
60
|
+
except GatewayError as e:
|
|
61
|
+
if not _refuses_user_fields(e):
|
|
62
|
+
raise
|
|
63
|
+
if explicit: # the default user is best effort on a gateway that predates user/cwd; a user the caller named is not
|
|
64
|
+
raise SolariCompatUnsupported("user_parameters", "this gateway cannot create sandboxes as another user yet") from e
|
|
65
|
+
_warn_root(e)
|
|
66
|
+
return await solari.create(**opts)
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"""Create sandboxes that run as Runloop's default user (commands, code and files default to its home)."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import re
|
|
6
|
-
import warnings
|
|
7
|
-
from typing import Any
|
|
8
|
-
|
|
9
|
-
from solari_core.errors import GatewayError
|
|
10
|
-
|
|
11
|
-
from ._exceptions import SolariCompatUnsupported
|
|
12
|
-
|
|
13
|
-
VENDOR_USER = "user"
|
|
14
|
-
VENDOR_HOME = "/home/user"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def _refuses_user_fields(e: BaseException) -> bool:
|
|
18
|
-
return isinstance(e, GatewayError) and e.status == 400 and re.search(r"\b(user|cwd)\b", repr(getattr(e, "body", None)), re.I) is not None
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def _warn_root() -> None:
|
|
22
|
-
warnings.warn(
|
|
23
|
-
"solari-runloop-compat: the server or this template's image predates user support, so the sandbox runs as root instead of 'user'. "
|
|
24
|
-
"Rebuild templates and snapshots made before user support shipped to get the vendor user.",
|
|
25
|
-
RuntimeWarning,
|
|
26
|
-
stacklevel=4,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
async def create_as_vendor_user(solari: Any, **opts: Any) -> Any:
|
|
31
|
-
"""``solari.create(**opts)`` with ``user`` / ``cwd`` set to Runloop's defaults. A gateway that predates them (it answers 400
|
|
32
|
-
naming them) gets the plain create, and the sandbox runs as root there (COMPAT.md). Restores from a snapshot keep the
|
|
33
|
-
snapshot's own user and are sent without them."""
|
|
34
|
-
if opts.get("from_snapshot") is not None:
|
|
35
|
-
return await solari.create(**opts)
|
|
36
|
-
explicit = opts.get("user") is not None # a user the caller named (launch_parameters.user_parameters) wins
|
|
37
|
-
try:
|
|
38
|
-
return await solari.create(**{"user": VENDOR_USER, "cwd": VENDOR_HOME, **opts})
|
|
39
|
-
except GatewayError as e:
|
|
40
|
-
if not _refuses_user_fields(e):
|
|
41
|
-
raise
|
|
42
|
-
if explicit: # the default user is best effort on a gateway that predates user/cwd; a user the caller named is not
|
|
43
|
-
raise SolariCompatUnsupported("user_parameters", "this gateway cannot create sandboxes as another user yet") from e
|
|
44
|
-
_warn_root()
|
|
45
|
-
return await solari.create(**opts)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/lib/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/blueprint_view.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/devbox_view.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/object_view.py
RENAMED
|
File without changes
|
|
File without changes
|
{solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/secret_view.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solari_runloop_compat-0.2.12 → solari_runloop_compat-0.2.13}/solari_runloop/types/tunnel_view.py
RENAMED
|
File without changes
|