Watch
0
0
Fork
You've already forked hyperhive
0

k8s: stt and ci-metrics start without a state gate

This commit is contained in:
atlas 2026-11-23 02:46:31 +01:00 • committed by mara
commit 2232acd056

View file

@ -32,9 +32,9 @@ cluster follow the same pattern.
the iptables firewall (`networking.nftables.enable` off).
[The queue](#the-queue) has its own section.
- `services.hyperhive.deploy.<service>.k8s.freshState` (default `false`) for
each service whose pod keeps state in a volume: `swarm-controller`, `stt`,
`ci-metrics` and `nats`. It says whether the pod may start on an empty volume
([State](#state)).
each service whose pod keeps state worth moving in a volume:
`swarm-controller` and `nats`. It says whether the pod may start on an empty
volume ([State](#state)).
With `"host"`, a host without [the cluster node](node.md) renders the same
configuration as before the option existed. With the node on and every service
@ -108,21 +108,22 @@ claims stay; `swarmctl migrate finish` deletes them.
## State
A pod with a state volume starts only on migrated state. Its first init
container, `state-gate`, mounts the volume and exits 0 when the volume holds
`.hyperhive-migrated`. A volume with no entries besides `lost+found` gets the
marker (`{"fresh": true, "at": <time>}`) and passes where the service's
`k8s.freshState` is on. Every other volume fails the gate, including one that
holds files and no marker, since a copy may have stopped half way. The pod stays
in `Init:Error`, and the container's termination message and log carry one
line that names the service, the `swarmctl migrate` command and the option to
set for a fresh install. Nothing of the service runs on the empty volume. The
gate doesn't decide which copy runs: the host unit stops before the pod
exists. Switching a stateful service to `"k8s"` on a live host therefore needs
`swarmctl migrate`, which copies the state and writes the marker, or the
fresh flag, which is for a swarm with no state to lose.
`swarm-notify-router`, `swarm-review-classifier` and `swarm-claude-login` have
no volume and no gate.
A pod with a state volume that holds state worth moving (`swarm-controller` and
NATS) starts only on migrated state. Its first init container, `state-gate`,
mounts the volume and exits 0 when the volume holds `.hyperhive-migrated`. A
volume with no entries besides `lost+found` gets the marker (`{"fresh": true,
"at": <time>}`) and passes where the service's `k8s.freshState` is on. Every
other volume fails the gate, including one that holds files and no marker, since
a copy may have stopped half way. The pod stays in `Init:Error`, and the
container's termination message and log carry one line that names the service,
the `swarmctl migrate` command and the option to set for a fresh install.
Nothing of the service runs on the empty volume. The gate doesn't decide which
copy runs: the host unit stops before the pod exists. Switching a stateful
service to `"k8s"` on a live host therefore needs `swarmctl migrate`, which
copies the state and writes the marker, or the fresh flag, which is for a swarm
with no state to lose. `swarm-notify-router`, `swarm-review-classifier` and
`swarm-claude-login` have no volume and no gate, and `swarm-stt` and
`swarm-ci-metrics` have a volume that the gate doesn't check.
`swarm-notify-router` keeps nothing on the host. Its durable consumer on the
forge events stream and its `notify-router-state` bucket live in the queue, so a
@ -131,23 +132,21 @@ consumer's position.
`swarm-stt` keeps a transcript cache, which lives 24 hours. On the host the
cache sits in the container's `/var/lib/swarm-stt`. In the cluster it sits in
the PersistentVolumeClaim `swarm-stt-state`, mounted at the same path. A switch
copies neither: each side starts with the cache it last had, empty the first
time (the pod's gate wants the marker or `deploy.stt.k8s.freshState` for
that), and transcribes a memo that only the other side cached. The claim stays
after a switch back, as every claim does, and the container's directory stays
too. The whisper model isn't state: the pod's image holds it, from the same
store path the container reads, and the volume doesn't.
an `emptyDir` at the same path, so the pod has no claim and no gate and starts
on an empty cache on every start of the pod. A switch copies nothing, and the
service transcribes a memo that only the other side cached. The whisper model
isn't state: the pod's image holds it, from the same store path the container
reads.
`swarm-ci-metrics` keeps a cursor, `cursor.json`, which holds the run numbers
already pushed. On the host it sits in the service's state directory. In
the cluster it sits in the PersistentVolumeClaim `swarm-ci-metrics-state`,
mounted at the same path, and the claim binds with the first Job. A
switch copies neither, so each side keeps the cursor it last had, and
the first pass on a side with none (the pod's gate wants the marker or
`deploy.ci-metrics.k8s.freshState` for that) pushes every run again, as
the same points. A second Job on the same side finds the cursor and pushes
nothing. The claim stays after a switch back, and so does the host's directory.
already pushed. On the host it sits in the service's state directory. In the
cluster it sits in the PersistentVolumeClaim `swarm-ci-metrics-state`, mounted
at the same path, and the claim binds with the first Job. A switch copies
neither, so each side keeps the cursor it last had, and the first pass on a side
with none pushes every run again, as the same points. The pod starts on the
empty claim with no gate. A second Job on the same side finds the cursor and
pushes nothing. The claim stays after a switch back, and so does the host's
directory.
## The controller