k8s: stt and ci-metrics start without a state gate
This commit is contained in:
parent
772435504f
commit
a793df9708
3 changed files with 296 additions and 309 deletions
|
|
@ -23,7 +23,7 @@ A service gets manifests on the host whose configuration deploys it:
|
|||
| ------------------------- | ---------- | ------------------------------------------------------------------------------------------------ |
|
||||
| `swarm-controller` | Deployment | ServiceAccount, PersistentVolumeClaim `swarm-controller-state`, ConfigMap `swarm-controller-etc` |
|
||||
| `swarm-notify-router` | Deployment | ServiceAccount |
|
||||
| `swarm-stt` | Deployment | ServiceAccount, PersistentVolumeClaim `swarm-stt-state` |
|
||||
| `swarm-stt` | Deployment | ServiceAccount |
|
||||
| `swarm-review-classifier` | Deployment | ServiceAccount |
|
||||
| `swarm-claude-login` | Deployment | ServiceAccount |
|
||||
| `swarm-ci-metrics` | CronJob | ServiceAccount, PersistentVolumeClaim `swarm-ci-metrics-state` |
|
||||
|
|
|
|||
|
|
@ -80,15 +80,15 @@ for every storage class.
|
|||
endpoints the [services page](../../2-handbook/swarm/services.md) lists; the
|
||||
[readiness page](../swarm/readiness.md) has their mechanics.
|
||||
|
||||
| service | state | what moves | readiness signal | cut-over and rollback |
|
||||
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `swarm-notify-router` | in the queue: a state bucket and a durable consumer on the forge events stream | nothing | `/readyz`: queue connected | `runtime = "k8s"`, rebuild; back with `runtime = "host"` |
|
||||
| `swarm-review-classifier` | none on disk; its runs and settings live in buckets the controller owns | nothing | `/readyz`: queue connected | same |
|
||||
| `swarm-claude-login` | none; credentials it writes go to the store | nothing; a login in progress ends | `/readyz`: queue connected | same |
|
||||
| `swarm-stt` | the transcript cache, entries live 24 h | nothing; the pod starts with an empty cache, once the gate has its marker | `/readyz`: queue connected | same |
|
||||
| `swarm-ci-metrics` | `cursor.json` in the state directory; losing it re-pushes every run | the state directory, to a PVC | the CronJob's next Job completes | `runtime = "k8s"`, rebuild; the timer goes, the CronJob runs. Rollback copies the PVC back |
|
||||
| NATS + `swarm-nats-auth` | JetStream's `store_dir`: the swarm's desired state, operator profiles, schedules and run records. `swarm-nats-auth` keeps nothing | the whole `store_dir`, to a PVC; the cut-over rebuild stops NATS, so the copy reads a quiescent tree | nats-server's `/healthz?js-enabled-only=true` and `swarm-nats-auth`'s `/readyz`; Ready when both pass | `runtime = "k8s"`, rebuild; the pod takes the same host port, so hives keep their URL. Rollback copies the PVC back |
|
||||
| `swarm-controller` | its state directory: the operator-admin set, the legacy `webhook-secret` fallback and the forge avatar markers. The rest sits in the queue or the store | the state directory, to a PVC | `/readyz` on the controller's plain health listener | `runtime = "k8s"`, rebuild; the same rebuild points the gateway's `/api/` and `/webhook/forge/` upstreams at the controller's TCP listener. Rollback copies the PVC back and returns the upstreams to the socket |
|
||||
| service | state | what moves | readiness signal | cut-over and rollback |
|
||||
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `swarm-notify-router` | in the queue: a state bucket and a durable consumer on the forge events stream | nothing | `/readyz`: queue connected | `runtime = "k8s"`, rebuild; back with `runtime = "host"` |
|
||||
| `swarm-review-classifier` | none on disk; its runs and settings live in buckets the controller owns | nothing | `/readyz`: queue connected | same |
|
||||
| `swarm-claude-login` | none; credentials it writes go to the store | nothing; a login in progress ends | `/readyz`: queue connected | same |
|
||||
| `swarm-stt` | the transcript cache, entries live 24 h; the pod keeps it in an `emptyDir` | nothing; the pod starts with an empty cache | `/readyz`: queue connected | same |
|
||||
| `swarm-ci-metrics` | `cursor.json` in the state directory; losing it re-pushes every run | nothing; the pod starts on an empty PVC with no gate, and its first pass re-pushes every run as the same points | the CronJob's next Job completes | `runtime = "k8s"`, rebuild; the timer goes, the CronJob runs; back with `runtime = "host"` |
|
||||
| NATS + `swarm-nats-auth` | JetStream's `store_dir`: the swarm's desired state, operator profiles, schedules and run records. `swarm-nats-auth` keeps nothing | the whole `store_dir`, to a PVC; the cut-over rebuild stops NATS, so the copy reads a quiescent tree | nats-server's `/healthz?js-enabled-only=true` and `swarm-nats-auth`'s `/readyz`; Ready when both pass | `runtime = "k8s"`, rebuild; the pod takes the same host port, so hives keep their URL. Rollback copies the PVC back |
|
||||
| `swarm-controller` | its state directory: the operator-admin set, the legacy `webhook-secret` fallback and the forge avatar markers. The rest sits in the queue or the store | the state directory, to a PVC | `/readyz` on the controller's plain health listener | `runtime = "k8s"`, rebuild; the same rebuild points the gateway's `/api/` and `/webhook/forge/` upstreams at the controller's TCP listener. Rollback copies the PVC back and returns the upstreams to the socket |
|
||||
|
||||
Two facts the table rests on:
|
||||
|
||||
|
|
@ -108,18 +108,16 @@ Two facts the table rests on:
|
|||
1. **`swarm-notify-router` alone.** The first cut-over proves the runtime
|
||||
switch, the image, the store identity and reaching the host-run NATS by
|
||||
name, with nothing to copy.
|
||||
2. **`swarm-review-classifier`, `swarm-claude-login`, `swarm-stt`**, in one
|
||||
rebuild or one at a time. No state, same pattern as step 1.
|
||||
3. **`swarm-ci-metrics`.** The first copy, of one small file. It exercises
|
||||
the snapshot, the gate, the copy and the rollback on state whose loss
|
||||
costs a re-push, not data.
|
||||
4. **NATS with `swarm-nats-auth`.** The riskiest move: the largest copy, every
|
||||
2. **`swarm-review-classifier`, `swarm-claude-login`, `swarm-stt`,
|
||||
`swarm-ci-metrics`**, in one rebuild or one at a time. Nothing to copy, same
|
||||
pattern as step 1: the pods start with no gate on an empty volume.
|
||||
3. **NATS with `swarm-nats-auth`.** The riskiest move: the largest copy, every
|
||||
hive and agent disconnects, and the data is the swarm's desired state.
|
||||
The copy path has run once by then. `swarm-nats-auth` moves in the same
|
||||
pod, because it answers the auth callout on every connect and dials the
|
||||
It's the first copy `swarmctl migrate` makes. `swarm-nats-auth` moves in the
|
||||
same pod, because it answers the auth callout on every connect and dials the
|
||||
server by name, which the pod's host aliases map to its loopback.
|
||||
5. **`swarm-controller` last.**
|
||||
- It's the operator's view of the swarm. Kept on the host through step 4,
|
||||
4. **`swarm-controller` last.**
|
||||
- It's the operator's view of the swarm. Kept on the host through step 3,
|
||||
it reports from an unchanged place whether the hives reconnected after
|
||||
the NATS move, and `swarmctl` keeps its local socket for the checks.
|
||||
- Its cut-over also changes the gateway's upstream and ends the local
|
||||
|
|
@ -214,9 +212,7 @@ stops a workload leaves its PVC in place, so the data survives until `finish`.
|
|||
|
||||
A fresh install straight onto k8s has no host state to copy: with
|
||||
`deploy.<svc>.k8s.freshState` on, the gate marks the empty volume itself
|
||||
(`{"fresh": true, "at": <time>}`), and `swarmctl migrate` isn't needed. A
|
||||
service with state that moves nothing, `swarm-stt`, still needs the marker:
|
||||
`swarmctl migrate` writes one that names no source.
|
||||
(`{"fresh": true, "at": <time>}`), and `swarmctl migrate` isn't needed.
|
||||
|
||||
## Downtime and what hives see
|
||||
|
||||
|
|
@ -229,7 +225,7 @@ pod passing step 4.
|
|||
| `swarm-review-classifier` | 2 min | A try-out request in the gap gets no answer, and its caller reports a failure |
|
||||
| `swarm-claude-login` | 2 min | A login in progress fails; the operator starts it again |
|
||||
| `swarm-stt` | 2 min | Transcription requests fail during the gap; the cache starts empty |
|
||||
| `swarm-ci-metrics` | one 5-minute period | One pass runs late; the copied cursor means no run gets pushed twice |
|
||||
| `swarm-ci-metrics` | one 5-minute period | One pass runs late; the first pass on the pod's empty cursor pushes every run again |
|
||||
| NATS + `swarm-nats-auth` | 10 min; the copy takes most of it | below |
|
||||
| `swarm-controller` | 5 min | The swarm UI and API answer with gateway errors. Forge webhook deliveries in the gap fail at the forge. After the cut-over, `swarmctl` on the host needs `--swarm` |
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue