Watch
0
0
Fork
You've already forked hyperhive
0

full-setup and the host swarmctl reach the controller as a pod, not through a host socket

This commit is contained in:
atlas 2026-11-26 09:22:29 +01:00 • committed by maia
commit bb7d616ce9

View file

@ -136,7 +136,7 @@ let
# evaluate no node.
scriptWith =
{
controllerSocket,
controller,
publicNames,
swarm,
nameOf,
@ -149,8 +149,14 @@ let
import shlex
import time
API = "http://localhost"
SOCKET = "${controllerSocket}"
# The controller is a pod: the swarm machine reaches its TLS listener the way the gateway
# does, by the Service's ClusterIP with the services root as trust and the gateway's client leaf.
CONTROLLER_URL = "https://${controller.name}:${toString controller.port}"
CONTROLLER_CURL = (
"curl --silent --cacert ${controller.root} --cert ${controller.cert} --key ${controller.key} "
"--resolve ${controller.name}:${toString controller.port}:"
"$(getent ahostsv4 ${controller.service} | awk 'NR==1 {print $1}')"
)
FORGE = "https://${publicNames.forge}"
HIVE = "${hiveName}"
TOPLEVELS = ${builtins.toJSON toplevelPaths}
@ -297,12 +303,6 @@ let
diagnose(swarm, "openbao", "${swarm.bao.machine}")
raise
def controller(method, path, body=None, check="--fail-with-body"):
data = f"-H 'Content-Type: application/json' -d {shlex.quote(json.dumps(body))}" if body else ""
return swarm.succeed(
f"curl {check} --silent --unix-socket {SOCKET} -X {method} {API}{path} {data}"
)
def forge(method, path, body=None):
data = f"-H 'Content-Type: application/json' -d {shlex.quote(json.dumps(body))}" if body else ""
return swarm.succeed(
@ -315,8 +315,8 @@ let
# archetype list comes from the builder's evaluation), so ask again.
for _ in range(60):
status, out = swarm.execute(
f"curl --silent --unix-socket {SOCKET} -o /root/create.out -w '%{{http_code}}' "
f"-X POST {API}/api/agents -H 'Content-Type: application/json' -d {shlex.quote(json.dumps(body))}"
f"{CONTROLLER_CURL} -o /root/create.out -w '%{{http_code}}' "
f"-X POST {CONTROLLER_URL}/api/agents -H 'Content-Type: application/json' -d {shlex.quote(json.dumps(body))}"
)
if out.strip().startswith("2"):
return
@ -563,7 +563,7 @@ let
with subtest("setup.md steps 8 and 9: two agents, through the endpoint the swarm UI calls"):
swarm.wait_until_succeeds(
f"curl --fail --silent --unix-socket {SOCKET} {API}/api/permissions >/dev/null", timeout=1800
f"{CONTROLLER_CURL} --fail {CONTROLLER_URL}/api/permissions >/dev/null", timeout=1800
)
created = int(swarm.succeed("date +%s"))
create_agent({"name": "spawn", "hive": HIVE, "archetype": ARCHETYPE})
@ -571,7 +571,7 @@ let
with subtest("assert 4: the agents are deployed on the hive, from the cache on heavyduty, and need a login"):
settle_hive_agents(
f"curl --fail --silent --unix-socket {SOCKET} {API}/api/agents/status "
f"{CONTROLLER_CURL} --fail {CONTROLLER_URL}/api/agents/status "
"| jq -e '[.[] | select(.hive == \"" + HIVE + "\" and .freshness == \"fresh\" and .needs_login == true)"
" | .name] | map(select(. == \"iris\" or . == \"spawn\")) | unique | length == 2'",
1200,
@ -592,7 +592,14 @@ pkgs.testers.runNixOSTest (
let
swarmCfg = config.nodes.swarm.services.hyperhive;
inherit (swarmCfg) swarm;
controllerSocket = swarmCfg.deploy.swarm-controller.socketPath;
controller = {
name = swarm.controller.tcp.domain;
inherit (swarm.controller.tcp) port;
service = swarmCfg.deploy.swarm-controller.tcp.serviceHost;
cert = swarmCfg.deploy.swarm-controller.tcp.gatewayClientCertFile;
key = swarmCfg.deploy.swarm-controller.tcp.gatewayClientKeyFile;
root = "${swarmCfg.deploy.hive-controller.tls.stateDir}/swarm-services-root.pem";
};
settingsJson =
config.nodes.swarm.systemd.services.swarm-controller.environment.SWARM_CONTROLLER_META_FLAKE;
@ -761,7 +768,7 @@ pkgs.testers.runNixOSTest (
testScript = scriptWith {
inherit
controllerSocket
controller
publicNames
swarm
nameOf
@ -773,7 +780,14 @@ pkgs.testers.runNixOSTest (
# What `nix/vm-test-typecheck.nix` checks: the same text with stand-in values.
passthru.typecheckScript = scriptWith {
controllerSocket = "/stub/socket";
controller = {
name = "controller.stub";
port = 9443;
service = "controller.stub.svc";
cert = "/stub/cert.pem";
key = "/stub/key.pem";
root = "/stub/root.pem";
};
publicNames.forge = "forge.stub";
swarm = {
bao.machine = "stub";