Add periodic cleanup of log files

When images are removed and no longer being built, their log files
hang around forever.  Add a simple cron job to clean them up after 7
days, but hide it behind a default-off flag just in case people really
want their old logs.

Change-Id: Iee55717bc5fbf88d739a4124f62f76d193cf3b75
This commit is contained in:
Ian Wienand 2016-02-04 09:57:23 +11:00
parent bb12dbb646
commit 923778ff19
1 changed files with 13 additions and 0 deletions

View File

@ -26,6 +26,7 @@ class nodepool (
$statsd_host = undef,
$vhost_name = $::fqdn,
$image_log_document_root = '/var/log/nodepool/image',
$image_log_periodic_cleanup = false,
$enable_image_log_via_http = false,
$environment = {},
# enable sudo for nodepool user. Useful for using dib with nodepool
@ -303,6 +304,18 @@ class nodepool (
}
}
# run a cleanup on the image log directory to cleanup logs for
# images that are no longer being built
if $image_log_periodic_cleanup == true {
cron { 'image_log_cleanup':
user => 'nodepool',
hour => '1',
minute => '0',
command => "find ${image_log_document_root} -name '*.log' -mtime +7 -execdir rm {} \\;",
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
}
}
if $sudo == true {
$sudo_file_ensure = present
}