k8s: refuse a workload name that starts with the legacy hive- prefix
The forge and matrix services carry a hive- prefix from their per-hive container days. Neither runs in the cluster on k8s/v1 yet, so nothing is renamed here: the renderer now fails the evaluation of any in-cluster workload that carries a name starting with hive- (an object key, an object's name, or its app label), so the move cannot bring the prefix along. A module-eval case pins the lookup on literals and holds the rendered hosts to it.
This commit is contained in:
parent
a4e44645a0
commit
02e0aab3b6
1 changed files with 46 additions and 2 deletions
|
|
@ -320,6 +320,23 @@ let
|
|||
|
||||
fail = name: msg: throw "services.hyperhive.k8s: ${name}: ${msg}";
|
||||
|
||||
# The names an object set carries that start with `hive-`, the prefix the
|
||||
# forge and matrix services had as per-hive containers. Their workloads, and
|
||||
# so their pods, must not bring it into the cluster. Read from the object
|
||||
# keys, each object's name and its app label.
|
||||
legacyPrefixed =
|
||||
objs:
|
||||
lib.filter (lib.hasPrefix "hive-") (
|
||||
lib.attrNames objs
|
||||
++ lib.concatMap (
|
||||
o:
|
||||
[ o.metadata.name ]
|
||||
++ lib.optional (
|
||||
o.metadata.labels."app.kubernetes.io/name" or null != null
|
||||
) o.metadata.labels."app.kubernetes.io/name"
|
||||
) (lib.attrValues objs)
|
||||
);
|
||||
|
||||
# A unit's `ExecStart` as argv, split as systemd splits it: on spaces, with
|
||||
# single quotes grouping a word (`lib.escapeShellArg` writes them) and `$$`
|
||||
# standing for `$`. A pod's arguments are not expanded by a shell.
|
||||
|
|
@ -1125,7 +1142,9 @@ let
|
|||
};
|
||||
};
|
||||
in
|
||||
if !(lib.all (p: lib.elem (lib.getName p) nixosDefaultPath) unit.path) then
|
||||
if legacyPrefixed objects != [ ] then
|
||||
fail name "names ${lib.concatStringsSep ", " (lib.unique (legacyPrefixed objects))}, which start with the legacy `hive-` prefix"
|
||||
else if !(lib.all (p: lib.elem (lib.getName p) nixosDefaultPath) unit.path) then
|
||||
fail name "the unit puts packages on PATH, which the image does not carry"
|
||||
else if svc.otlp == "own" && !(lib.any (n: unitEnv ? ${n}) otlpEndpointVars) then
|
||||
fail name "the unit names no OTLP endpoint of its own, which the pod would push to"
|
||||
|
|
@ -1187,5 +1206,5 @@ in
|
|||
lib.filterAttrs (_: svc: svc.enable && svc ? hostUsers && !svc.hostUsers) services
|
||||
);
|
||||
services = lib.mapAttrs (_: w: { inherit (w) objects; }) enabled;
|
||||
inherit caConfigMap caSources;
|
||||
inherit caConfigMap caSources legacyPrefixed;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue