Closes #21409: Add option to retain create & last update changelog records when pruning #223

Closed
opened 2026-04-05 16:23:07 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 3/4/2026

Fixes: #21409

Thanks for reviewing this PR!

This introduces a new dynamic configuration parameter, CHANGELOG_RETAIN_CREATE_LAST_UPDATE, which ensures each non-deleted object’s original create change record and most recent update change record are retained when pruning expired changelog entries per CHANGELOG_RETENTION. For objects with a delete change record, changelog entries are pruned normally according to CHANGELOG_RETENTION.

Changes included:

  • Add CHANGELOG_RETAIN_CREATE_LAST_UPDATE (enabled by default)
  • Update changelog pruning logic (system housekeeping job + housekeeping management command) to respect the new behavior, including excluding objects with a delete change record from the retention exemption
  • Add tests covering pruning behavior, including deleted-object scenarios
  • Update docs/templates/forms to surface the behavior in the UI and configuration reference (including an upgrade warning)

Why this is enabled by default

I’ve set the default value to True because NetBox defaults to a 90-day changelog retention period, which can remove valuable provenance data for new users (especially “who created this?” / “who last changed this?”) once the instance has been running for a while. In my experience it’s preferable to retain this minimal set of high-value records by default, even if the behavior change may be surprising for existing users, rather than silently losing it.

For existing deployments that prefer the previous pruning behavior, this can be reverted by setting
CHANGELOG_RETAIN_CREATE_LAST_UPDATE = False. Any previously retained records will then be eligible for pruning on the next housekeeping run.

*Originally created by @pheus on 3/4/2026* ### Fixes: #21409 Thanks for reviewing this PR! This introduces a new dynamic configuration parameter, `CHANGELOG_RETAIN_CREATE_LAST_UPDATE`, which ensures each **non-deleted** object’s original `create` change record and most recent `update` change record are retained when pruning expired changelog entries per `CHANGELOG_RETENTION`. For objects with a `delete` change record, changelog entries are pruned normally according to `CHANGELOG_RETENTION`. Changes included: - Add `CHANGELOG_RETAIN_CREATE_LAST_UPDATE` (enabled by **default**) - Update changelog pruning logic (system housekeeping job + `housekeeping` management command) to respect the new behavior, including excluding objects with a `delete` change record from the retention exemption - Add tests covering pruning behavior, including deleted-object scenarios - Update docs/templates/forms to surface the behavior in the UI and configuration reference (including an upgrade warning) #### Why this is enabled by default I’ve set the default value to `True` because NetBox defaults to a 90-day changelog retention period, which can remove valuable provenance data for new users (especially “who created this?” / “who last changed this?”) once the instance has been running for a while. In my experience it’s preferable to retain this minimal set of high-value records by default, even if the behavior change may be surprising for existing users, rather than silently losing it. For existing deployments that prefer the previous pruning behavior, this can be reverted by setting `CHANGELOG_RETAIN_CREATE_LAST_UPDATE = False`. Any previously retained records will then be eligible for pruning on the next housekeeping run.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#223