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

@ -116,8 +116,6 @@ let
lib.recursiveUpdate config {
services.hyperhive.deploy = {
nats.k8s.freshState = true;
stt.k8s.freshState = true;
ci-metrics.k8s.freshState = true;
swarm-controller.k8s.freshState = true;
};
};
@ -902,7 +900,6 @@ let
&&
lib.sort lib.lessThan (map (o: o.kind) onCluster.services.k3s.manifests.swarm-stt.content) == [
"Deployment"
"PersistentVolumeClaim"
"ServiceAccount"
]
&&
@ -1124,23 +1121,26 @@ let
}));
}
{
name = "the speech-to-text pod has probes on its health listener, keeps its cache in a volume, mounts no Secret, and runs as every pod does";
name = "the speech-to-text pod has probes on its health listener, keeps its cache in an emptyDir with no claim, mounts no Secret, and runs as every pod does";
ok =
let
c = container "swarm-stt";
spec = podSpec "swarm-stt";
pvc = objects."swarm-stt/persistentvolumeclaim";
cred = lib.findFirst (v: v.name == "credentials") null spec.volumes;
in
(lib.head c.ports).containerPort == 8080
&& c.readinessProbe.httpGet.path == "/readyz"
&& c.livenessProbe.httpGet.path == "/healthz"
&& pvc.metadata.name == "swarm-stt-state"
&& pvc.spec.resources.requests.storage == "1Gi"
&& lib.any (m: m.name == "state" && m.mountPath == "/var/lib/swarm-stt") c.volumeMounts
# The cache needs no claim, and is no state to gate. The poller beside
# it, whose cursor is kept, is the control that a claim renders.
&&
(lib.findFirst (v: v.name == "state") null spec.volumes).persistentVolumeClaim.claimName
== "swarm-stt-state"
(lib.findFirst (v: v.name == "state") null spec.volumes) == {
name = "state";
emptyDir = { };
}
&& !(objects ? "swarm-stt/persistentvolumeclaim")
&& objects ? "swarm-ci-metrics/persistentvolumeclaim"
# The one credential the pod holds is the store's public CA, from the
# ConfigMap. The controller's pod is the control for the lookup.
&& cred != null
@ -1690,12 +1690,11 @@ let
&& !(lib.any (v: v ? secret) spec.volumes);
}
{
# The gate is the pod's first init container wherever the pod has a
# state volume, ahead of the TLS leaf. The default holds the pod back; a
# fresh install opts in. Each arm's value is the control for the other,
# and the list of gated services is the control for the services with no
# volume.
name = "every pod with a state volume starts with the state gate on that volume, and the fresh option sets what it reads";
# The gate is the first init container of a pod whose state is worth
# moving, ahead of the TLS leaf. The default holds the pod back; a fresh
# install opts in. Each arm's value is the control for the other, and the
# gated services are the control for the ones that start with no gate.
name = "every pod whose state is worth moving starts with the state gate on that volume, and the fresh option sets what it reads";
ok =
let
fresh = render (freshInstall onCluster);
@ -1714,27 +1713,21 @@ let
volume = "state";
option = "deploy.swarm-controller.k8s.freshState";
};
swarm-stt = {
path = "/var/lib/swarm-stt";
volume = "state";
option = "deploy.stt.k8s.freshState";
};
swarm-ci-metrics = {
path = "/var/lib/swarm-ci-metrics";
volume = "state";
option = "deploy.ci-metrics.k8s.freshState";
};
swarm-nats = {
path = "/var/lib/nats";
volume = "nats-data";
option = "deploy.nats.k8s.freshState";
};
};
ungated = [
# The poller keeps a claim for its cursor and the speech-to-text pod
# keeps none; neither is gated.
unclaimed = [
"swarm-notify-router"
"swarm-review-classifier"
"swarm-claude-login"
"swarm-stt"
];
ungated = unclaimed ++ [ "swarm-ci-metrics" ];
one =
name: g:
let
@ -1768,8 +1761,10 @@ let
in
lib.all (n: one n gated.${n}) (lib.attrNames gated)
&& lib.all (n: gate objects n == null && gate fresh n == null) ungated
&& lib.all (n: !(objects ? "${n}/persistentvolumeclaim")) ungated
&& lib.all (n: objects ? "${n}/persistentvolumeclaim") (lib.attrNames gated)
&& lib.all (n: !(objects ? "${n}/persistentvolumeclaim")) unclaimed
&& lib.all (n: objects ? "${n}/persistentvolumeclaim") (
lib.attrNames gated ++ [ "swarm-ci-metrics" ]
)
# One image serves every gate.
&& lib.length (lib.unique (map (n: (gate objects n).image) (lib.attrNames gated))) == 1;
}
@ -1858,21 +1853,22 @@ let
{
# Each state block is read against what the render makes: the claim is
# the PVC's name and the mount is where the state gate looks. The
# stateless services are the control that an entry can carry no state.
name = "migrate.json names every service, with a state block exactly for the ones whose pod has a state volume";
# stateless services are the control that an entry can carry no state. The
# poller has a claim and no entry, since it starts without a gate.
name = "migrate.json names every service, with a state block exactly for the ones whose state is gated";
ok =
let
services = (migrateOf withNode).services;
stateful = [
"swarm-controller"
"swarm-nats"
"swarm-stt"
"swarm-ci-metrics"
];
stateless = [
"swarm-notify-router"
"swarm-review-classifier"
"swarm-claude-login"
"swarm-stt"
"swarm-ci-metrics"
];
objs = render withNode;
gateDir =
@ -1896,7 +1892,9 @@ let
&& s ? hostPath
&& s ? excludes
) stateful
&& lib.all (n: services.${n}.state == null && !(objs ? "${n}/persistentvolumeclaim")) stateless
&& lib.all (n: services.${n}.state == null) stateless
# The poller's claim is the control that a state of null is no claim's absence.
&& objs ? "swarm-ci-metrics/persistentvolumeclaim"
&& lib.all (n: lib.hasPrefix "services.hyperhive.deploy." services.${n}.option) (
lib.attrNames services
);
@ -1912,9 +1910,8 @@ let
&& host.swarm-controller.state.hostPath == "/var/lib/swarm-controller"
&& host.swarm-nats.state.hostPath == "/var/lib/nixos-containers/swarm-nats/var/lib/nats"
&& host.swarm-nats.state.mount == "/var/lib/nats"
# A DynamicUser unit's data is under `private`.
&& host.swarm-ci-metrics.state.hostPath == "/var/lib/private/swarm-ci-metrics"
&& host.swarm-stt.state.hostPath == null
&& host.swarm-ci-metrics.state == null
&& host.swarm-stt.state == null
&&
host.swarm-ci-metrics.hostUnits == [
"swarm-ci-metrics.timer"