swarm: wire the agents' queue coordinates and credential through the modules
The host end: `HIVE_C0RE_AGENT_QUEUE_CREDENTIAL_DIR` tells the daemon where the reader unit put the files, and a new `deploy.hive-controller.queue.agentNatsUrl` says where the queue is as an agent *container* reaches it. That address defaults to the bridge one and never to loopback — `statusPublish.natsUrl` beside it is loopback and correct, because hive-c0re shares the host netns and an agent does not. Paired with the swarm's token endpoint, gated together, and forwarded by `hive_c0re::meta` as both an env var and an agent option: the harness reads the variable at runtime, its unit is built from the option. The agent end: `nix/agent-modules/queue.nix` declares that option pair and, when set, has the harness unit inherit the two credentials by name. Bare-id `LoadCredential=` is the terse form documented for inheriting what the service manager received, and is non-fatal when the credential is absent — which a hive whose publisher has not run yet needs. No `HIVE_AGENT_OIDC_CA_FILE`: the meta flake already embeds the hive CA and the swarm root into each container's trust store at build time, and reqwest's rustls backend verifies against it. Refs #3805
This commit is contained in:
parent
353cdd9264
commit
86652f051a
7 changed files with 290 additions and 0 deletions
|
|
@ -275,6 +275,33 @@ in
|
|||
# ./default.nix. The daemon reads a path, never a value.
|
||||
HIVE_C0RE_OIDC_CLIENT_SECRET_FILE = "%d/swarm-status-client.secret";
|
||||
}
|
||||
// {
|
||||
# Where ../glue-queue-agent-credential.nix lands the AGENTS' queue
|
||||
# credential. Read by `hive_c0re::lifecycle::host_config`, which stats the
|
||||
# two files and forwards them into each container as systemd credentials.
|
||||
# Never read for its contents here: the secret is `0600` root-owned and
|
||||
# this daemon is `hive-core`, which is exactly why the transport is a
|
||||
# credential rather than a bind mount.
|
||||
HIVE_C0RE_AGENT_QUEUE_CREDENTIAL_DIR = toString config.services.hyperhive.deploy.hive-controller.queue.agentCredentialDir;
|
||||
}
|
||||
//
|
||||
# The agents' half of the same queue, forwarded by `hive_c0re::meta` into
|
||||
# every container. A pair, gated together, because an agent that got one of
|
||||
# them would report a half-configured queue instead of none.
|
||||
#
|
||||
# ⚠️ The url is the bridge address, NOT the loopback one beside it in
|
||||
# `HIVE_C0RE_NATS_URL` above. Both are correct for their reader: this daemon
|
||||
# shares the host netns, an agent does not, and inside a container
|
||||
# `127.0.0.1` is the agent itself.
|
||||
lib.optionalAttrs
|
||||
(
|
||||
config.services.hyperhive.deploy.hive-controller.queue.agentNatsUrl != null
|
||||
&& config.services.hyperhive.swarm.statusPublish.tokenEndpoint != null
|
||||
)
|
||||
{
|
||||
HIVE_AGENT_NATS_URL = config.services.hyperhive.deploy.hive-controller.queue.agentNatsUrl;
|
||||
HIVE_AGENT_OIDC_TOKEN_ENDPOINT = config.services.hyperhive.swarm.statusPublish.tokenEndpoint;
|
||||
}
|
||||
//
|
||||
# Where the swarm's secret store is, and the identity this hive presents to
|
||||
# it (hive-c0re::workers::credential). `swarm_secret_client` reads these
|
||||
|
|
|
|||
|
|
@ -587,4 +587,35 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# The same queue, reached from one layer further in. An agent container has
|
||||
# its own network namespace, so it needs an address of its own rather than
|
||||
# the one beside it in `statusPublish.natsUrl` — sharing that option would
|
||||
# hand every agent a loopback address that resolves to the agent.
|
||||
#
|
||||
# Only the address lives here. The credential does not: it is published per
|
||||
# hive and read out of the store by ./glue-queue-agent-credential.nix, which
|
||||
# owns `queue.agentCredentialDir` in the same namespace.
|
||||
options.services.hyperhive.deploy.hive-controller.queue.agentNatsUrl = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default =
|
||||
if queueLocal then "nats://${cfg.network.bridgeIp}:${toString swarmCfg.nats.port}" else null;
|
||||
defaultText = lib.literalExpression ''"nats://''${network.bridgeIp}:''${swarm.nats.port}" when this host runs the queue and the IdP, else null'';
|
||||
example = "nats://10.100.0.1:4222";
|
||||
description = ''
|
||||
Where the swarm queue listens, as an agent *container* on this host
|
||||
reaches it.
|
||||
|
||||
Defaults to the bridge address when this host runs the queue, because
|
||||
that is the only address it is reachable at from a container:
|
||||
{option}`services.hyperhive.swarm.nats.port` is opened on the bridge
|
||||
interface alone. ⚠️ Never a loopback address — inside an agent's network
|
||||
namespace `127.0.0.1` is the agent, not this host.
|
||||
|
||||
Null means this hive's agents have no queue. Together with
|
||||
{option}`services.hyperhive.swarm.statusPublish.tokenEndpoint` it is
|
||||
what decides whether the harness is handed queue coordinates at all; a
|
||||
hive whose queue is elsewhere names the address its containers route to.
|
||||
'';
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue