Fix container ignoring max bytes when parsing CRI partial messages#49743
Fix container ignoring max bytes when parsing CRI partial messages#49743belimawr wants to merge 9 commits intoelastic:mainfrom
Conversation
GenAI-Assisted: Yes Human-Reviewed: Yes Tool: Claude-CLI, Model: Sonet 4.6
🤖 GitHub commentsJust comment with:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses an OOM risk in Filebeat’s container/CRI log parsing by enforcing the max_bytes limit during CRI partial-line reassembly (instead of only after reassembly), and adds a regression test plus a changelog fragment.
Changes:
- Add
maxBytessupport toDockerJSONReaderand enforce it while joining CRI partial (P) chunks. - Plumb
max_bytesfrom the harvester/parser pipeline into the Docker/CRI JSON reader. - Add a unit test and a changelog fragment for the fix.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
libbeat/reader/readjson/docker_json.go |
Introduces maxBytes and truncation logic during partial reassembly. |
libbeat/reader/readjson/docker_json_test.go |
Updates constructor usage and adds a new max-bytes regression test. |
libbeat/reader/parser/parser.go |
Passes configured MaxBytes into the container parser. |
filebeat/input/log/harvester.go |
Passes MaxBytes into the Docker JSON reader; normalizes some error strings. |
changelog/fragments/1774630083-fix-container-max-bytes.yaml |
Adds release note entry for the bug fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a changelog fragment and wires 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@changelog/fragments/1774630083-fix-container-max-bytes.yaml`:
- Line 12: In the changelog fragment, update the YAML key value for "kind" from
"bug" to the exact expected token "bug-fix" so the changelog tool recognizes
this as a fix; locate the "kind" entry in the fragment (the line currently
reading kind: bug) and replace its value with kind: bug-fix.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: beda5ed9-4c33-44f8-8ccf-568533f875b4
📒 Files selected for processing (5)
changelog/fragments/1774630083-fix-container-max-bytes.yamlfilebeat/input/log/harvester.golibbeat/reader/parser/parser.golibbeat/reader/readjson/docker_json.golibbeat/reader/readjson/docker_json_test.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Proposed commit message
See title
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesstresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.## Disruptive User Impact## Author's ChecklistHow to test this PR locally
1. Run the tests
The test added by this PR is
TestDockerJSONMaxBytesinlibbeat/reader/readjson/docker_json_test.go.2. Manual testing
Follow the 'steps to reproduce' from #49259, you'll have to add
allow_deprecated_use: trueto the input configuration to run Filebeat >= 9.0.0.Or build the docker image then run the following script.
To build:
If the test fails at the end of the build, don't worry, that's likely because your Docker version is >= 29. Just ensure the image
docker.elastic.co/beats/filebeat-oss:9.4.0-SNAPSHOTwas built.It will print
Error: Process killed by OOM (Out of Memory) Killer (Exit Code: 137)for the latest release and will just 'hang' (well, keep executing) with the currently build FilebeatRelated issues
## Use cases## Screenshots## Logs