Repository navigation
Accept single-record Filebeat registries during cleanup - #1168
Merged
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1165.
Normalize a parsed registry object to one record before iterating. A valid single-entry file previously produced a dictionary, whose keys were passed to deep_get and aborted the cleanup run.
JSON arrays, NDJSON, device/inode conversion and protection of registered files retain existing behavior. The general JSON loader, retention rules and corrupt-input policies are unchanged. This is separate from #1160's lock correction.
Testing
python -m pytest -q filebeat/tests/test_single_record_registry.py17 focused tests passed; ten fail on unchanged source. Coverage includes compact/pretty/single-line objects, numeric and string identities, arrays, NDJSON, multiple registries, incomplete records and empty/missing files.
The full prune_files path runs against temporary plaintext logs recognized by real libmagic. It preserves the registered file and removes only an isolated expired unregistered fixture; fuser is mocked. No production log, registry, Filebeat process or external service was accessed. Combined validation with #1160 also passes.
Tested on macOS with Python 3.12. New-test formatting, syntax checks, scoped lint with the Python 3.12 target, and
git diff --checkpass. Full Malcolm deployment testing was not run. No workflow or dependency changes.