Watch
0
0
Fork
You've already forked hyperhive
0

k8s: stt's pod runs in a user namespace of its own

This commit is contained in:
atlas 2026-11-23 13:44:57 +01:00 • committed by maia
commit 4e60183bfa

View file

@ -13,8 +13,8 @@
# token, read its client secret and minted a token with it. The router
# routes an event and a deleted pod exits 0 within its grace period; the
# speech-to-text pod carries its limits and keeps its cache in an emptyDir,
# with no claim and no state gate, and its NetworkPolicy lets a queue request
# reach it, and it reach DNS and four host ports, and nothing else;
# with no claim and no state gate, in a user namespace, and its NetworkPolicy
# lets a queue request in and only DNS and four host ports out;
# - the poller's Job completes against a forge that lists one run, pushes it to
# its own route of the swarm collector, holds no Secret, and keeps its cursor
# in a volume, so a second Job pushes nothing, and starts with no state
@ -736,6 +736,25 @@ pkgs.testers.runNixOSTest {
router_resources = json.loads(kube(machine, f"get pod {router} -o json"))["spec"]["containers"][0]["resources"]
assert router_resources == {}, router_resources
with subtest("the speech-to-text pod runs in a user namespace, and still logs in, writes its state and starts its decoder"):
assert kube(machine, f"get pod {stt_pod} -o jsonpath='{{.spec.hostUsers}}'").strip() == "false"
def id_map(service: str) -> list[str]:
container = machine.succeed(f"k3s crictl ps --name '^{service}$' --state running -q").split()[0]
pid = machine.succeed(f"k3s crictl inspect {container} | jq -r .info.pid").strip()
return machine.succeed(f"cat /proc/{pid}/uid_map").split()
# The router's pod shares the node's ids, which is what reading the map
# shows when there is no namespace.
assert id_map(SERVICE) == ["0", "0", "4294967295"], id_map(SERVICE)
mapping = id_map(STT)
assert mapping[0] == "0" and int(mapping[1]) >= 65536 and mapping[2] == "65536", mapping
# The login read the projected token, and the decode writes a scratch
# directory in the emptyDir; both volumes are idmapped mounts.
machine.wait_until_succeeds(f"grep -F '/api/oidc/token ${sttClientId}:{STT_SECRET}' ${tokenLog}", timeout=120)
out = machine.succeed(f"nats {NATS} req '$SWARM.stt.transcribe.{AGENT}' 'OggS not really audio' --timeout 90s 2>/dev/null")
reply = json.loads([line for line in out.splitlines() if line.startswith("{")][-1])
assert reply == {"status": "failed", "message": "the audio could not be decoded"}, reply
with subtest("the speech-to-text cache is an emptyDir mounted where the unit keeps its state, with no claim and no state gate"):
stt_spec = json.loads(kube(machine, f"get pod {stt_pod} -o json"))["spec"]
assert [v for v in stt_spec["volumes"] if v["name"] == "state"] == [{"name": "state", "emptyDir": {}}], stt_spec["volumes"]