Watch
0
0
Fork
You've already forked hyperhive
0

forge: its own netns, HTTP on a unix socket, git over HTTPS only

The hive-forge container leaves the host netns and listens on no TCP port: Forgejo serves HTTP on a unix socket the gateway proxies to, and the built-in SSH server is off. The httpPort, sshPort and openFirewall options are removed with a message each.
This commit is contained in:
maia 2026-11-22 19:44:19 +01:00 • committed by mara
commit fc70f538ac

View file

@ -2414,9 +2414,9 @@ let
# Each old spelling lands on the new path, with its own rename warning,
# and its value reaches the unit or vhost that reads it. Ports are chosen
# so two of them collide on purpose: the bao collector's telemetry
# port equals the NATS monitor port and the forge forwarder's. Each of the
# two colocation assertions must read the moved options to see it. (The log
# store has a netns of its own, so its forwarder's port collides with none.)
# port equals the NATS monitor port. The colocation assertion must read
# the moved options to see it. (The log store and the forge have a netns
# of their own, so their forwarders' ports collide with none.)
name = "the per-service settings moved to deploy.* still apply from their old paths, with a rename warning each";
ok =
let
@ -2436,7 +2436,6 @@ let
nats.metricsPort = 17777;
nats.otel.telemetryPort = 8897;
otel.telemetryPort = 18889;
forge.httpPort = 13000;
matrix.allowEncryption = true;
controller.links = [
{
@ -2472,7 +2471,6 @@ let
&& d.nats.metricsPort == 17777
&& d.nats.otel.telemetryPort == 8897
&& d.swarm-otel.telemetryPort == 18889
&& d.forgejo.httpPort == 13000
&& d.matrix.allowEncryption
&& d.builder.nixpkgsFlake == "path:/legacy/nixpkgs"
&& lib.any (l: l.label == "Legacy" && l.url == "https://legacy.example/") d.swarm-controller.links
@ -2492,7 +2490,6 @@ let
old.containers.swarm-builder.config.systemd.services.swarm-builder.environment.SWARM_BUILDER_NIXPKGS_FLAKE
== "path:/legacy/nixpkgs"
&& (locs sw.nats.domain)."= /metrics".proxyPass == "http://127.0.0.1:17777/metrics"
&& (locs sw.forge.domain)."/".proxyPass == "http://127.0.0.1:13000/"
&& old.containers.hive-matrix.config.services.matrix-tuwunel.settings.global.allow_encryption
&& lib.all warned [
"swarm.controller.queue.natsUrl"
@ -2502,7 +2499,6 @@ let
"swarm.nats.metricsPort"
"swarm.nats.otel.telemetryPort"
"swarm.otel.telemetryPort"
"swarm.forge.httpPort"
"swarm.matrix.allowEncryption"
"c0re.nixpkgsFlake"
"swarm.controller.links"
@ -2511,9 +2507,7 @@ let
]
&& !(lib.any (w: lib.hasInfix "swarm.controller.queue" w) allLocal.warnings)
&& refused old "deploy.nats.otel.telemetryPort"
&& refused old "The forge's journal forwarder's telemetry port"
&& !(refused allLocal "deploy.nats.otel.telemetryPort")
&& !(refused allLocal "The forge's journal forwarder's telemetry port");
&& !(refused allLocal "deploy.nats.otel.telemetryPort");
}
{
# The default render of the moved options, pinned so moving them changes
@ -2537,7 +2531,7 @@ let
&&
(locs h.swarm.victorialogs.domain)."= /metrics".proxyPass
== "http://unix:/run/swarm-victorialogs/victorialogs.sock:/metrics"
&& (locs h.swarm.forge.domain)."/".proxyPass == "http://127.0.0.1:3000/"
&& (locs h.swarm.forge.domain)."/".proxyPass == "http://unix:/run/hive-forge/forgejo.sock:/"
&& !allLocal.containers.hive-matrix.config.services.matrix-tuwunel.settings.global.allow_encryption
&& env.SWARM_CONTROLLER_MATRIX_ADMIN_SYNC_IGNORE_USERS == ""
&& lib.any (l: l.label == "Forge" && l.url == "https://${h.swarm.forge.domain}/") (
@ -2548,6 +2542,55 @@ let
(otelSettings allLocal).receivers.prometheus.config.scrape_configs
)).static_configs == [ { targets = [ "127.0.0.1:8889" ]; } ];
}
{
# The forge has a netns of its own and no TCP port: Forgejo serves HTTP on
# a unix socket in a directory bind-mounted from the host, the gateway's
# `/` and `= /metrics` locations proxy to that socket, and git has no SSH
# server. The host-side directory is the gateway group's and no one
# else's, which is what makes the socket's `0666` safe.
name = "the forge runs in its own netns and serves HTTP on a unix socket, with no SSH";
ok =
let
h = allLocal.services.hyperhive;
c = allLocal.containers.hive-forge;
srv = c.config.services.forgejo.settings.server;
locs = allLocal.services.nginx.virtualHosts.${h.swarm.forge.domain}.locations;
socket = "/run/hive-forge/forgejo.sock";
nginxGid = toString allLocal.ids.gids.nginx;
in
c.privateNetwork
&& c.hostBridge == h.network.bridgeName
&& c.config.services.hyperhive.swarmContainer.privateNetwork
&& c.bindMounts."/run/hive-forge".hostPath == "/run/hive-forge"
&& !c.bindMounts."/run/hive-forge".isReadOnly
&& lib.elem "d /run/hive-forge 0770 root ${nginxGid} - -" allLocal.systemd.tmpfiles.rules
&& srv.PROTOCOL == "http+unix"
&& srv.HTTP_ADDR == socket
&& !srv.START_SSH_SERVER
&& srv.DISABLE_SSH
&& locs."/".proxyPass == "http://unix:${socket}:/"
&& locs."= /metrics".proxyPass == "http://unix:${socket}:/metrics"
&& c.config.users.groups.gateway-nginx.gid == allLocal.ids.gids.nginx
&& lib.elem "gateway-nginx" c.config.users.users.forgejo.extraGroups
&& lib.elem "/run/hive-forge" c.config.systemd.services.forgejo.serviceConfig.ReadWritePaths
&& !(lib.elem 3000 allLocal.networking.firewall.allowedTCPPorts)
&& !(lib.elem 2222 allLocal.networking.firewall.allowedTCPPorts);
}
{
# The options that named the forge's host ports are gone. A configuration
# that still sets one fails at evaluation, and the message says why.
name = "setting a removed forge port option is refused with the reason";
ok =
let
refused = m: part: lib.any (a: !a.assertion && lib.hasInfix part a.message) m.assertions;
in
refused (hiveWithController { swarm.forge.sshPort = 2222; }) "runs no SSH server"
&& refused (hiveWithController { swarm.forge.httpPort = 3000; }) "unix socket"
&& refused (hiveWithController { deploy.forgejo.httpPort = 3000; }) "unix socket"
&& refused (hiveWithController { deploy.forgejo.openFirewall = true; }) "no host port to open"
&& !(refused allLocal "runs no SSH server")
&& !(refused allLocal "unix socket");
}
{
# Each old spelling lands on the new path, with its own rename warning;
# the squid.conf it renders equals the one the new spelling renders, and