run the metrics store and its auth responders as pods
This commit is contained in:
parent
1606f1e9bb
commit
681426b53b
1 changed files with 1308 additions and 1031 deletions
|
|
@ -203,7 +203,6 @@ let
|
|||
"swarm-ci-runner"
|
||||
"swarm-grafana"
|
||||
"swarm-otel"
|
||||
"swarm-victoriametrics"
|
||||
];
|
||||
|
||||
# A container's start limit, in seconds.
|
||||
|
|
@ -248,7 +247,6 @@ let
|
|||
"forgejo-secrets.service"
|
||||
"swarm-bao-token.service"
|
||||
"swarm-bridge-dns.service"
|
||||
"victoriametrics-state-migrate.service"
|
||||
];
|
||||
suffixes = [
|
||||
"-ca-bundle.service"
|
||||
|
|
@ -263,7 +261,6 @@ let
|
|||
"gitea-runner-swarm.service"
|
||||
"grafana.service"
|
||||
"opentelemetry-collector.service"
|
||||
"victoriametrics.service"
|
||||
];
|
||||
}
|
||||
];
|
||||
|
|
@ -310,22 +307,6 @@ let
|
|||
[ ]
|
||||
) hyperhiveContainers;
|
||||
|
||||
# The metrics store on a build older than its socket needs. Only its
|
||||
# `assertions` are read, and the package is a stub carrying a version.
|
||||
oldMetricsStore = hive {
|
||||
deploy.victoriametrics.enable = true;
|
||||
deploy.victoriametrics.package = pkgs.emptyDirectory // {
|
||||
version = "1.152.0";
|
||||
};
|
||||
};
|
||||
# Failing assertions first, then their messages: a message is only
|
||||
# well-defined when its assertion fails (nixpkgs' fileSystems one throws
|
||||
# otherwise).
|
||||
failedMetricsStoreVersion =
|
||||
host:
|
||||
lib.filter (lib.hasInfix "services.hyperhive.deploy.victoriametrics.package must be") (
|
||||
map (a: a.message) (lib.filter (a: !a.assertion) host.assertions)
|
||||
);
|
||||
cases = [
|
||||
{
|
||||
# `lib.all` over an empty set holds vacuously, so the roster is counted
|
||||
|
|
@ -769,7 +750,6 @@ let
|
|||
"swarm-authelia"
|
||||
"swarm-bao"
|
||||
"swarm-grafana"
|
||||
"swarm-victoriametrics"
|
||||
"swarm-otel"
|
||||
"hive-matrix"
|
||||
"hive-forge"
|
||||
|
|
@ -817,7 +797,7 @@ let
|
|||
# that lost a container can't pass by comparing fewer of them.
|
||||
name = "every service container restates its host-side privateNetwork";
|
||||
ok =
|
||||
lib.length (lib.attrNames serviceContainers) == 10
|
||||
lib.length (lib.attrNames serviceContainers) == 9
|
||||
&& lib.all (
|
||||
c: c.privateNetwork == (c.config.services.hyperhive.swarmContainer.privateNetwork or null)
|
||||
) (lib.attrValues serviceContainers);
|
||||
|
|
@ -846,46 +826,6 @@ let
|
|||
in
|
||||
c.networking.firewall.enable && c.networking.resolvconf.enable;
|
||||
}
|
||||
{
|
||||
# No interface but loopback, so the socket is the store's only listener
|
||||
# the host can reach. Every location that forwards to the store goes
|
||||
# through it; the internal auth subrequests are the only other upstreams.
|
||||
# The read, push and scrape locations are named so an empty filter
|
||||
# can't pass.
|
||||
name = "the metrics store runs on a netns of its own and the gateway reaches it over its socket";
|
||||
ok =
|
||||
let
|
||||
host = serviceContainersWithCi;
|
||||
c = host.containers.swarm-victoriametrics;
|
||||
dir = "/run/swarm-victoriametrics";
|
||||
sock = "${dir}/victoriametrics.sock";
|
||||
viaSock = path: "http://unix:${sock}:${path}";
|
||||
locs =
|
||||
host.services.nginx.virtualHosts.${host.services.hyperhive.swarm.victoriametrics.domain}.locations;
|
||||
toStore = map (l: l.proxyPass) (
|
||||
lib.filter (l: l.proxyPass != null && !(lib.hasInfix "internal;" l.extraConfig)) (
|
||||
lib.attrValues locs
|
||||
)
|
||||
);
|
||||
unit = c.config.systemd.services.victoriametrics;
|
||||
nginxGid = host.ids.gids.nginx;
|
||||
in
|
||||
c.privateNetwork
|
||||
&& c.hostBridge == null
|
||||
&& c.hostAddress == null
|
||||
&& c.config.services.victoriametrics.listenAddress == "unix:${sock}"
|
||||
&& locs."= /api/v1/query".proxyPass == viaSock "/api/v1/query"
|
||||
&& locs."= /opentelemetry/api/v1/push".proxyPass == viaSock "/opentelemetry/api/v1/push"
|
||||
&& locs."= /metrics".proxyPass == viaSock "/metrics"
|
||||
&& lib.all (lib.hasPrefix (viaSock "")) toStore
|
||||
&& c.bindMounts.${dir}.hostPath == dir
|
||||
&& builtins.elem "d ${dir} 0770 root ${toString nginxGid} - -" host.systemd.tmpfiles.rules
|
||||
&& c.config.users.groups.gateway-nginx.gid == nginxGid
|
||||
&& unit.serviceConfig.Group == "gateway-nginx"
|
||||
&& !unit.serviceConfig.DynamicUser
|
||||
&& unit.serviceConfig.UMask == "0007"
|
||||
&& lib.hasInfix "--unix-socket ${sock}" unit.postStart;
|
||||
}
|
||||
{
|
||||
# On the bridge by DHCP, like the CI runner, and its socket the only
|
||||
# listener the gateway dials. `address` unset is what keeps tuwunel off
|
||||
|
|
@ -1406,38 +1346,9 @@ let
|
|||
&& !verdict (lib.replaceStrings [ "%header{x-swarm-otel-route}" ] [ "" ] script)
|
||||
&& !verdict (lib.replaceStrings [ ''[ "$seen" = "$route" ] && '' ] [ "" ] script);
|
||||
}
|
||||
{
|
||||
# The DynamicUser layout keeps the history under /var/lib/private; the
|
||||
# static user's StateDirectory is the plain path. The move runs as its
|
||||
# own unit ahead of the store.
|
||||
name = "the metrics store's history moves from the DynamicUser path before the store starts";
|
||||
ok =
|
||||
let
|
||||
cfg = serviceContainers.swarm-victoriametrics.config;
|
||||
m = cfg.systemd.services.victoriametrics-state-migrate;
|
||||
in
|
||||
cfg.services.victoriametrics.stateDir == "victoriametrics"
|
||||
&& builtins.elem "victoriametrics.service" m.before
|
||||
&& builtins.elem "victoriametrics.service" m.requiredBy
|
||||
&& lib.hasInfix "old=/var/lib/private/victoriametrics" m.script
|
||||
&& lib.hasInfix "new=/var/lib/victoriametrics" m.script
|
||||
&& lib.hasInfix ''mv "$old" "$new"'' m.script
|
||||
&& lib.hasInfix ''chown -R victoriametrics:gateway-nginx "$new"'' m.script;
|
||||
}
|
||||
{
|
||||
# The control is the default package on the all-services host.
|
||||
name = "a metrics store package older than 1.153.0 fails evaluation";
|
||||
ok =
|
||||
let
|
||||
old = failedMetricsStoreVersion oldMetricsStore;
|
||||
in
|
||||
lib.length old == 1
|
||||
&& lib.hasInfix "1.152.0" (lib.head old)
|
||||
&& failedMetricsStoreVersion serviceContainersWithCi == [ ];
|
||||
}
|
||||
{
|
||||
name = "a service container that sets no stateVersion of its own is on 26.05";
|
||||
ok = serviceContainers.swarm-victoriametrics.config.system.stateVersion == "26.05";
|
||||
ok = serviceContainers.swarm-grafana.config.system.stateVersion == "26.05";
|
||||
}
|
||||
{
|
||||
name = "a service container that pins its own stateVersion keeps it";
|
||||
|
|
|
|||
Loading…
Reference in a new issue