From 6de28514cd91ffe4d20f4b60587fa42dcf34ffa6 Mon Sep 17 00:00:00 2001 From: atlas Date: Sun, 13 Sep 2026 21:43:14 +0200 Subject: [PATCH] fix(otel): let file_storage extension create its own directory validateConfigFile runs `otelcol validate` at nix build time, in a pure sandbox where systemd's StateDirectory= has not run yet, so the directory named by extensions.file_storage.directory does not exist. Setting create_directory = true lets the validator create it itself, matching what happens at runtime once StateDirectory= has acted. Refs #4375 Co-Authored-By: Claude Sonnet 5 --- nix/agent-modules/otel.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nix/agent-modules/otel.nix b/nix/agent-modules/otel.nix index e4ff3200..95a432cf 100644 --- a/nix/agent-modules/otel.nix +++ b/nix/agent-modules/otel.nix @@ -234,7 +234,15 @@ in # host-persisted state bind mount: it indexes /var/log/journal, # itself fresh on every container recreate, so the two must share # a lifetime or the cursor outlives the journal it points into. - extensions.file_storage.directory = "/var/lib/opentelemetry-collector"; + # `create_directory` matters here for a build-time-vs-runtime + # reason, not a convenience one: `validateConfigFile` above runs + # `otelcol validate` in the nix build sandbox, before systemd's + # `StateDirectory=` has ever created this path. Without it the + # validator refuses with "directory must exist" and the build fails. + extensions.file_storage = { + directory = "/var/lib/opentelemetry-collector"; + create_directory = true; + }; receivers.journald = { # ⚠️ STATED, and it must stay stated: the receiver's own default