From 7b258dc11f82de5dd122f2405d93d116acec1534 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 27 Mar 2023 12:10:59 -0400 Subject: [PATCH] Rename JOBRESULT_RETENTION to JOB_RETENTION --- docs/administration/housekeeping.md | 2 +- docs/configuration/index.md | 2 +- docs/configuration/miscellaneous.md | 8 +++++--- netbox/extras/admin.py | 2 +- netbox/extras/management/commands/housekeeping.py | 8 ++++---- netbox/netbox/config/parameters.py | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/administration/housekeeping.md b/docs/administration/housekeeping.md index fcc3aa04e..212b8308d 100644 --- a/docs/administration/housekeeping.md +++ b/docs/administration/housekeeping.md @@ -4,7 +4,7 @@ NetBox includes a `housekeeping` management command that should be run nightly. * Clearing expired authentication sessions from the database * Deleting changelog records older than the configured [retention time](../configuration/miscellaneous.md#changelog_retention) -* Deleting job result records older than the configured [retention time](../configuration/miscellaneous.md#jobresult_retention) +* Deleting job result records older than the configured [retention time](../configuration/miscellaneous.md#job_retention) * Check for new NetBox releases (if [`RELEASE_CHECK_URL`](../configuration/miscellaneous.md#release_check_url) is set) This command can be invoked directly, or by using the shell script provided at `/opt/netbox/contrib/netbox-housekeeping.sh`. This script can be linked from your cron scheduler's daily jobs directory (e.g. `/etc/cron.daily`) or referenced directly within the cron configuration file. diff --git a/docs/configuration/index.md b/docs/configuration/index.md index 42d254027..4f8d102f7 100644 --- a/docs/configuration/index.md +++ b/docs/configuration/index.md @@ -26,7 +26,7 @@ Some configuration parameters are primarily controlled via NetBox's admin interf * [`DEFAULT_USER_PREFERENCES`](./default-values.md#default_user_preferences) * [`ENFORCE_GLOBAL_UNIQUE`](./miscellaneous.md#enforce_global_unique) * [`GRAPHQL_ENABLED`](./miscellaneous.md#graphql_enabled) -* [`JOBRESULT_RETENTION`](./miscellaneous.md#jobresult_retention) +* [`JOB_RETENTION`](./miscellaneous.md#job_retention) * [`MAINTENANCE_MODE`](./miscellaneous.md#maintenance_mode) * [`MAPS_URL`](./miscellaneous.md#maps_url) * [`MAX_PAGE_SIZE`](./miscellaneous.md#max_page_size) diff --git a/docs/configuration/miscellaneous.md b/docs/configuration/miscellaneous.md index 8550564d8..d3d1d12c3 100644 --- a/docs/configuration/miscellaneous.md +++ b/docs/configuration/miscellaneous.md @@ -87,14 +87,16 @@ Setting this to False will disable the GraphQL API. --- -## JOBRESULT_RETENTION +## JOB_RETENTION !!! tip "Dynamic Configuration Parameter" +!!! note + This parameter was renamed from `JOBRESULT_RETENTION` in NetBox v3.5. + Default: 90 -The number of days to retain job results (scripts and reports). Set this to `0` to retain -job results in the database indefinitely. +The number of days to retain job results (scripts and reports). Set this to `0` to retain job results in the database indefinitely. !!! warning If enabling indefinite job results retention, it is recommended to periodically delete old entries. Otherwise, the database may eventually exceed capacity. diff --git a/netbox/extras/admin.py b/netbox/extras/admin.py index a6e8007fb..04a67b521 100644 --- a/netbox/extras/admin.py +++ b/netbox/extras/admin.py @@ -39,7 +39,7 @@ class ConfigRevisionAdmin(admin.ModelAdmin): 'fields': ('DEFAULT_USER_PREFERENCES',), }), ('Miscellaneous', { - 'fields': ('MAINTENANCE_MODE', 'GRAPHQL_ENABLED', 'CHANGELOG_RETENTION', 'JOBRESULT_RETENTION', 'MAPS_URL'), + 'fields': ('MAINTENANCE_MODE', 'GRAPHQL_ENABLED', 'CHANGELOG_RETENTION', 'JOB_RETENTION', 'MAPS_URL'), }), ('Config Revision', { 'fields': ('comment',), diff --git a/netbox/extras/management/commands/housekeeping.py b/netbox/extras/management/commands/housekeeping.py index bc3818ce2..467518fef 100644 --- a/netbox/extras/management/commands/housekeeping.py +++ b/netbox/extras/management/commands/housekeeping.py @@ -67,10 +67,10 @@ class Command(BaseCommand): # Delete expired Jobs if options['verbosity']: self.stdout.write("[*] Checking for expired jobs") - if config.JOBRESULT_RETENTION: - cutoff = timezone.now() - timedelta(days=config.JOBRESULT_RETENTION) + if config.JOB_RETENTION: + cutoff = timezone.now() - timedelta(days=config.JOB_RETENTION) if options['verbosity'] >= 2: - self.stdout.write(f"\tRetention period: {config.JOBRESULT_RETENTION} days") + self.stdout.write(f"\tRetention period: {config.JOB_RETENTION} days") self.stdout.write(f"\tCut-off time: {cutoff}") expired_records = Job.objects.filter(created__lt=cutoff).count() if expired_records: @@ -88,7 +88,7 @@ class Command(BaseCommand): self.stdout.write("\tNo expired records found.", self.style.SUCCESS) elif options['verbosity']: self.stdout.write( - f"\tSkipping: No retention period specified (JOBRESULT_RETENTION = {config.JOBRESULT_RETENTION})" + f"\tSkipping: No retention period specified (JOB_RETENTION = {config.JOB_RETENTION})" ) # Check for new releases (if enabled) diff --git a/netbox/netbox/config/parameters.py b/netbox/netbox/config/parameters.py index 8efb0a033..2bfa234f0 100644 --- a/netbox/netbox/config/parameters.py +++ b/netbox/netbox/config/parameters.py @@ -214,7 +214,7 @@ PARAMS = ( field=forms.IntegerField ), ConfigParam( - name='JOBRESULT_RETENTION', + name='JOB_RETENTION', label=_('Job result retention'), default=90, description=_("Days to retain job result history (set to zero for unlimited)"),