Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

puppet: Rotate access log files every day, not at 500M.

Alex Vandiver7c023042cfbb
diff --git a/docs/production/deployment.md b/docs/production/deployment.md
index f761c03a06a..a036990c022 100644
--- a/docs/production/deployment.md
+++ b/docs/production/deployment.md
@@ -791,6 +791,11 @@ Override the default uwsgi backlog of 128 connections.
Override the default `uwsgi` (Django) process count of 6 on hosts with
more than 3.5GiB of RAM, 4 on hosts with less.
+#### `access_log_retention_days`
+
+Number of days of access logs to keep, for both nginx and the application.
+Defaults to 14 days.
+
### `[postfix]`
#### `mailname`
diff --git a/puppet/zulip/manifests/nginx.pp b/puppet/zulip/manifests/nginx.pp
index d2743fb2f6b..d6115c8cf17 100644
--- a/puppet/zulip/manifests/nginx.pp
+++ b/puppet/zulip/manifests/nginx.pp
@@ -76,13 +76,14 @@ class zulip::nginx {
group => 'adm',
mode => '0750',
}
+ $access_log_retention_days = zulipconf('application_server','access_log_retention_days', 14)
file { '/etc/logrotate.d/nginx':
ensure => file,
require => Package[$zulip::common::nginx],
owner => 'root',
group => 'root',
mode => '0644',
- source => 'puppet:///modules/zulip/logrotate/nginx',
+ content => template('zulip/logrotate/nginx.template.erb'),
}
package { 'certbot':
ensure => installed,
diff --git a/puppet/zulip/manifests/profile/app_frontend.pp b/puppet/zulip/manifests/profile/app_frontend.pp
index 42242a4fffc..e82ff71d0ca 100644
--- a/puppet/zulip/manifests/profile/app_frontend.pp
+++ b/puppet/zulip/manifests/profile/app_frontend.pp
@@ -23,12 +23,13 @@ class zulip::profile::app_frontend {
content => template('zulip/nginx/zulip-enterprise.template.erb'),
notify => Service['nginx'],
}
+ $access_log_retention_days = zulipconf('application_server','access_log_retention_days', 14)
file { '/etc/logrotate.d/zulip':
- ensure => file,
- owner => 'root',
- group => 'root',
- mode => '0644',
- source => 'puppet:///modules/zulip/logrotate/zulip',
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ content => template('zulip/logrotate/zulip.template.erb'),
}
file { '/etc/nginx/sites-enabled/zulip-enterprise':
ensure => link,
diff --git a/puppet/zulip/files/logrotate/nginx b/puppet/zulip/templates/logrotate/nginx.template.erb
similarity index 88%
rename from puppet/zulip/files/logrotate/nginx
rename to puppet/zulip/templates/logrotate/nginx.template.erb
index ad1d97af54f..052955a529e 100644
--- a/puppet/zulip/files/logrotate/nginx
+++ b/puppet/zulip/templates/logrotate/nginx.template.erb
@@ -1,7 +1,7 @@
/var/log/nginx/*.log {
daily
missingok
- rotate 14
+ rotate <%= @access_log_retention_days %>
compress
delaycompress
notifempty
diff --git a/puppet/zulip/files/logrotate/zulip b/puppet/zulip/templates/logrotate/zulip.template.erb
similarity index 94%
rename from puppet/zulip/files/logrotate/zulip
rename to puppet/zulip/templates/logrotate/zulip.template.erb
index 2858ef1b505..0248291ccaf 100644
--- a/puppet/zulip/files/logrotate/zulip
+++ b/puppet/zulip/templates/logrotate/zulip.template.erb
@@ -32,8 +32,8 @@
/var/log/zulip/server.log
{
missingok
- rotate 10
- size 500M
+ rotate <%= @access_log_retention_days %>
+ daily
compress
delaycompress
notifempty
diff --git a/scripts/log-search b/scripts/log-search
index 2e8297f018f..745b23ee23e 100755
--- a/scripts/log-search
+++ b/scripts/log-search
@@ -25,18 +25,31 @@ from typing import Protocol
from django.conf import settings
-from scripts.lib.zulip_tools import BOLD, CYAN, ENDC, FAIL, GRAY, OKBLUE
+from scripts.lib.zulip_tools import (
+ BOLD,
+ CYAN,
+ ENDC,
+ FAIL,
+ GRAY,
+ OKBLUE,
+ get_config,
+ get_config_file,
+)
def parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="Search logfiles, ignoring commonly-fetched URLs.")
log_selection = parser.add_argument_group("File selection")
log_selection_options = log_selection.add_mutually_exclusive_group()
+ access_log_retention_days = int(
+ get_config(get_config_file(), "application_server", "access_log_retention_days", "14")
+ )
log_selection_options.add_argument(
"--log-files",
"-n",
help="Number of log files to search",
- choices=range(1, 16),
+ choices=range(1, access_log_retention_days + 2),
+ metavar=f"[1-{access_log_retention_days+1}]",
type=int,
)
log_selection_options.add_argument(