hive-c0re: name an agent container after its machine, not "nixos"
Every agent container reports the hostname `nixos`, so every log line it ships carries that as its `_HOSTNAME`. Measured: host `muede-lpt2`, `hive-matrix` (declared as `containers.hive-matrix`) `hive-matrix`, and `h-atlas` `nixos`. nixpkgs sets the hostname in the merge function of the `containers.<name>.config` option (nixos-containers.nix:524), so it reaches a guest evaluated through that option and nothing else. Agent containers are `nixos-container create --flake meta#<name>` — an independent `nixosSystem` off the meta flake, which never evaluates that submodule. nspawn also names a container's hostname after the machine by default; that is ruled out as the source here, because `h-atlas`'s machine name is `h-atlas` and it reports `nixos`. The machine name rather than the logical one: `stats/otel_metrics.rs:345` already labels metrics `container.name = "h-<name>"`, so the logical name would make logs say `atlas` while metrics say `h-atlas` — a prefix transform on every join between the two signals. Declarative containers and nspawn both use the machine name too, so this is one rule with no exception for agents. The emission sits next to `hyperhive.user.name = name;`, which already derives the container's unix user from the agent name; the hostname was the one identity attr nobody wired. Also drops the prose in swarm-otel.nix and module-eval.nix that explained `_MACHINE_ID` by "every container is `nixos`" — that motivating example is what this commit removes, and the argument for `_MACHINE_ID` never depended on it. Checked before editing: nothing in the tree assumes the hostname is "nixos" (0 hits across *.rs and *.nix), and nothing reads the hostname at runtime. Gate: cargo fmt 0, clippy -D warnings 0, cargo test -p hive-c0re meta:: 0 (23 run, 22 passed, 1 ignored), nix fmt 0 changed. Refs #4304
This commit is contained in:
parent
4db746a22c
commit
2a02c76ad5
3 changed files with 52 additions and 10 deletions
|
|
@ -1459,9 +1459,9 @@ let
|
|||
&& lib.hasInfix "logs.t.local" l;
|
||||
}
|
||||
{
|
||||
# `_HOSTNAME` cannot separate containers: none sets
|
||||
# `networking.hostName`, so it is `nixos` for all of them and every
|
||||
# container's stream for a unit name merges into one.
|
||||
# `_HOSTNAME` cannot separate machines on its own: a hostname is a
|
||||
# config value two of them can share, and then every stream for a unit
|
||||
# name merges into one.
|
||||
name = "the log stream is keyed by machine, not only by a hostname every container shares";
|
||||
ok =
|
||||
let
|
||||
|
|
|
|||
Loading…
Reference in a new issue