Conversation
…ter them When the tailer reached EOF in the middle of a line, nxadm/tail sent the partial line as a complete one, then seeked to the end of the file: the rest of that line, and any line written in the meantime, were never read. CompleteLines is nxadm/tail's option for this: a partial line is kept until its newline arrives. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@n1koo: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.
DetailsI am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository. |
|
@n1koo: There are no area labels on this PR. You can add as many areas as you see fit.
DetailsI am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository. |
|
/kind fix |
|
Another production data point supporting this fix, on v1.7.8. Setup: a Traefik v3 JSON access log written to a host file (Docker bind mount) and tailed by the CrowdSec agent through a Measured over ~21h, by comparing the lines written to the file in the agent's uptime window with the
I checked |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4678 +/- ##
==========================================
+ Coverage 64.73% 65.19% +0.45%
==========================================
Files 522 505 -17
Lines 39863 39130 -733
==========================================
- Hits 25807 25511 -296
+ Misses 11654 11256 -398
+ Partials 2402 2363 -39
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hello, It seems the tests are flaky on windows (https://github.com/crowdsecurity/crowdsec/actions/runs/34595197049/job/104708935711?pr=4678#step:6:14353), which is often the case when relying on small sleep for synchronization (the windows runners are extremely slow) |
What and why
The file datasource silently drops lines when a log is written in bursts. If the tailer hits EOF mid-line, nxadm/tail sends the partial line, then seeks to EOF. That skips everything written in between (tail.go#L336-L342). On a production Traefik log (~65k lines/day, v1.8.1), this showed up as 37
UnmarshalJSON : unexpected end of JSON inputerrors in 7 days. The skipped lines log nothing.This sets
CompleteLines: true, nxadm/tail's own option for this. It is off by default because the nxadm fork merged hpcloud/tail#126, and was restored as opt-in in nxadm/tail#26. Trade-offs:file reader died.Not covered: at startup the tail seeks to EOF, which can still land mid-line.
Human review: I read the diff line by line and verified the testing below.
How it was tested
The new test fails on master: the partial line is sent and the lines after it are lost. It is file-only, because this is the only datasource using nxadm/tail.
I replayed 40,000 production lines in request bursts, one
write()per line. v1.8.1 parsed 39,961 of them in one run and 39,998 in another; with this patch it parsed all 40,000 both times.golangci-lint v2.10: 0 issues on linux, windows and freebsd. Tests were run on Linux only.
Checklist
cscli -o json|rawoutput.AI assistance used: mostly