Camera permission and review fixes (openpanel C3, C4)
C4: a device's `viewers` (superusers by default, or members) covers the image and video messages its ports publish. Anyone else gets none of their values on the socket, in the catalogue or a flow's state, 403 for their history, for the frames they hold (the last 8 included) and for TURN credentials, no bytes when asking for them, and `bye: forbidden` for a live view. A device credential stays bounded by its dashboards. The device page sets it in its Camera section, and a tile the viewer may not see says "No access to this camera" and asks the camera for nothing. C3: - A volatile upload is held to MAX_FRAME_BYTES (4 MiB, 413 above it, read without extra copies), and so is a frame on a device's socket. - A frame the engine holds in memory is written to the ring directory before a local worker is handed it, so load_artifact finds it. - A socket the bus dropped events for catches up with a snapshot, demand included, and a device's credential is checked again per frame, cached by the flow store revision and its nonce, so a lost event never keeps an unpaired device's frames coming. - A report is at most 64 KB once its named config_schemas are put in place. - A device away for 60 s has its true bool messages set to false. - Refused frames are logged by fixed keys, a frame is named after its message, `fluksio serve` waits 5 s for open connections, a tile with a stream URL creates no demand, the 8-name cap keeps the newest names. - Every container's log rotates (json-file, 3 x 10 MB).
This commit is contained in:
@@ -24,13 +24,14 @@ import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable, Iterator
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import orjson
|
||||
from fluksio_worker import worker_main as _worker_main
|
||||
|
||||
from fluksio.flow.artifacts import is_reference
|
||||
from fluksio.flow.events import EventBus
|
||||
from fluksio.flow.nodes.base import NodeOutputError
|
||||
|
||||
@@ -129,6 +130,19 @@ def _remote_class(name: str) -> type[RemoteError]:
|
||||
return cls
|
||||
|
||||
|
||||
def _digests(value: Any) -> Iterator[str]:
|
||||
"""Every artifact digest a node's inputs name, however deep."""
|
||||
if isinstance(value, dict):
|
||||
if is_reference(value):
|
||||
yield str(value["digest"])
|
||||
return
|
||||
for item in value.values():
|
||||
yield from _digests(item)
|
||||
elif isinstance(value, list):
|
||||
for item in value:
|
||||
yield from _digests(item)
|
||||
|
||||
|
||||
class _Worker:
|
||||
"""One subprocess, and the framing of one request/response over its pipes."""
|
||||
|
||||
@@ -237,10 +251,16 @@ class PythonWorkerPool:
|
||||
events: EventBus | None = None,
|
||||
env: dict[str, str] | None = None,
|
||||
max_rss_mb: int = 0,
|
||||
spill: Callable[[str], None] | None = None,
|
||||
) -> None:
|
||||
self.python = python
|
||||
self.size = size
|
||||
self.events = events
|
||||
# Called with each artifact a call's inputs name, before the call: a
|
||||
# frame the engine holds in memory is written where a worker in this
|
||||
# container finds it (``VolatileStore.spill``), since it is another
|
||||
# process.
|
||||
self.spill = spill
|
||||
# A worker holding more than this when its call returns is retired
|
||||
# rather than kept warm; 0 keeps them all. A library like JAX keeps what
|
||||
# it allocated for as long as the process lives, and warm is the point
|
||||
@@ -307,6 +327,7 @@ class PythonWorkerPool:
|
||||
events=self.events,
|
||||
env={**self.env, **extra},
|
||||
max_rss_mb=self.max_rss_mb,
|
||||
spill=self.spill,
|
||||
)
|
||||
child._generation = self._generation
|
||||
child.start()
|
||||
@@ -593,6 +614,9 @@ class PythonWorkerPool:
|
||||
run_id: str = "",
|
||||
on_event: Callable[[dict[str, Any]], None] | None = None,
|
||||
) -> Any:
|
||||
if self.spill is not None:
|
||||
for digest in _digests(kwargs):
|
||||
self.spill(digest)
|
||||
response = self._request(
|
||||
{
|
||||
"op": "run",
|
||||
|
||||
Reference in New Issue
Block a user