Skip to content

fix(kubernetes_logs): preserve partial records across file rotation - #27324

Draft
ss25sand wants to merge 2 commits into
vectordotdev:masterfrom
ss25sand:ssandhu/vector-kubernetes-log-rotation
Draft

ss25sand wants to merge 2 commits into
vectordotdev:masterfrom
ss25sand:ssandhu/vector-kubernetes-log-rotation

Conversation

@ss25sand

Copy link
Copy Markdown

Summary

A partial container log message can span kubelet-rotated files. Grouping by filename separates its fragments, and independently polling the files can deliver the ending before the beginning. Read each container attempt’s files in order and merge its fragments across rotations, keeping stdout, stderr, and container restarts separate. With oldest_first: false, each attempt shares read time with the other attempts.

Newly discovered sequences receive a confirming scan before consumption. On Linux, a short-lived read lease checks that a predecessor’s writer has closed; late bytes are drained before advancing. If that check is unavailable, the reader warns and falls back to EOF-based ordering. A writer that remains open delays newer files for its attempt. These completion and portability tradeoffs need maintainer review.

The first commit preserves the stream-separation contribution from #26566, including its original authorship. The rotation implementation is a separate commit, with one compatibility adjustment from the deprecated Value::as_str accessor to Value::to_str_lossy. The independent allocation optimization in #26516 is not included.

References

Closes #24981.
Related: #26566 and #25385. The regression coverage targets kubelet timestamp-named rotations; Docker symlink behavior in #25385 is not claimed as fixed.

Vector configuration

The affected source is kubernetes_logs with automatic partial merging enabled. No new configuration fields are introduced. The fairness tests use oldest_first: false; the existing default and priority option are retained.

sources:
  pods:
    type: kubernetes_logs
    auto_partial_merge: true
    oldest_first: false

How did you test this PR?

Validation is against current upstream master with Rust 1.100.0.

  • Linux: all 12 file-source tests, all 69 Kubernetes-source tests, and the existing generic file-source fair-read and oldest-first regressions pass.
  • macOS: all 11 applicable file-source tests and all 66 applicable Kubernetes-source tests pass.
  • FEATURES=sources-kubernetes_logs,sources-file make check-clippy passes on Linux.
  • make fmt, make check-markdown, and make check-changelog-fragments pass.

The regression cases cover cross-file merging in both log namespaces, restart/stream isolation, ordering during discovery, a rename between listing and opening, late predecessor writes after EOF, final unterminated bytes, and continued progress for unrelated containers. The new cross-file merger regression fails before the rotation change (two records instead of one) and passes after it.

An earlier 0.61 downstream implementation also passed replay and live kubelet rotation with 13 MiB and 50 MiB messages, matching the expected hashes and surrounding record order. All 60 control messages arrived, including 36 before the large record completed. That runtime build also carried the separate allocation fix from #26516; those measurements are supporting evidence for this port.

Does this PR include user facing changes?

  • Yes.
  • No.

ravi-inguva and others added 2 commits November 25, 2026 00:24
Keep file reads ordered within each container attempt, with stable per-stream merge keys across kubelet rotation. Confirm discovery before consuming new sequences and drain predecessors after their writers close.

AI-assisted implementation and tests: OpenAI Codex (GPT-6).
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, please sign our Contributor License Agreement.

To sign, copy and post the phrase below as a new comment on this PR.

Note: If the bot says your username was not found, the email used in your git commit may not be linked to your GitHub account. Fix this at github.com/settings/emails, then comment recheck to retry.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
✅ (ravi-inguva)[https://github.com/ravi-inguva]
❌ @sam Sandhu
Sam Sandhu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot added the domain:sources Anything related to Vector's sources label Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain:sources Anything related to Vector's sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incomplete log records in Kubernetes

2 participants