From 4a6081fc58f9ce3be69af039f1115ee98a3aff68 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 27 Sep 2014 11:31:37 +0100 Subject: [PATCH] add expire_jobs and set default expire times --- Netdisco/Changes | 11 +++++++++++ .../App/Netdisco/Daemon/Worker/Poller/Expiry.pm | 9 +++++++++ Netdisco/lib/App/Netdisco/Manual/Configuration.pod | 14 +++++++++++--- Netdisco/share/config.yml | 7 ++++--- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 6404d954..75b64f27 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,3 +1,14 @@ +2.029009 - 2014-09-27 + + [ENHANCEMENTS] + + * Defaults now exist for all expire tasks + * Added expire_jobs to remove jobs queue items after 14 days + + [BUG FIXES] + + * Require new DBIC version to fix duplicate DB connection problem + 2.029008 - 2014-09-23 [ENHANCEMENTS] diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Expiry.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Expiry.pm index 2741907d..01d82d4a 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Expiry.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Expiry.pm @@ -40,6 +40,15 @@ sub expire { }); } + if (setting('expire_jobs') and setting('expire_jobs') > 0) { + schema('netdisco')->txn_do(sub { + schema('netdisco')->resultset('Admin')->search({ + entered => \[q/< (now() - ?::interval)/, + (setting('expire_jobs') * 86400)], + })->delete(); + }); + } + return job_done("Checked expiry for all Devices and Nodes"); } diff --git a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod index b9578d99..36b8e235 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod @@ -724,14 +724,14 @@ seconds as well as integers. =head3 C -Value: Number of Days. +Value: Number of Days. Default: 60 Devices that have not been refreshed in this number of days will be removed. All nodes connected to this device will be removed as well. =head3 C -Value: Number of Days. +Value: Number of Days. Default: 90 Nodes that have not been refreshed in this number of days will be removed from the database. Archived and non-archived nodes are removed. This includes @@ -739,11 +739,19 @@ SwitchPort/MAC and MAC/IP mappings. =head3 C -Value: Number of Days. +Value: Number of Days. Default: 60 Archived data for switch-port/MAC and MAC/IP mappings older than this number of days will be removed. +=head3 C + +Value: Number of Days. Default: 14 + +Jobs which entered the job queue more than this many days ago will be removed +from the queue during the scheduled expiry process (regardless of whether they +were ever run). + =head3 C Value: Settings Tree. Default: diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index 019caae8..7e14a201 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -130,9 +130,10 @@ nbtstat_only: [] nbtstat_max_age: 7 nbtstat_interval: 0.02 nbtstat_timeout: 1 -expire_devices: 0 -expire_nodes: 0 -expire_nodes_archive: 0 +expire_devices: 60 +expire_nodes: 90 +expire_nodes_archive: 60 +expire_jobs: 14 store_wireless_clients: true store_modules: true ignore_interfaces: