k8s: the controller pod keeps no volume; the state gate goes
This commit is contained in:
parent
140ee7f38a
commit
4ea3b0e10d
1 changed files with 233 additions and 1110 deletions
|
|
@ -31,10 +31,6 @@ cluster follow the same pattern.
|
|||
rule. One switch covers the queue's server and its auth callout. It needs
|
||||
the iptables firewall (`networking.nftables.enable` off).
|
||||
[The queue](#the-queue) has its own section.
|
||||
- `services.hyperhive.deploy.<service>.k8s.freshState` (default `false`) for
|
||||
the service whose pod keeps state worth moving in a volume:
|
||||
`swarm-controller`. 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
|
||||
|
|
@ -104,27 +100,14 @@ Job:
|
|||
|
||||
A failed step fails the unit, and the host unit doesn't start: the service stays
|
||||
down and never doubles. A rerun resumes from the renamed link. Persistent volume
|
||||
claims stay; `swarmctl migrate finish` deletes them.
|
||||
claims stay until the operator deletes them.
|
||||
|
||||
## State
|
||||
|
||||
A pod with a state volume that holds state worth moving (`swarm-controller`)
|
||||
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, `swarm-stt` and
|
||||
`swarm-ci-metrics` have a volume that the gate doesn't check, and the queue's
|
||||
volume is the host unit's own directory.
|
||||
No pod starts behind a gate that checks its state volume: a service keeps
|
||||
nothing a switch has to copy. Each service's state is below.
|
||||
`swarm-notify-router`, `swarm-review-classifier` and `swarm-claude-login` have
|
||||
no volume.
|
||||
|
||||
`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
|
||||
|
|
@ -132,22 +115,20 @@ switch in either direction copies nothing, and the router continues from the
|
|||
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
|
||||
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.
|
||||
cache sits in the container's `/var/lib/swarm-stt`. In the cluster it sits in an
|
||||
`emptyDir` at the same path, so the pod has no claim 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 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.
|
||||
with none 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.
|
||||
|
||||
## The controller
|
||||
|
||||
|
|
@ -192,13 +173,13 @@ controller may move there.
|
|||
`/healthz` and readiness on `/readyz`. Readiness needs the queue connection
|
||||
and a fresh store login, so a store role that refuses the pod's token leaves
|
||||
it NotReady.
|
||||
- **State.** `/var/lib/swarm-controller` is the PersistentVolumeClaim
|
||||
`swarm-controller-state`. It starts empty, and nothing here copies the host's
|
||||
directory into it ([migrate](migrate.md) does). An empty claim holds no
|
||||
`operator-matrix-admins.json`, which reads as an empty set: the controller
|
||||
revokes nobody, and an account removed from the operator group before the
|
||||
copy keeps its homeserver admin. The webhook secret is in the store, so it
|
||||
survives.
|
||||
- **State.** `/var/lib/swarm-controller` is an `emptyDir`. The record of the
|
||||
operator Matrix admin grants is in the queue's key-value store, so the pod
|
||||
revokes the accounts the host controller granted. What the directory holds
|
||||
starts again from nothing: the forge avatar markers and the legacy webhook
|
||||
secret, which the secret store also holds. The controller's first start on
|
||||
the host imports a legacy grant file into the store, so run it there once
|
||||
before the switch.
|
||||
- **The rev.** The unit's rev file, `/etc/hyperhive/swarm-controller.json`, is a
|
||||
`subPath` mount of the `swarm-controller-etc` ConfigMap, which a running pod
|
||||
never sees change. The Deployment's pod template carries `checksum/etc`, a
|
||||
|
|
|
|||
Loading…
Reference in a new issue