Skip to content

fix(socket-proxy): hold quiet log follows open past the idle timeouts - #1560

Merged
Gerrrt merged 2 commits into
mainfrom
fix/socket-proxy-log-follow-timeout
Nov 17, 2026
Merged

Gerrrt merged 2 commits into
mainfrom
fix/socket-proxy-log-follow-timeout

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

What changed

docker-socket-proxy now holds a loki.source.docker log follow open past upstream's 10-minute idle timeouts, for /containers/{id}/logs only, so Alloy stops re-sending a quiet container's last line every ten minutes. The lab's Prometheus gains the estate's LogEntriesDropped rule, so a lab guest dropping log lines now alerts.

  • stacks/observability/docker-socket-proxy/haproxy.cfg: http-request set-timeout client 24d on the /logs path, inside the existing homelab block before its allow rule. A second homelab block at the end routes /logs to upstream's docker-events backend (timeout server 0). The header's new "3." explains why.
  • scripts/check_socket_proxy.sh: the drift check expects two blocks. A new idle section boots the pinned image on a copy of the config with the idle timeouts cut to 5 s. A follow on a quiet container must still be open at 20 s. A control copy without the two Alloy re-sends a quiet container's last log line every 10 minutes through the socket proxy #1552 lines must close the same follow within that window, after at least the timeout. /events is followed too, and its lifetime is printed for the record.
  • stacks/lab/prometheus/rules/lab.rules.yaml: LogEntriesDropped, with the estate's expression and for: 1h. Tests: a firing case of fenrir's shape and a quiet restart burst. Counts are 22 → 23.
  • docs/security.md and docs/changelog.md.

Why

Refs #1552. The defaults' timeout client 10m / timeout server 10m closed an idle follow. Alloy reconnected from its saved position and shipped the last line again. Once that line was 7 days old, Loki rejected every copy: 1363 entries on fenrir, with no alert in the lab.

Two HAProxy facts shaped the fix. Both come from the 3.4 manual; haproxy -v in the pinned image reads 3.4.2.

  • set-timeout "must be non-null", so 0 is not used. 24d is just under HAProxy's 2^31 ms timer limit.
  • set-timeout server only works in a section with backend capabilities, and the frontend has none. So the server side comes from routing to docker-events, whose only difference from dockerbackend is timeout server 0.

Refs #836.

Blast radius

Every Alloy behind this file: the six compose stacks and deploy-agent.sh's agent proxies. If it's wrong, docker log collection stalls or keeps re-sending. No path is newly allowed: the allow rules are unchanged, and the drift check still proves upstream's template is unchanged under ours.

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml

Verification

Run on a Mac with no Docker daemon, so everything that boots an image skipped. That includes the new idle test, which only CI's hardened boot exercises.

  • make validate did not pass locally. The failures are this host's toolchain, not the change: sub-scripts found no PyYAML, flock is missing, BSD stat lacks -c, and ansible-lint's local runner fails. Every Docker check skipped.

  • promtool check rules → 23 rules found. promtool test rules passed for both lab test files, and "every alert rule is selected by a promtool test" passed.

  • check_docs.py (PyYAML in a venv) → docs OK — 164 Prometheus + 21 Loki rules, 8 dashboards, 156 panels, 14 assertions.

  • lint.sh: yamllint passed. shellcheck and actionlint passed on local binaries, not the pinned ones. markdownlint, editorconfig-checker, packer and tofu skipped.

  • The drift rebuild, run alone against upstream's v0.5.0 haproxy.cfg from GitHub: identical. The control derivation was checked by diff: it removes exactly the set-timeout line and the second block.

  • make validate passes (CI)

  • Deployed to the lab and confirmed working. After merge: make up STACK=sensor on fenrir, then an hour with no recurring could not transfer logs for sensor-zeek and a flat loki_write_dropped_entries_total. The issue stays open until that check passes.

  • Docs updated (docs/, service README, or docs/roadmap.md)

🤖 Generated with Claude Code

The socket proxy inherited upstream's ten-minute client and server idle
timeouts, so a quiet container's log follow was closed every ten minutes.
Alloy reconnected and re-sent the last line, and Loki rejected it once it
was seven days old. The fix lifts the client timeout and routes the
server side to the backend with no timeout, for /containers/{id}/logs
only. check_socket_proxy.sh proves it with shortened timeouts and a
control, and the lab gains the estate's LogEntriesDropped rule.

Refs #1552.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 23:24
@Gerrrt
Gerrrt enabled auto-merge (squash) November 17, 2026 23:24
…follow-timeout

# Conflicts:
#	docs/changelog.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The shared HAProxy change affects log collection across six stacks and deployed agents, but skipped local runtime checks leave CI results and planned fenrir canary validation requiring human review.

No open issues 🎉

What changed in this PR

Addresses quiet-container log replay in #1552 by extending socket-proxy log-follow lifetimes without widening allowed paths. Adds lab alerting for sustained log loss.

Changes:

  • Sets a 24-day client timeout for container log requests and routes them through the backend with no server timeout.
  • Adds an accelerated idle-timeout regression check with a control configuration, while preserving upstream drift checks.
  • Adds the lab’s LogEntriesDropped alert, firing and restart-burst tests, and supporting documentation.

Docker-based verification and deployment confirmation remain pending.

File Description
stacks/​observability/​docker-socket-proxy/​haproxy.cfg Extends client and server idle limits for container log requests.
stacks/​lab/​README.md Updates the rule count and describes log-loss coverage.
stacks/​lab/​prometheus/​tests/​lab.test.yaml Tests sustained log-loss alerting and restart-burst suppression.
stacks/​lab/​prometheus/​rules/​lab.rules.yaml Adds LogEntriesDropped with a one-hour pending period.
scripts/​check_socket_proxy.sh Adds idle-follow and control checks; updates drift reconstruction.
docs/​security.md Documents longer log follows and unchanged path restrictions.
docs/​changelog.md Records the timeout fix, alert addition, and pending deployment verification.

Review effort: Balanced

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