fix(sentinel): start log retention pruning timer on dynamic enable - #298
Merged
Conversation
The pruning timer was only started in init/1 when data_retention_period
was non-nil. The handle_cast({:update_data_retention_period, ...})
callback updated the retention period in state but never started the
timer if it was not already running. So if log retention was initially
disabled (nil) and then enabled via a config change through the watcher,
old log entries were never pruned.
Track the timer reference in state. Start the timer when transitioning
from nil to a non-nil retention period, and cancel it when transitioning
back to nil.
Risk assessment:
- Impact: Log retention now works correctly when enabled at runtime via
config changes, not just when set at startup
- Blast radius: sentinel logs server only; the prune timer lifecycle is
the only behavior change
- Regression risk: low - existing behavior (timer started in init) is
preserved; the new code only adds start/cancel on dynamic updates
- Rollback: plain commit revert
thiagoesteves
force-pushed
the
thiagoesteves/fix-log-retention-timer
branch
from
August 14, 2026 12:16
6573bfa to
04bf3c1
Compare
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
init/1whendata_retention_periodwas non-nil. Thehandle_cast({:update_data_retention_period, ...})callback updated the retention period in state but never started the timer if it was not already running. So if log retention was initially disabled (nil) and then enabled via a config change through the watcher, old log entries were never pruned.Test plan
mix test apps/sentinel/test/logs/server_test.exs --warnings-as-errors(13 tests)mix format --check-formattedmix credo --strict apps/sentinel/lib/sentinel/logs/server.exRisk assessment
Generated with Devin powered by GLM-5.2 High