fix: log consumers miss lines on reconnect #4102
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 436 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.364
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4102"
general
weight: 0.35
stevenh
<!-- Type of change
Please label this PR with one of the existing labels, depending on the scope of your change
-->
What does this PR do?
<!-- Mandatory
Explain here the changes you made on the PR. Please explain the WHAT: patterns used, algorithms implemented, design architecture, etc.
-->
The log producer no longer cuts a working log stream every log production timeout. Instead it follows the stream until the container stops, and if the connection fails it resumes from the last entry delivered. It asks the daemon for timestamps, strips them before entries reach consumers, and reconnects with the last entry's timestamp as
since. It then skips the entries the daemon replays at that timestamp, by count rather than by content, which handles both Docker's inclusive nanosecondsinceand Podman's timestamps, which are only to the second. Entries without a timestamp are passed through unchanged. The cost is about 9ns per entry with no allocations.WithLogProductionTimeoutis deprecated and now has no effect, because there is no periodic reconnect left for it to control; the docs are updated to match. The log consumer tests that waited on the final line without a timeout now fail after five seconds instead of hanging the package.Why is it important?
<!-- Mandatory
Explain here the WHY, or the rationale/motivation for the changes.
-->
The periodic reconnect resumed from the current time, so any line the container wrote before the reconnect that hadn't been delivered yet was lost. Podman's logs endpoint is slow to respond, so these reconnect gaps regularly caught the container's final line. That made the log consumer tests fail intermittently on Podman, and hang the package until the 30 minute test timeout. The timeout originally existed so the old producer could check a stop channel; context cancellation has since replaced that, so cutting the stream no longer serves a purpose.
Related issues
<!-- Recommended
Link related issues below. Insert the issue link or reference after the word "Closes" if merging this should automatically close it.
-->
How to test this PR
<!-- Recommended
Explain here how this PR will be tested by the reviewer: commands, dependencies, steps, etc.
-->
TestLogProducerResumesAfterErrorruns the log producer against a fake daemon that drops the connection mid-stream, with Docker-style, Podman-style and untimestamped entries. It checks thesincevalue of each request and that every entry is delivered exactly once. Locally against Docker Desktop,go test . -run 'Test_LogConsumerGetsCalled|Test_ShouldRecognizeLogTypes|Test_MultipleLogConsumers|TestContainerLogsEnableAtStart|Test_MultiContainerLogConsumer_CancelledContext|TestRestartContainerWithLogConsumer|TestContainerLogDrainOnTerminate|TestContainerLogsShouldBeWithoutStreamHeader|TestContainerLogsTty|TestLogProducerResumesAfterError|TestSplitLogTimestamp'passed, andgolangci-lintv2.15 reported nothing in the changed code. The original failure needs Podman, so the Podman CI jobs are the real check.Follow-ups
<!-- Optional
Add here any thought that you consider could be identified as an actionable step once this PR is merged.
-->
Without the periodic timeout, a half-open TCP connection to a remote daemon is only detected by TCP keepalive. Since reconnects no longer lose entries, a stall detector could be added later if that turns out to matter.