k8s: stt and ci-metrics start without a state gate
This commit is contained in:
parent
772435504f
commit
a793df9708
5 changed files with 296 additions and 309 deletions
|
|
@ -85,6 +85,14 @@ let
|
|||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule [ "services" "hyperhive" "deploy" "stt" "k8s" "freshState" ] ''
|
||||
The pod keeps its transcript cache in an emptyDir, so it starts on any
|
||||
node with no state to migrate. Remove this definition.
|
||||
'')
|
||||
(lib.mkRemovedOptionModule [ "services" "hyperhive" "deploy" "ci-metrics" "k8s" "freshState" ] ''
|
||||
The pod starts on an empty volume without a gate: the cursor it loses is
|
||||
one backfill pass. Remove this definition.
|
||||
'')
|
||||
(lib.mkRemovedOptionModule [ "services" "hyperhive" "swarm" "victorialogs" "port" ] ''
|
||||
VictoriaLogs listens on a unix socket in a network namespace of its own,
|
||||
and the gateway reaches it there, so it binds no host port. Remove this
|
||||
|
|
|
|||
|
|
@ -31,9 +31,8 @@ let
|
|||
controllerStateDir = "/var/lib/swarm-controller";
|
||||
|
||||
# `option` is the service's name under `services.hyperhive.deploy`. `state`
|
||||
# is null for a service with no state volume. `hostPath` is null where the
|
||||
# copy has no source: the speech-to-text cache is not moved, and the pod
|
||||
# starts with an empty one.
|
||||
# is null for a service whose pod keeps nothing worth moving: no volume, an
|
||||
# `emptyDir`, or a volume that starts empty with no gate.
|
||||
#
|
||||
# The claim is `<service>-state`, as ./render.nix and ../swarm-nats.nix name
|
||||
# it.
|
||||
|
|
@ -65,11 +64,7 @@ let
|
|||
};
|
||||
swarm-stt = {
|
||||
option = "stt";
|
||||
state = {
|
||||
mount = stateMount deployCfg.stt.unit;
|
||||
hostPath = null;
|
||||
excludes = [ ];
|
||||
};
|
||||
state = null;
|
||||
};
|
||||
swarm-review-classifier = {
|
||||
option = "review-classifier";
|
||||
|
|
@ -81,13 +76,7 @@ let
|
|||
};
|
||||
swarm-ci-metrics = {
|
||||
option = "ci-metrics";
|
||||
state = {
|
||||
mount = stateMount deployCfg.ci-metrics.unit;
|
||||
# A DynamicUser unit's state directory is under `private`, behind a
|
||||
# symlink at the path the unit names.
|
||||
hostPath = "/var/lib/private/swarm-ci-metrics";
|
||||
excludes = [ ];
|
||||
};
|
||||
state = null;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -152,9 +152,11 @@ let
|
|||
# the paths the unit names that hold one to theirs. `listener`, where a
|
||||
# service has one, is the TCP port the pod publishes on the node
|
||||
# (`hostAddress`) and the directory its init container writes the leaf to.
|
||||
# `fresh` (`freshOf`) is set on every service whose pod gets a state volume:
|
||||
# the volume's first init container, the state gate, refuses to start the pod
|
||||
# on one that holds no migrated state unless the install is fresh.
|
||||
# `fresh` (`freshOf`) is set on a service whose state is worth moving: the
|
||||
# volume's first init container, the state gate, refuses to start the pod on
|
||||
# one that holds no migrated state unless the install is fresh. A service
|
||||
# without it starts on whatever volume it gets, and one with
|
||||
# `ephemeralState` gets an `emptyDir` in place of a claim.
|
||||
# `switch` is null for a service that always runs on the host, and for one
|
||||
# with a `runtime` option names the option's value and the host unit or units
|
||||
# that run the service when it is `"host"`. `otlp` is where the pod pushes
|
||||
|
|
@ -238,7 +240,7 @@ let
|
|||
etcFiles = [ ];
|
||||
publicCredentials.stt-bao-server-ca = baoServerCaKey;
|
||||
otlp = "hive";
|
||||
fresh = freshOf "stt" deployCfg.stt;
|
||||
ephemeralState = true;
|
||||
switch = {
|
||||
inherit (deployCfg.stt) runtime;
|
||||
hostUnit = "container@swarm-stt.service";
|
||||
|
|
@ -279,7 +281,6 @@ let
|
|||
etcFiles = [ ];
|
||||
publicCredentials."bao-ca.pem" = baoServerCaKey;
|
||||
otlp = "own";
|
||||
fresh = freshOf "ci-metrics" deployCfg.ci-metrics;
|
||||
# The timer and the service both: the prune unit holds back either, and a
|
||||
# service started by hand cannot run beside the CronJob.
|
||||
switch = {
|
||||
|
|
@ -445,6 +446,7 @@ let
|
|||
|
||||
runtimeDir = if sc ? RuntimeDirectory then "/run/${sc.RuntimeDirectory}" else null;
|
||||
stateDir = if sc ? StateDirectory then "/var/lib/${sc.StateDirectory}" else null;
|
||||
ephemeral = svc.ephemeralState or false;
|
||||
|
||||
# PATH holds only NixOS's default tools (checked below), which the image
|
||||
# does not carry. `%d` is systemd's specifier for the credential
|
||||
|
|
@ -622,10 +624,14 @@ let
|
|||
name = "runtime";
|
||||
emptyDir = { };
|
||||
}
|
||||
++ lib.optional (stateDir != null) {
|
||||
name = "state";
|
||||
persistentVolumeClaim.claimName = "${name}-state";
|
||||
}
|
||||
++ lib.optional (stateDir != null) (
|
||||
{
|
||||
name = "state";
|
||||
}
|
||||
// (
|
||||
if ephemeral then { emptyDir = { }; } else { persistentVolumeClaim.claimName = "${name}-state"; }
|
||||
)
|
||||
)
|
||||
++ lib.optional (svc.etcFiles != [ ]) {
|
||||
name = "etc";
|
||||
configMap.name = "${name}-etc";
|
||||
|
|
@ -772,18 +778,22 @@ let
|
|||
package = leafImagePackage;
|
||||
bin = leafIssueBin;
|
||||
};
|
||||
# The volume that holds the service's state, and where it is mounted. A
|
||||
# pod that makes its own volume names it in `state`.
|
||||
# The volume the state gate checks, and where it is mounted: that of a
|
||||
# service with a `fresh` option, none for the rest. A pod that makes its
|
||||
# own volume names it in `state`.
|
||||
stateVolume =
|
||||
extra.state or (
|
||||
if stateDir != null then
|
||||
{
|
||||
volume = "state";
|
||||
path = stateDir;
|
||||
}
|
||||
else
|
||||
null
|
||||
);
|
||||
if !(svc ? fresh) then
|
||||
null
|
||||
else
|
||||
extra.state or (
|
||||
if stateDir != null then
|
||||
{
|
||||
volume = "state";
|
||||
path = stateDir;
|
||||
}
|
||||
else
|
||||
null
|
||||
);
|
||||
|
||||
stateGate = lib.optionalAttrs (stateVolume != null) {
|
||||
name = "state-gate";
|
||||
|
|
@ -974,7 +984,7 @@ let
|
|||
automountServiceAccountToken = false;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (stateDir != null) {
|
||||
// lib.optionalAttrs (stateDir != null && !ephemeral) {
|
||||
"${name}/persistentvolumeclaim" = {
|
||||
apiVersion = "v1";
|
||||
kind = "PersistentVolumeClaim";
|
||||
|
|
@ -1000,8 +1010,6 @@ let
|
|||
fail name "the unit names no OTLP endpoint of its own, which the pod would push to"
|
||||
else if svc.healthEnv != null && unitEnv ? ${svc.healthEnv} then
|
||||
fail name "the unit already sets ${svc.healthEnv}"
|
||||
else if stateVolume != null && !(svc ? fresh) then
|
||||
fail name "the pod has a state volume and the service names no `fresh` option for its state gate"
|
||||
else if lib.head execWords != entrypoint then
|
||||
fail name "ExecStart is not ${entrypoint} with plain arguments"
|
||||
else if lib.any (w: lib.hasInfix "\"" w) execWords then
|
||||
|
|
|
|||
|
|
@ -211,17 +211,14 @@ in
|
|||
service and timer return, so one poller runs at any time. Its cursor is
|
||||
in the service's state directory on the host, and in a volume of the
|
||||
cluster in a pod; neither moves with the poller, so the first pass after
|
||||
a switch pushes every run again, as the same points. The pod does not
|
||||
start on its empty volume until `swarmctl migrate` marks it or
|
||||
{option}`services.hyperhive.deploy.ci-metrics.k8s.freshState` is set.
|
||||
a switch pushes every run again, as the same points. The pod starts on
|
||||
its empty volume with no gate.
|
||||
|
||||
The poller keeps pushing to the swarm collector's route of its own,
|
||||
not to the hive collector the cluster's other pods push to.
|
||||
'';
|
||||
};
|
||||
|
||||
k8s.freshState = import ./lib/fresh-state-option.nix { inherit lib; } "ci-metrics";
|
||||
|
||||
unit = lib.mkOption {
|
||||
type = lib.types.raw;
|
||||
readOnly = true;
|
||||
|
|
|
|||
|
|
@ -358,18 +358,12 @@ in
|
|||
in its group, and the cache is each instance's own, so a switch moves
|
||||
the service: the container goes and its objects are applied, or the
|
||||
objects are deleted and the container returns. The transcript cache is
|
||||
in the container's state directory on the host, and in a volume of the
|
||||
cluster in a pod; neither moves with the service, so a transcript is
|
||||
made again after a switch. The pod does not start on its empty volume
|
||||
until `swarmctl migrate` marks it or
|
||||
{option}`services.hyperhive.deploy.stt.k8s.freshState` is set.
|
||||
in the container's state directory on the host, and in an `emptyDir` of the
|
||||
pod; neither moves with the service, so a transcript is
|
||||
made again after a switch.
|
||||
'';
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.stt.k8s.freshState = import ./lib/fresh-state-option.nix {
|
||||
inherit lib;
|
||||
} "stt";
|
||||
|
||||
options.services.hyperhive.deploy.stt.unit = lib.mkOption {
|
||||
type = lib.types.raw;
|
||||
readOnly = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue