← Back to Pull requests

fix: log consumers miss lines on reconnect #4102

Open
unknown opened this pull request with 436 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 09, 2026 14:53 UTC
Author

<!-- 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 nanosecond since and 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.

WithLogProductionTimeout is 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.

  • Closes #123

  • Relates #123

  • Requires #123

  • Supersedes #123

  • -->
  • Closes #4101
  • How to test this PR

    <!-- Recommended
    Explain here how this PR will be tested by the reviewer: commands, dependencies, steps, etc.
    -->

    TestLogProducerResumesAfterError runs the log producer against a fake daemon that drops the connection mid-stream, with Docker-style, Podman-style and untimestamped entries. It checks the since value 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, and golangci-lint v2.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.

    Diff: 436 lines (+327 / -109) across 5 files Reviewer: stevenh Review duration: 23480m
    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
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.1% · Safe to merge
    24.1%