Skip to content

fix(compose): restore Vector log writes and unbreak prod compose validation (#1799) - #1800

Merged
vybe merged 1 commit into
devfrom
fix/1799-vector-log-perms-prod-compose
Jul 27, 2026
Merged

vybe merged 1 commit into
devfrom
fix/1799-vector-log-perms-prod-compose

Conversation

@obasilakis

Copy link
Copy Markdown
Contributor

Fixes two independent, silent compose defects found while diagnosing a Docker daemon wedge caused by a full disk.

Compose-only — no schema change, no migration, no code change, no new config surface.

Closes #1799


1. Vector has discarded ALL log output since #1478 (v0.8.0)

Affects both docker-compose.yml and docker-compose.prod.yml.

logs-init chowns /data/logs to 1000:1000 / 775 so the UID-1000 backend's retention sweep can delete archived originals (#1478). But vector runs as root with cap_drop: ALL, which strips CAP_DAC_OVERRIDE — the capability that lets root bypass file permission checks. Root is neither the owner (1000) nor in the group (1000), so it falls through to other on a 775 dir: r-x, no write bit.

Every sink write fails:

ERROR sink{component_id=local_logs component_type=file}: vector::internal_events::file:
  Unable to open the file. path=b"/data/logs/local-2026-07-27.json"
  error=Permission denied (os error 13) error_code=failed_opening_file
ERROR component_events_dropped: Events dropped intentional=false count=1

Why it went unnoticed for ~3 weeks: a file-sink error does not fail Vector's healthcheck, which only probes the :8686 API. The container reports healthy while writing nothing. On the instance where this surfaced, /data/logs had no new files between 2026-07-09 and 2026-07-27 — every platform and agent log in that window is unrecoverable.

Pre-#1478 files are root:root, which is why this only started when the directory ownership changed.

Fix

group_add: ["1000"] on vector.

Two deliberate choices worth reviewing:

  • group_add, not cap_add: [DAC_OVERRIDE] — uses the directory's existing group-write bit rather than restoring a capability, so the cap_drop: ALL posture (Invariant Client/Viewer User Role (AUTH-002) #17 territory) is preserved.
  • Vector stays root — raw container logs under /var/lib/docker/containers/*/*-json.log are 0640 root:root, so user: "1000:1000" would trade a write failure for a read failure.

2. docker-compose.prod.yml failed schema validation and hid a conflicting retention default

backend.environment is a YAML list, and two separate "#1039 packaging gap" fixes each appended the same trio:

[ 66] LOG_RETENTION_DAYS=${LOG_RETENTION_DAYS:-5}       <- block A
[ 67] LOG_ARCHIVE_ENABLED=${LOG_ARCHIVE_ENABLED:-true}
[ 68] LOG_CLEANUP_HOUR=${LOG_CLEANUP_HOUR:-3}
...
[112] LOG_ARCHIVE_ENABLED=${LOG_ARCHIVE_ENABLED:-true}  <- block B
[113] LOG_RETENTION_DAYS=${LOG_RETENTION_DAYS:-90}
[114] LOG_CLEANUP_HOUR=${LOG_CLEANUP_HOUR:-3}

Two distinct problems, only one visible:

2a — hard failure. LOG_ARCHIVE_ENABLED and LOG_CLEANUP_HOUR are byte-identical in both blocks. Compose requires array items to be unique, so the file does not parse:

$ docker compose -f docker-compose.prod.yml config
validating docker-compose.prod.yml: services.backend.environment array items[67,112] must be unique

2b — silent semantic conflict. LOG_RETENTION_DAYS is also duplicated, but 5 vs 90. Because the strings differ, the uniqueness check does not flag it — fixing 2a by deduping only the identical pair would leave this in place. Docker resolves a repeated env key by last-wins, so prod silently runs 90 while block A, docker-compose.yml, and config.py (COMMUNITY_RETENTION_FLOOR_DAYS = 5) all say 5.

The conflict direction keeps 18× more rather than deleting early, so unlike #1638 this is a disk-growth bug, not data loss. It still matters: log_archive_service only deletes originals older than the window, so a 90-day window is a large unbounded-growth contributor — the same failure mode that wedged the daemon here.

Fix

Removed block B; kept block A (matches docker-compose.yml and the code default), folding B's LOG_ARCHIVE_PATH-omission rationale into A's comment.


Verification

docker compose -f docker-compose.yml      config  -> VALID
docker compose -f docker-compose.prod.yml config  -> VALID   (before: parse error)

both resolve  vector.group_add = ['1000'], cap_drop = ['ALL'], user = root
both resolve  backend LOG_RETENTION_DAYS = 5        (prod before: silently 90)

Live on the affected instance after applying the Vector fix:

before: 0 output files since 2026-07-09, repeated "Permission denied" per cycle
after : -rw-r--r-- 1 root root 2636479 /data/logs/local-2026-07-27.json
        0 permission errors

Deployment note

Existing deployments pick up the Vector fix on the next docker compose up -d — its service config changed, so Vector is recreated automatically. No action needed beyond a normal deploy. Logs already dropped are not recoverable.

Out of scope

The same investigation found that no compose service or SDK-created agent container sets any logging: / log_config, so container logs grow unbounded — the root cause of the full disk. That fix is deliberately kept out of this PR to keep it reviewable, and will be filed separately.

🤖 Generated with Claude Code

…dation (#1799)

Two independent compose defects, both silent, both found while diagnosing a
Docker daemon wedge caused by a full disk.

1. Vector has discarded ALL log output since #1478 (v0.8.0)

   #1478 chowns /data/logs to 1000:1000 (chmod 775) so the UID-1000 backend's
   retention sweep can delete archived originals. But the vector service runs
   as root with cap_drop: ALL, which strips CAP_DAC_OVERRIDE — the capability
   that lets root ignore file permissions. Root is neither the owner (1000)
   nor in the group (1000), so it falls through to "other" (r-x) on a 775 dir
   and every sink write fails:

     ERROR sink{component_id=local_logs component_type=file}:
       Unable to open the file. path=b"/data/logs/local-2026-07-27.json"
       error=Permission denied (os error 13)

   This is silent because a file-sink error does not fail Vector's healthcheck,
   which only probes the :8686 API — the container reports healthy while
   writing nothing. On the instance where this was found, /data/logs had no new
   files between 2026-07-09 and 2026-07-27.

   Fixed with group_add: ["1000"], which uses the directory's existing
   group-write bit rather than restoring a capability, so the cap_drop posture
   is preserved. Vector must stay root for the uid: raw container logs under
   /var/lib/docker/containers are 0640 root:root, so user: "1000:1000" would
   swap a write failure for a read failure.

2. docker-compose.prod.yml failed schema validation and hid a conflicting
   retention default

   backend.environment is a YAML list, and two separate #1039-class "mirror
   docker-compose.yml" fixes each appended the same LOG_* trio. That broke the
   file two different ways:

   - LOG_ARCHIVE_ENABLED and LOG_CLEANUP_HOUR were byte-identical across both
     blocks. Compose requires array items to be unique, so the file did not
     parse at all:
       validating docker-compose.prod.yml:
         services.backend.environment array items[67,112] must be unique

   - LOG_RETENTION_DAYS was duplicated with a DIFFERENT value (5 vs 90).
     Differing strings are not caught by the uniqueness check, so deduping only
     the identical pair would fix the parse error and leave this in place.
     Docker resolves a repeated env key by last-wins, so prod would silently
     run 90 while its own earlier block, docker-compose.yml, and config.py
     (COMMUNITY_RETENTION_FLOOR_DAYS = 5) all say 5.

   The conflict direction keeps 18x more rather than deleting early, so unlike
   #1638 this is a disk-growth bug, not data loss — but log_archive_service
   only deletes originals older than the window, making it a large contributor
   to unbounded growth.

   Removed the later duplicate block; kept the one matching docker-compose.yml
   and the code default, folding its LOG_ARCHIVE_PATH rationale into the
   survivor.

Compose-only: no schema change, no migration, no code change, no new config
surface. Existing deployments pick up the Vector fix on the next
docker compose up -d (its service config changed, so it is recreated).

Verification:
  docker compose -f docker-compose.yml      config  -> VALID
  docker compose -f docker-compose.prod.yml config  -> VALID (was: parse error)
  both resolve vector.group_add=['1000'], cap_drop=['ALL'], user=root
  both resolve backend LOG_RETENTION_DAYS=5 (prod was silently 90)
  live: 0 permission errors, /data/logs writing again after 18 days silent

Closes #1799
@github-actions

Copy link
Copy Markdown

⚠️ Nightly unit-suite check skipped — merge conflict against dev.

Resolve by running git merge dev locally and pushing the result. The next nightly run will re-test once the conflict is gone.

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated via /validate-pr: compose-only fix for #1799 — dedupes the LOG_* trio (restores prod compose validation, resolves the 5-vs-90 retention conflict in favor of the documented community floor) and grants Vector GID 1000 group-write instead of restoring CAP_DAC_OVERRIDE (cap_drop posture preserved). Infra change justified in-diff. Security scan clean.

@vybe
vybe merged commit 65fa67e into dev Jul 27, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants