hand agents the queue address at container start
HIVE_AGENT_NATS_URL now reaches each container in its hive facts, from the host's deploy.hive-controller.queue.agentNatsUrl, instead of being rendered into the meta flake. The agent option services.hyperhive.agent.queue.natsUrl is removed; the harness unit imports the queue credential whenever the token endpoint is set. On deploy every agent rebuilds once (the rendered flake loses the address), and the harness reads the address from the facts file hive-priv writes before each start. Refs #4857
This commit is contained in:
parent
ba97c64dda
commit
f3c0a87c0f
13 changed files with 54 additions and 31 deletions
|
|
@ -36,7 +36,7 @@ let
|
|||
'';
|
||||
queueRemoved = ''
|
||||
The harness reads the queue's address at runtime from HIVE_AGENT_NATS_URL,
|
||||
which the hive forwards into every container, and authenticates with the
|
||||
in /etc/hyperhive-hive-facts, and authenticates with the
|
||||
agent's own secret from the swarm secret store, so no agent build sets a
|
||||
queue option. Remove the setting.
|
||||
'';
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
# ./default.nix runs this container's own when absent);
|
||||
# - `HYPERHIVE_OTEL_EXTRA_RESOURCE_ATTRIBUTES`, appended to
|
||||
# `OTEL_RESOURCE_ATTRIBUTES` by ./otel.nix (no extra labels when absent).
|
||||
# - `HIVE_AGENT_NATS_URL`, where the harness reaches the swarm queue (it fails
|
||||
# at boot when absent).
|
||||
#
|
||||
# Any of them may be absent: a hive-c0re older than the agent's build writes
|
||||
# fewer. Two readers hand the lines on:
|
||||
|
|
@ -43,6 +45,7 @@ let
|
|||
HYPERHIVE_HIVE_NAME) hive=$value ;;
|
||||
HYPERHIVE_HIVE_DOMAIN | HIVE_DASHBOARD_PORT) ;;
|
||||
HYPERHIVE_CLAUDE_CODE_PATH | HYPERHIVE_OTEL_EXTRA_RESOURCE_ATTRIBUTES) ;;
|
||||
HIVE_AGENT_NATS_URL) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
printf '%s=%s\n' "$key" "$value"
|
||||
|
|
|
|||
|
|
@ -222,8 +222,8 @@ in
|
|||
HIVE_C0RE_OIDC_CLIENT_ID = "hive-${config.services.hyperhive.hiveName}";
|
||||
}
|
||||
//
|
||||
# The agents' half of the same queue, forwarded by `hive_c0re::meta` into
|
||||
# every container.
|
||||
# Where the agents reach the queue: the address goes into every container in
|
||||
# its hive facts (`hive_c0re::lifecycle::hive_facts`).
|
||||
#
|
||||
# ⚠️ By name, like `HIVE_C0RE_NATS_URL` above, and never a loopback
|
||||
# address: inside a container `127.0.0.1` is the agent itself.
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ check() {
|
|||
for sh in $SHELLS; do
|
||||
# Only what the snippet exported reaches the child's environment. No PATH:
|
||||
# the snippet must not need one.
|
||||
got=$(env -i "$sh" -c ". '$dir/profile'; exec '$envbin'" | grep -E '^(HYPERHIVE_|HIVE_DASHBOARD_PORT=|CLAUDE_|LD_PRELOAD=|__hyperhive)' | sort)
|
||||
got=$(env -i "$sh" -c ". '$dir/profile'; exec '$envbin'" | grep -E '^(HYPERHIVE_|HIVE_DASHBOARD_PORT=|HIVE_AGENT_NATS_URL=|CLAUDE_|LD_PRELOAD=|__hyperhive)' | sort)
|
||||
if [ "$got" != "$(printf '%s\n' "$want" | sort)" ]; then
|
||||
fail "$sh: a child of the sourcing shell saw:"$'\n'"$got"
|
||||
fi
|
||||
|
|
@ -61,10 +61,11 @@ check "a last line without a newline is kept" "HYPERHIVE_HIVE_DOMAIN=pr1ma.examp
|
|||
HYPERHIVE_HIVE_NAME=pr1ma
|
||||
CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX=pr1ma-a1"
|
||||
|
||||
printf 'HIVE_DASHBOARD_PORT=7123\nHYPERHIVE_CLAUDE_CODE_PATH=/nix/store/0abc-claude-code\nHYPERHIVE_OTEL_EXTRA_RESOURCE_ATTRIBUTES=team=a,env=prod\n' >"$facts"
|
||||
printf 'HIVE_DASHBOARD_PORT=7123\nHYPERHIVE_CLAUDE_CODE_PATH=/nix/store/0abc-claude-code\nHYPERHIVE_OTEL_EXTRA_RESOURCE_ATTRIBUTES=team=a,env=prod\nHIVE_AGENT_NATS_URL=tls://nats.example.test:4222\n' >"$facts"
|
||||
check "the per-host values, a value holding = kept whole" "HIVE_DASHBOARD_PORT=7123
|
||||
HYPERHIVE_CLAUDE_CODE_PATH=/nix/store/0abc-claude-code
|
||||
HYPERHIVE_OTEL_EXTRA_RESOURCE_ATTRIBUTES=team=a,env=prod
|
||||
HIVE_AGENT_NATS_URL=tls://nats.example.test:4222
|
||||
CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX=unknown-a1"
|
||||
|
||||
: >"$facts"
|
||||
|
|
|
|||
Loading…
Reference in a new issue