Skip to content

Keep cleanup runners coordinated through a stable lock file - #1160

Merged
mmguero merged 1 commit into
cisagov:sylvesterkaczmarek-mergesfrom
sylvesterkaczmarek:fix/cleanup-lock-inode-lifetime-20261006
Oct 7, 2026
Merged

mmguero merged 1 commit into
cisagov:sylvesterkaczmarek-mergesfrom
sylvesterkaczmarek:fix/cleanup-lock-inode-lifetime-20261006

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Summary

Fixes #1157.

Keep the lock inode in place after both successful and unsuccessful attempts. The prior finally block let a losing contender unlink a live lock, allowing another runner to acquire a new inode and execute concurrently.

The file descriptor still closes on every return or exception, releasing the kernel lock. The empty lock file now intentionally persists. Cleanup eligibility, retention limits and the cleanup callback are unchanged.

Testing

python -m pytest -q filebeat/tests/test_cleanup_lock.py

7 focused tests passed; 5 fail on unchanged source. Coverage uses actual fcntl.flock calls, separate descriptors and a separate Python process, plus successful sequential runs and exception recovery. The cleanup callback is mocked or writes an isolated marker; no production log is removed.

Tests ran on macOS with Python 3.12. Filebeat/container deployment testing was not run.

New-test formatting, syntax checks and git diff --check pass. No dependency, workflow or version changes.

Thanks for taking a look.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@mmguero mmguero self-assigned this Oct 6, 2026
@mmguero mmguero added the upload Relating to PCAP and/or Zeek log ingestion label Oct 6, 2026
@mmguero mmguero added this to the v26.10.0 milestone Oct 6, 2026
@mmguero mmguero added this to Malcolm Oct 6, 2026
@mmguero
mmguero changed the base branch from main to sylvesterkaczmarek-merges October 7, 2026 14:45
@mmguero
mmguero merged commit b2b4658 into cisagov:sylvesterkaczmarek-merges Oct 7, 2026
@mmguero mmguero moved this from Done to Released in Malcolm Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upload Relating to PCAP and/or Zeek log ingestion

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

Competing cleanup runners can unlink the active lock and enter concurrently

2 participants