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 ee6b5f69f6
12 changed files with 222 additions and 157 deletions

View file

@ -174,6 +174,9 @@ It prints a generated password once — record it. Keep both flags:
it. Without it you log in fine and are then refused.
- **`--email`** — the forge won't create an account without one.
This step writes authelia's users file and calls no controller, so it needs nothing from the controller. The first verb that calls the controller is
`swarmctl forge make-admin` in step 3, after `swarmctl login`.
Fix either afterwards with `swarmctl user update mara --add-group admins
--email …`. Details: [`2-handbook/swarm/sso.md`](../2-handbook/swarm/sso.md).
@ -186,7 +189,8 @@ needs a real DNS record. → [`2-handbook/swarm/ui.md`](../2-handbook/swarm/ui.m
Signing in to the forge once through SSO creates your forge account under the
same username. Then, _on the swarm-controller's host_, log `swarmctl` in once. The host's
`swarmctl` reaches the controller through the swarm's gateway as your own SSO account, so every
verb that calls the controller needs this login:
verb that calls the controller (`forge make-admin`, `agent create`, `schedule`, the agent steps of
`setup status`) needs this login, and the controller has no socket on the host to use instead:
```bash
swarmctl login

View file

@ -66,7 +66,7 @@ swarm-level operator CLI
* `--users-file <PATH>` — Host-side path of authelia's users database — that is, the path inside the container, prefixed with the container's root.
This is the only user store: it's read before every change and written in place, and `swarm-authelia-bridge` writes the same file.
* `--swarm <URL>` — The swarm's domain, as `https://<domain>` or the bare domain. Given, the `agent`, `schedule` and `forge` verbs, and the agent checks and steps of `setup`, go through its gateway as the account `swarmctl login` logged in, instead of over the controller's socket. Falls back to `SWARMCTL_SWARM`; `login` then falls back to `SWARMCTL_LOGIN_DEFAULT_SWARM`. The swarm-controller nix module sets both to its host's own swarm, so there the verbs use the gateway and need `swarmctl login` once; an empty `SWARMCTL_SWARM` or `--swarm ""` puts them back on the controller's socket
* `--swarm <URL>` — The swarm's domain, as `https://<domain>` or the bare domain. Given, the `agent`, `schedule` and `forge` verbs, and the agent checks and steps of `setup`, go through its gateway as the account `swarmctl login` logged in, instead of over the controller's socket. Falls back to `SWARMCTL_SWARM`; `login` then falls back to `SWARMCTL_LOGIN_DEFAULT_SWARM`. The swarm-controller nix module sets both to its host's own swarm, so there the verbs use the gateway and need `swarmctl login` once. With no swarm, they use the socket that `--controller-socket` or `SWARM_CONTROLLER_SOCKET` names; the module sets neither
* `--ca-file <PATH>` — A PEM CA certificate to trust beside the system roots, for a swarm whose gateway serves a certificate from the swarm's own CA. Falls back to `SWARMCTL_CA_FILE`
@ -123,7 +123,7 @@ No approval gate guards this: the caller is root on the controller's host, or lo
The agent writes it on its first start, and only when it has no `AGENTS.md` yet: re-creating an agent never replaces an existing file. The controller refuses a file over 64 KiB.
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -145,7 +145,7 @@ Queues and returns, the same way `agent create` does — watch the swarm UI's jo
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -172,7 +172,7 @@ No approval gate guards this: the caller is root on the controller's host, or lo
* `--yes` — Confirm `destroyed`, which can't be undone
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -192,7 +192,7 @@ The swarm-level counterpart of `hivectl agent watch`, read from the swarm-contro
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -228,7 +228,7 @@ Show what the swarm sets for an agent, naming the fields it doesn't set, and the
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -252,7 +252,7 @@ Set fields for an agent. Only the flags given change; the others keep what's sto
* `--subagent-models <MODELS>` — The models it may start subagents on, comma-separated. Stored and shown; the agent doesn't apply it yet
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -270,7 +270,7 @@ Clear every field for an agent, so it goes back to its own values
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -304,7 +304,7 @@ Show the permissions the swarm grants an agent, or that it sets none
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -327,7 +327,7 @@ Replace the permissions the swarm grants an agent; the internet flag stays unles
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -345,7 +345,7 @@ Clear the agent's permissions, so the default applies again
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -378,7 +378,7 @@ Print an agent's AGENTS.md on stdout, and its revision on stderr
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -400,7 +400,7 @@ The diff names `a/AGENTS.md` and `b/AGENTS.md`, as `diff -u a/AGENTS.md b/AGENTS
* `--base <REVISION>` — The revision you made the diff against, as `get` printed it. It's the git blob id of that text, so `git hash-object` of the unedited file prints it too
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -441,7 +441,7 @@ Without `--every` it fires once. Without `--at` its first fire is now.
* `--paused` — Add it paused
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -456,7 +456,7 @@ List scheduled prompts, one row each, with their agents and next fire time
* `--agent <AGENT>` — Show only the prompts that fire in this agent
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -483,7 +483,7 @@ Only the flags given change, and the id stays. `--at` and `--every` move the fir
* `--remove-agent <AGENT>` — Agent to stop firing it in. Repeatable. Fails if the agent isn't a target, or if no agent would remain
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -501,7 +501,7 @@ Stop a scheduled prompt firing. Times that pass while it's paused aren't fired w
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -519,7 +519,7 @@ Let a paused scheduled prompt fire again, from its next time on
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -537,7 +537,7 @@ Remove a scheduled prompt from every agent it names
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -647,7 +647,7 @@ The forge creates a human's account on their first SSO login, and this fails unt
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -670,7 +670,7 @@ For scripts, use `setup status` and the individual verbs.
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.
@ -688,7 +688,7 @@ Exits 0 when every step it can see has finished, and 1 otherwise, including when
* `--controller-socket <PATH>` — swarm-controller's unix socket.
Supplied by the nix module that installs this binary, from the same `socketPath` option the daemon binds; falls back to `SWARM_CONTROLLER_SOCKET`.
Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to `SWARM_CONTROLLER_SOCKET`. The controller runs as a pod and has no socket on the host, so name the swarm instead.

View file

@ -171,8 +171,8 @@ of more than one node needs one before the controller may run there.
and the script's tools.
- **`swarmctl`.** The controller's socket lives inside the pod, so the host's
`swarmctl` reaches the controller only through the gateway: run
`swarmctl login` once, then use `--swarm <url>` or a wrapper that defaults
to it. A socket path on the host serves nothing.
`swarmctl login` once. The host's wrapper defaults `--swarm` to the host's own
swarm and sets no socket path, since a socket path on the host serves nothing.
- **Probes.** The pod binds `SWARM_CONTROLLER_HEALTH_ADDR`, with liveness on
`/healthz` and readiness on `/readyz`. Readiness needs the queue connection
and a fresh store login, so a store role that refuses the pod's token leaves

View file

@ -136,14 +136,6 @@ let
SWARM_CONTROLLER_AGENT_PKI_ROLE = deployCfg.bao.agentPkiRoleName;
};
# Where `swarmctl agent create` posts to. Unconditional: this binary is
# only installed where the daemon runs, so the socket is always the one
# right below it — and it is the same `socketPath` the daemon binds, read
# once rather than restated.
controllerSocketEnv = {
SWARM_CONTROLLER_SOCKET = deployCfg.swarm-controller.socketPath;
};
forgeCfg = config.services.hyperhive.swarm.forge;
swarmDomain = config.services.hyperhive.swarm.domain;
matrixCfg = config.services.hyperhive.swarm.matrix;
@ -159,10 +151,8 @@ let
# The swarm the host's `swarmctl` talks to: this host's own, through the
# gateway, as the operator's own SSO account (`swarmctl login`). The
# controller socket then serves the gateway alone, which always sets
# `Remote-User`. Both are defaults, so an operator's own value wins: an
# empty `SWARMCTL_SWARM` puts the socket verbs back on the socket for
# root.
# controller runs as a pod and has no socket on the host, so the gateway is
# the only way in. Both are defaults, so an operator's own value wins.
swarmDefaultEnv = lib.optionalAttrs (swarmDomain != null) {
SWARMCTL_SWARM = "https://${swarmDomain}";
SWARMCTL_LOGIN_DEFAULT_SWARM = "https://${swarmDomain}";
@ -341,7 +331,7 @@ let
wrapProgram $out/bin/swarmctl ${
lib.concatStringsSep " " (
lib.mapAttrsToList (name: value: "--set ${name} ${lib.escapeShellArg value}") (
controllerSocketEnv // swarmctlTrustEnv // deployCfg.swarm-controller.swarmctlEnvironment
swarmctlTrustEnv // deployCfg.swarm-controller.swarmctlEnvironment
)
++ lib.mapAttrsToList (
name: value: "--set-default ${name} ${lib.escapeShellArg value}"
@ -662,10 +652,8 @@ in
per-agent sockets, and the directory is `0750` owned by the
`${clientsGroup}` group. Members of that group (the gateway's
nginx, for `/api/` and `/webhook/forge/`) and root (which bypasses mode
bits) can reach the socket. The host's `swarmctl` goes through the
gateway by default, so only a root-run verb with an empty
`SWARMCTL_SWARM` opens it; every other local
user gets `EACCES` at the directory. What keeps `0666` safe is that
bits) can reach the socket. The host's `swarmctl` does not open it: it
goes through the gateway, and sets no socket path. What keeps `0666` safe is that
the directory holds exactly one socket.
Moving this path under a directory that carries anything else —
`/run/hyperhive`, which holds the host admin socket, above all —
@ -838,7 +826,7 @@ in
internal = true;
description = ''
Variables the installed `swarmctl` wrapper sets, on top of the
controller's socket path. Empty unless another module on this host
trust bundle. Empty unless another module on this host
supplies some: ./glue-controller-env.nix adds the configured authelia
where authelia runs here.
'';

View file

@ -154,13 +154,14 @@ let
or null == "https://matrix.hive.t.local";
}
{
# The host's swarmctl reaches the gateway by default and the socket only when
# the operator empties `SWARMCTL_SWARM`: `--set-default` lets that empty value
# through, `--set` would not. The socket variable is the control that the
# wrapper text was found at all.
name = "the host's swarmctl defaults to its own swarm's gateway, and an operator's own value wins";
# The host's swarmctl reaches the gateway by default and sets no controller socket: the
# controller is a pod, so the host has none. `--set-default` lets an operator's own value
# through, `--set` would not. The trust variable is the control that the wrapper text was
# found at all.
name = "the host's swarmctl defaults to its own swarm's gateway with no controller socket, and an operator's own value wins";
ok =
lib.hasInfix "--set SWARM_CONTROLLER_SOCKET " swarmctlWrapperCmd
lib.hasInfix "--set SSL_CERT_FILE " swarmctlWrapperCmd
&& !(lib.hasInfix "SWARM_CONTROLLER_SOCKET" swarmctlWrapperCmd)
&& lib.hasInfix "--set-default SWARMCTL_SWARM https://t.local" swarmctlWrapperCmd
&& lib.hasInfix "--set-default SWARMCTL_LOGIN_DEFAULT_SWARM https://t.local" swarmctlWrapperCmd
&& !(lib.hasInfix "--set SWARMCTL_SWARM" swarmctlWrapperCmd);

View file

@ -9,16 +9,16 @@
# needs a TPM). A pkcs11 store unseals itself at init, so here
# the unseal comes right after init, before the granter.
# 2 SSO account `swarmctl user add mara --group admins`.
# 8 spawn `POST /api/agents` on the controller socket, as the swarm
# 8 spawn `POST /api/agents` on the controller pod's listener, as the swarm
# UI's create form does, with the reviewer archetype's defaults.
# 9 first agent The same endpoint, for `iris`: `swarmctl agent create` has no
# archetype flag, and a custom agent's config repo would need
# inputs the VM cannot resolve offline.
# `swarmctl setup status` is read before the agents deploy: steps 1-6 done; step 9
# (the product's hard-coded `ruth`) stays undone, as no root agent exists here. Not
# scripted yet: step 3, the first SSO login to the forge (an OIDC code flow against
# authelia), and `swarmctl forge make-admin`.
# Green when `GET /api/agents/status` on the controller socket lists `iris` and
# The script reaches the controller pod's TLS listener as the gateway does (ClusterIP, services
# root, gateway client leaf). `swarmctl login` needs a browser, so the host's swarmctl stops at
# "not logged in": `setup status` leaves steps 9 and 10 unknown, `schedule list` names the login.
# Not scripted yet: step 3, the first SSO login to the forge, and `swarmctl forge make-admin`.
# Green when `GET /api/agents/status` on the controller pod's listener lists `iris` and
# `spawn` with `freshness` fresh and `needs_login` true.
#
# Offline: the test seeds the swarm's forge with `hyperhive/hyperhive` (one
@ -140,7 +140,12 @@ in
# find their binaries on the node's PATH.
test.overrideTestDerivation (old: {
env = (old.env or { }) // {
FULL_SETUP_SOCKET = deploy.swarm-controller.socketPath;
FULL_SETUP_CONTROLLER_NAME = swarm.controller.tcp.domain;
FULL_SETUP_CONTROLLER_PORT = toString swarm.controller.tcp.port;
FULL_SETUP_CONTROLLER_SERVICE = deploy.swarm-controller.tcp.serviceHost;
FULL_SETUP_CONTROLLER_CERT = deploy.swarm-controller.tcp.gatewayClientCertFile;
FULL_SETUP_CONTROLLER_KEY = deploy.swarm-controller.tcp.gatewayClientKeyFile;
FULL_SETUP_SERVICES_ROOT = "${deploy.hive-controller.tls.stateDir}/swarm-services-root.pem";
FULL_SETUP_FORGE_DOMAIN = swarm.forge.domain;
FULL_SETUP_SWARM_DOMAIN = swarm.domain;
FULL_SETUP_HIVE = hive;

View file

@ -2,8 +2,6 @@ import json
import os
import shlex
API = "http://localhost"
SOCKET = os.environ["FULL_SETUP_SOCKET"]
FORGE = "https://" + os.environ["FULL_SETUP_FORGE_DOMAIN"]
HIVE = os.environ["FULL_SETUP_HIVE"]
TOPLEVELS = json.loads(os.environ["FULL_SETUP_TOPLEVELS"])
@ -11,10 +9,19 @@ REPO = os.environ["FULL_SETUP_HYPERHIVE_REPO"]
CONTROL_NIX = os.environ["FULL_SETUP_CONTROL_NIX"]
# Where `swarmctl bao init` saves what `bao operator init` printed, for root.
INIT = "/root/.local/state/swarmctl/bao-init.json"
# The host's swarmctl defaults to the swarm's gateway, where each controller verb needs a
# `swarmctl login`, which a VM without a browser cannot do. An empty `SWARMCTL_SWARM` puts a
# verb on the controller socket.
VIA_SOCKET = "SWARMCTL_SWARM="
# The controller is a pod, so the host reaches its TLS listener the way the gateway does: the
# Service's ClusterIP, the swarm services root as trust, and the gateway's client leaf. The host's
# swarmctl goes through the gateway instead, where each controller verb needs a `swarmctl login`,
# whose browser flow a VM cannot complete.
CONTROLLER_NAME = os.environ["FULL_SETUP_CONTROLLER_NAME"]
CONTROLLER_PORT = os.environ["FULL_SETUP_CONTROLLER_PORT"]
CONTROLLER_URL = f"https://{CONTROLLER_NAME}:{CONTROLLER_PORT}"
CONTROLLER_CURL = (
f"curl --silent --cacert {os.environ['FULL_SETUP_SERVICES_ROOT']} "
f"--cert {os.environ['FULL_SETUP_CONTROLLER_CERT']} --key {os.environ['FULL_SETUP_CONTROLLER_KEY']} "
f"--resolve {CONTROLLER_NAME}:{CONTROLLER_PORT}:"
f"$(getent ahostsv4 {os.environ['FULL_SETUP_CONTROLLER_SERVICE']} | awk 'NR==1 {{print $1}}')"
)
SWARM_URL = "https://" + os.environ["FULL_SETUP_SWARM_DOMAIN"]
FORGE_AUTH = "/root/forge-auth.header"
NIX = "nix --extra-experimental-features nix-command"
@ -26,17 +33,6 @@ POLICY_UNITS_ACTIVE = (
)
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 machine.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))}"
@ -84,8 +80,8 @@ def create_agent(body):
# archetype list comes from the builder's evaluation), so ask again.
for _ in range(60):
status, out = machine.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
@ -306,7 +302,7 @@ with subtest(
"step 8: spawn, a reviewer-archetype agent, through the endpoint the swarm UI calls"
):
machine.wait_until_succeeds(
f"curl --fail --silent --unix-socket {SOCKET} {API}/api/permissions >/dev/null",
f"{CONTROLLER_CURL} --fail {CONTROLLER_URL}/api/permissions >/dev/null",
timeout=900,
)
# A custom root agent (ruth, as the UI creates her) is a follow-up, not covered yet.
@ -343,8 +339,10 @@ with subtest("internal/meta holds the flake the toplevels were built from"):
)
with subtest("swarmctl setup status reports the steps done so far"):
# Step 9 names ruth, the root agent of the real setup; this test creates none, so the report
# ends on step 9 not done and the exit status is 1.
# The host's swarmctl goes through the gateway and no login exists in the VM, so steps 1-6,
# which read the host, are reported and the two that read the controller are unknown, with
# the login named as the reason. Step 9 names ruth, the root agent of the real setup, which
# this test does not create, so the exit status is 1 either way.
reported = [
"✅ 1 secret store initialised",
"✅ 2 secret store unsealed",
@ -352,12 +350,14 @@ with subtest("swarmctl setup status reports the steps done so far"):
"✅ 4 granting units active",
"✅ 5 store unsealed after the granting units",
"✅ 6 SSO account in the admins group",
"👉 9 ruth created and up",
"✅ 10 another agent [optional]",
]
unreadable = ["❓ 9 ", "❓ 10 "]
for _ in range(60):
lines = machine.execute(f"{VIA_SOCKET} swarmctl setup status")[1].splitlines()
if all(any(line.startswith(prefix) for line in lines) for prefix in reported):
lines = machine.execute("swarmctl setup status")[1].splitlines()
if all(
any(line.startswith(prefix) for line in lines)
for prefix in reported + unreadable
):
break
machine.sleep(10)
else:
@ -365,23 +365,25 @@ with subtest("swarmctl setup status reports the steps done so far"):
"swarmctl setup status did not report the steps done so far:\n"
+ "\n".join(lines)
)
assert machine.execute(f"{VIA_SOCKET} swarmctl setup status >/dev/null")[0] == 1
for prefix in unreadable:
line = next(line for line in lines if line.startswith(prefix))
assert f"not logged in to {SWARM_URL}" in line, line
assert machine.execute("swarmctl setup status >/dev/null")[0] == 1
with subtest(
"the host's swarmctl reaches the controller through the gateway by default"
"the host's swarmctl reaches the controller through the gateway, and stops at the login"
):
# No login exists in the VM, so a verb that names the controller stops at the login, and
# says which swarm it went to. Over the socket the same verb needs none.
# No login exists in the VM, so a verb that names the controller says which swarm it went to
# and that it is not logged in.
status, out = machine.execute("swarmctl schedule list 2>&1")
assert status != 0 and f"not logged in to {SWARM_URL}" in out, (status, out)
machine.succeed(f"{VIA_SOCKET} swarmctl schedule list")
with subtest("swarmctl login discovers the swarm's SSO provider from the gateway"):
# The swarm's own CA signs the gateway's leaf. A VM has no browser, so the login runs to the
# point where it prints the authorization URL and waits for the answer, which the timeout ends.
# Reaching that URL takes the gateway's 401 challenge, its published metadata, and authelia
# accepting the pushed authorization request.
ca = "/var/lib/hive-tls/swarm-services-root.pem"
ca = os.environ["FULL_SETUP_SERVICES_ROOT"]
auth = f"https://auth.{SWARM_URL.removeprefix('https://')}"
challenge = machine.succeed(
f"curl --silent --cacert {ca} -D - -o /dev/null {SWARM_URL}/api/"
@ -408,7 +410,7 @@ with subtest("swarmctl login discovers the swarm's SSO provider from the gateway
with subtest("the agents are deployed and need a login"):
settle(
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)'

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";

View file

@ -133,25 +133,25 @@ it can rebuild.
The job graph lives in memory; hive status and wanted state live in the swarm
queue, so both survive a restart.
## Why a unix socket, not a port
## The unix socket and the TCP listener
The hive-gateway's nginx is the only intended client (`swarmctl` runs as root).
A listener that is never bound to an address cannot be
reached from off-host by mistake.
The daemon binds a unix socket inside its pod, which nothing on the host can reach.
The gateway's nginx reaches the controller through the TCP listener below, and the host's
`swarmctl` goes through the gateway as the operator's own SSO account.
The socket path is `services.hyperhive.deploy.swarm-controller.socketPath`, default
`/run/swarm-controller/controller.sock`, exported to the process as
`SWARM_CONTROLLER_SOCKET`.
## The optional TCP listener
## The TCP listener
`services.hyperhive.swarm.controller.tcp.enable` (default off) adds a TLS listener beside the
socket, for a gateway that reaches the controller over the network. The routes trust their
`services.hyperhive.swarm.controller.tcp.enable` (default on wherever the swarm has a domain)
adds a TLS listener beside the socket, and it is the only way the gateway reaches the pod. The routes trust their
transport and check no caller, so the listener finishes a handshake for one client only
(`src/tcp_tls.rs`): a certificate that chains to the swarm services root, carries `clientAuth`,
and names `gateway-client.<swarm.domain>` in a subject alternative name. No certificate, another
name, or the `serverAuth`-only swarm-services leaf is refused during the handshake, before any
HTTP. The socket stays and answers exactly as before.
HTTP. The socket answers the same routes inside the pod, and checks no caller either.
The daemon takes five variables, all or none (`SWARM_CONTROLLER_TCP_LISTEN`, `_CERT`, `_KEY`,
`_CLIENT_CA`, `_CLIENT_NAME`), which the nix module sets from the options. It re-reads the server
@ -168,9 +168,8 @@ host so blast radius is unchanged."_
What keeps that safe is that the directory is `0750`, owned by the
`swarm-controller-clients` group, and holds **one** socket. nginx is in that
group through its unit's `SupplementaryGroups`; root bypasses mode bits. The host's `swarmctl` reaches the controller
through the gateway by default (`SWARMCTL_SWARM`), so nginx is the only routine client;
root opens the socket only for a verb run with `SWARMCTL_SWARM` empty. Every other local
user gets `EACCES` at the directory. The group is not `swarm-controller`'s own, which also owns the
through the gateway (`SWARMCTL_SWARM`) and sets no socket, so nginx is the only client
the module expects. Every other local user gets `EACCES` at the directory. The group is not `swarm-controller`'s own, which also owns the
state directory. So:
> **Never point `socketPath` at a directory that carries anything else.**

View file

@ -44,7 +44,7 @@ See `swarm-authelia-bridge/README.md` for what both writers must uphold.
## Configuration
The nix deployment sets every path, each derived from an option it already
has: `swarm-controller.nix` sets the socket, and `glue-controller-env.nix` sets
has: `swarm-controller.nix` sets the swarm and the trust bundle, and `glue-controller-env.nix` sets
`SWARMCTL_AUTHELIA_BIN` and `SWARMCTL_AUTHELIA_USERS_FILE`, only where
authelia runs on the same host. It also sets
`SWARMCTL_BAO_BOOTSTRAP_TOKEN_FILE` and `SWARMCTL_BAO_BOOTSTRAP_POLICY`, only
@ -61,7 +61,7 @@ an error.
| `SWARMCTL_AUTHELIA_UNIT` | authelia's unit inside that container |
| `SWARMCTL_BAO_BOOTSTRAP_TOKEN_FILE` | where `bao grant-bootstrap` places the 24h grant token |
| `SWARMCTL_BAO_BOOTSTRAP_POLICY` | the `bao-bootstrap` policy file `bao grant-bootstrap` writes |
| `SWARM_CONTROLLER_SOCKET` | the controller's unix socket, used when no swarm is named |
| `SWARM_CONTROLLER_SOCKET` | a controller socket to use when no swarm is named; the module sets none, as the controller is a pod |
| `SWARMCTL_LOGIN_DEFAULT_SWARM` | `https://<swarm domain>` of this host's swarm, for `login` |
| `SWARMCTL_SWARM` | the swarm's domain, bare or `https://`: reach the controller there; the module defaults it to this host's swarm |
| `SWARMCTL_CA_FILE` | a PEM CA to trust beside the system roots, for `SWARMCTL_SWARM` |
@ -112,9 +112,9 @@ queued: job node 42
agent "agent2" will be deployed to hive "alpha" once the job graph runs; `swarmctl` does not wait for it
```
`POST /api/agents` on the swarm-controller, over its unix socket
(`--controller-socket`, else `SWARM_CONTROLLER_SOCKET`, which the nix
module sets from the daemon's own `socketPath`). It prints the queued
`POST /api/agents` on the swarm-controller, through the swarm's gateway
(`--swarm`, else `SWARMCTL_SWARM`, which the nix module sets to the host's own swarm;
see "Reaching the controller" below). It prints the queued
job's node id **and stops there**.
It deliberately does not wait. The endpoint queues a DAG — SSO identity,
@ -187,8 +187,8 @@ as it arrives, with no total-request timeout. The header-state stream
forge: "mara" is now a site admin
```
`POST /api/forge/users/{name}/admin` on the swarm-controller, over the same
socket as `agent create`. It never creates an account: the forge makes a
`POST /api/forge/users/{name}/admin` on the swarm-controller, through the same
gateway as `agent create`. It never creates an account: the forge makes a
person's on their first login through authelia, and until then this fails
saying so. Running it on a site admin changes nothing, and an agent's name is
refused. The response body comes from `swarm-controller-api`, imported in
@ -204,8 +204,8 @@ refused. The response body comes from `swarm-controller-api`, imported in
# swarmctl schedule rm kqzpmwab
```
The `/api/schedules` routes on the swarm-controller, over the
same socket as `agent create`; each verb waits for the stored result. What a
The `/api/schedules` routes on the swarm-controller, through the
same gateway as `agent create`; each verb waits for the stored result. What a
schedule does once stored is in
[`docs/2-handbook/swarm/schedules.md`](../docs/2-handbook/swarm/schedules.md). The bodies come
from `swarm-controller-api`, imported in `src/schedule.rs`.
@ -273,8 +273,8 @@ Read-only, and it needs no token. Where each step is read from:
A check that cannot run gives `unknown` with the reason and the rest still
print: `bao` is only on `PATH` on the host running swarm-bao, the users file is
only on the authelia host, and the controller socket only on its host (or `--swarm`; on a controller host the
default swarm needs `swarmctl login` first). The exit code is 0 when every step it can see has finished and 1
only on the authelia host, and the controller only through the gateway, which needs
`swarmctl login` first (the host's own swarm is the default, so a host that has not logged in reports `unknown (not logged in…)`). The exit code is 0 when every step it can see has finished and 1
otherwise, counting an `unknown` from a failed check; step 10, another agent,
is optional and does not count.
@ -295,11 +295,12 @@ $ swarmctl schedule list
`--swarm` (before or after the verb) names the swarm, else `SWARMCTL_SWARM`; either takes the
bare domain too. On a swarm-controller host the module's wrapper sets `SWARMCTL_SWARM` and
`SWARMCTL_LOGIN_DEFAULT_SWARM` to the host's own swarm, so the host's `swarmctl` uses the gateway
too and needs one `swarmctl login`. The gateway names the sender from the SSO session, and the
controller's socket serves nginx alone. Both are defaults, so a value you set wins. An empty
`SWARMCTL_SWARM` (or `--swarm ""`) puts the verbs back on `SWARM_CONTROLLER_SOCKET` as root. That
route sends no `Remote-User`, so the routes that name the sender answer 401. Nothing in setup needs it:
`swarmctl login` needs only authelia and your SSO account, both there by step 2.
too and needs one `swarmctl login`. The gateway names the sender from the SSO session. Both are defaults, so a value you set wins.
The controller runs as a pod and has no socket on the host, so the gateway is the only way in. `swarmctl user add`
writes authelia's users file and needs no controller, so `swarmctl login` needs only authelia and your SSO account, both there by step 2.
`--controller-socket` and `SWARM_CONTROLLER_SOCKET` still name a unix socket for a controller reached that way
(none the module sets); with neither a swarm nor a socket the verb stops and says to name the swarm.
`login` finds the swarm's SSO provider itself: the gateway's 401 at `/api/`
names a public metadata document (RFC 9728) that names authelia, so `--swarm`

View file

@ -337,26 +337,40 @@ pub(crate) fn describe_error(status: hyper::StatusCode, body: &[u8]) -> String {
/// Message for a socket that could not be dialled.
///
/// Worth spelling out because the three ways this fails need three
/// different fixes and `No such file or directory (os error 2)` names
/// none of them: the daemon is off, it binds elsewhere, or this host is
/// not the one running it at all. No group-membership case to mention
/// here — `swarmctl` already runs as root.
/// The controller runs as a pod, so the host has no socket to dial: the way in
/// is the swarm's gateway.
pub(crate) fn connect_hint(socket: &Path) -> String {
format!(
"could not connect to swarm-controller at {} — is it running on this host? \
(`systemctl status swarm-controller`). The path comes from \
`--controller-socket` or `SWARM_CONTROLLER_SOCKET`, which the \
swarm-controller nix module sets from `socketPath`",
"could not connect to a swarm-controller socket at {} — the controller runs as a pod \
and has no socket on this host; reach it through the swarm's gateway with \
`--swarm <domain>` (or `SWARMCTL_SWARM`) after `swarmctl login`",
socket.display()
)
}
#[cfg(test)]
mod tests {
use super::{check_confirmed, describe_error, parse_ident, parse_state};
use super::{check_confirmed, connect_hint, describe_error, parse_ident, parse_state};
use swarm_wire::wanted::AgentState;
/// The controller has no socket on the host, so the hint sends the operator to the
/// gateway and the login, not to a unit that is not there.
#[test]
fn the_connect_hint_names_the_gateway_and_the_login() {
let hint = connect_hint(std::path::Path::new(
"/run/swarm-controller/controller.sock",
));
assert!(
hint.contains("/run/swarm-controller/controller.sock"),
"{hint}"
);
assert!(
hint.contains("--swarm <domain>") && hint.contains("swarmctl login"),
"{hint}"
);
assert!(!hint.contains("systemctl"), "{hint}");
}
/// The accepted values are the wire enum's: each spelling it writes
/// parses back, and an unknown one names the valid ones.
#[test]

View file

@ -92,8 +92,9 @@ struct RemoteArgs {
/// socket. Falls back to `SWARMCTL_SWARM`; `login` then falls back to
/// `SWARMCTL_LOGIN_DEFAULT_SWARM`. The swarm-controller nix module sets both
/// to its host's own swarm, so there the verbs use the gateway and need
/// `swarmctl login` once; an empty `SWARMCTL_SWARM` or `--swarm ""` puts
/// them back on the controller's socket.
/// `swarmctl login` once. With no swarm, they use the socket that
/// `--controller-socket` or `SWARM_CONTROLLER_SOCKET` names; the module sets
/// neither.
#[arg(long, value_name = "URL", global = true)]
swarm: Option<String>,
/// A PEM CA certificate to trust beside the system roots, for a swarm
@ -134,12 +135,19 @@ impl RemoteArgs {
.transpose()
}
/// The swarm when one is named, the controller's socket otherwise.
/// The swarm when one is named, else the controller socket the flag or
/// `SWARM_CONTROLLER_SOCKET` names. The controller runs as a pod and has no
/// socket on the host, so a host with neither is told to name the swarm.
fn target(&self, socket: Option<PathBuf>) -> Result<Target> {
Ok(match self.swarm()? {
Some(swarm) => Target::Swarm(swarm),
None => Target::Socket(path_from(socket, "SWARM_CONTROLLER_SOCKET")?),
})
if let Some(swarm) = self.swarm()? {
return Ok(Target::Swarm(swarm));
}
let socket =
socket.or_else(|| std::env::var_os("SWARM_CONTROLLER_SOCKET").map(PathBuf::from));
socket.map(Target::Socket).context(
"no swarm is named and no controller socket is given — name the swarm with \
`--swarm <domain>` or `SWARMCTL_SWARM` and run `swarmctl login`",
)
}
}
@ -615,9 +623,10 @@ struct AgentCreateArgs {
agents_md: Option<PathBuf>,
/// swarm-controller's unix socket.
///
/// Supplied by the nix module that installs this binary, from the same
/// `socketPath` option the daemon binds; falls back to
/// Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to
/// `SWARM_CONTROLLER_SOCKET`.
/// The controller runs as a pod and has no socket on the host, so name
/// the swarm instead.
#[arg(long, value_name = "PATH")]
controller_socket: Option<PathBuf>,
}
@ -635,9 +644,10 @@ struct AgentMintForgeTokenArgs {
name: String,
/// swarm-controller's unix socket.
///
/// Supplied by the nix module that installs this binary, from the same
/// `socketPath` option the daemon binds; falls back to
/// Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to
/// `SWARM_CONTROLLER_SOCKET`.
/// The controller runs as a pod and has no socket on the host, so name
/// the swarm instead.
#[arg(long, value_name = "PATH")]
controller_socket: Option<PathBuf>,
}
@ -658,9 +668,10 @@ struct ForgeMakeAdminArgs {
name: String,
/// swarm-controller's unix socket.
///
/// Supplied by the nix module that installs this binary, from the same
/// `socketPath` option the daemon binds; falls back to
/// Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to
/// `SWARM_CONTROLLER_SOCKET`.
/// The controller runs as a pod and has no socket on the host, so name
/// the swarm instead.
#[arg(long, value_name = "PATH")]
controller_socket: Option<PathBuf>,
}
@ -765,9 +776,10 @@ struct ScheduleIdArgs {
struct ControllerSocketArg {
/// swarm-controller's unix socket.
///
/// Supplied by the nix module that installs this binary, from the same
/// `socketPath` option the daemon binds; falls back to
/// Used when `--swarm` and `SWARMCTL_SWARM` give no swarm; falls back to
/// `SWARM_CONTROLLER_SOCKET`.
/// The controller runs as a pod and has no socket on the host, so name
/// the swarm instead.
#[arg(long, value_name = "PATH")]
controller_socket: Option<PathBuf>,
}
@ -1553,6 +1565,31 @@ mod tests {
);
}
/// A host that names no swarm and gives no socket (the host of a pod-only
/// controller) is told to name the swarm, not to look for a unit.
#[test]
fn with_no_swarm_and_no_socket_the_error_names_the_swarm() {
assert!(
std::env::var_os("SWARMCTL_SWARM").is_none()
&& std::env::var_os("SWARM_CONTROLLER_SOCKET").is_none(),
"this test needs both variables unset"
);
let cli = Cli::try_parse_from(["swarmctl", "schedule", "list"]).expect("parses");
let Verb::Schedule {
command: ScheduleVerb::List(args),
} = cli.command
else {
panic!("expected `schedule list`");
};
let err = args.socket.resolve(&cli.remote).err().expect("no target");
let text = format!("{err:#}");
assert!(
text.contains("--swarm <domain>") && text.contains("swarmctl login"),
"{text}"
);
assert!(!text.contains("systemctl"), "{text}");
}
/// Root on the controller host, with no `--swarm` and no login: the verbs
/// still go over the unix socket, unchanged by the remote path.
#[test]