Fix audit middleware file handle leak on shutdown#3074
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3074 +/- ##
==========================================
+ Coverage 63.66% 63.76% +0.10%
==========================================
Files 360 360
Lines 35328 35322 -6
==========================================
+ Hits 22491 22523 +32
+ Misses 11030 10992 -38
Partials 1807 1807 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JAORMX
previously approved these changes
Jan 12, 2026
Store Auditor reference in Middleware struct to enable proper cleanup. Update Close() to call Auditor.Close() for file-based logging. Use NewAuditorWithTransport directly instead of CreateMiddlewareWithTransport. This ensures audit log file handles are properly closed when the runner shuts down, preventing resource leaks and ensuring logs are flushed.
Delete CreateMiddlewareWithTransport and GetMiddlewareFromFile functions along with their tests. These functions had a design flaw where they created an Auditor but only returned the middleware function, making it impossible for callers to close file handles. The CreateMiddleware factory now calls NewAuditorWithTransport directly, making these wrapper functions unnecessary.
ad1d879 to
b75b68f
Compare
JAORMX
approved these changes
Jan 13, 2026
Collaborator
|
This has been approved and sitting here for a few weeks now. The only failing check is the E2E test on K8s v1.34.3, but it passes on v1.33.7 and v1.35.0. Looks like a flaky test rather than anything related to this change. Want to rebase and re-run CI to get this merged? |
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.
Store Auditor reference in Middleware struct to enable proper cleanup. Update Close() to call Auditor.Close() for file-based logging. Use NewAuditorWithTransport directly instead of CreateMiddlewareWithTransport.
This ensures audit log file handles are properly closed when the runner shuts down, preventing resource leaks and ensuring logs are flushed.