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 <noreply@anthropic.com>
This commit is contained in:
atlas 2026-09-13 21:43:14 +02:00
commit 6de28514cd

View file

@ -234,7 +234,15 @@ in
# host-persisted state bind mount: it indexes /var/log/journal, # host-persisted state bind mount: it indexes /var/log/journal,
# itself fresh on every container recreate, so the two must share # itself fresh on every container recreate, so the two must share
# a lifetime or the cursor outlives the journal it points into. # 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 = { receivers.journald = {
# ⚠️ STATED, and it must stay stated: the receiver's own default # ⚠️ STATED, and it must stay stated: the receiver's own default