Merge lp:~hloeung/ubuntu-repository-cache/squid-logrotate into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 303
Merged at revision: 300
Proposed branch: lp:~hloeung/ubuntu-repository-cache/squid-logrotate
Merge into: lp:ubuntu-repository-cache
Diff against target: 162 lines (+89/-39)
5 files modified
lib/ubuntu_repository_cache/service.py (+9/-7)
templates/logrotate/apache2-logrotate.conf.tmpl (+21/-32)
templates/logrotate/squid-deb-proxy-logrotate.conf.tmpl (+24/-0)
templates/logrotate/squid-logrotate.conf.tmpl (+21/-0)
templates/logrotate/ubuntu-repository-sync-logrotate.conf.tmpl (+14/-0)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/squid-logrotate
Reviewer Review Type Date Requested Status
Barry Price Approve
Canonical IS Reviewers Pending
Review via email: mp+397202@code.launchpad.net

Commit message

Fix squid/squid-deb-proxy log retention - LP:1912131

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Barry Price (barryprice) wrote :

LGTM +1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 300

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/ubuntu_repository_cache/service.py'
2--- lib/ubuntu_repository_cache/service.py 2020-10-13 04:38:51 +0000
3+++ lib/ubuntu_repository_cache/service.py 2021-02-01 02:01:01 +0000
4@@ -247,13 +247,15 @@
5 squid.render_configs()
6
7 # Log file rotation
8- logrotate_filename = '/etc/logrotate.d/apache2'
9- logrotate_context = {
10- 'logrotate_rotate': config['logrotate_rotate'],
11- 'logrotate_count': config['logrotate_count'],
12- 'logrotate_dateext': config['logrotate_dateext'],
13- }
14- templating.render('logrotate/logrotate.conf.template', logrotate_filename, logrotate_context, perms=0o644)
15+ for service in ['apache2', 'squid', 'squid-deb-proxy', 'ubuntu-repository-sync']:
16+ logrotate_filename = '/etc/logrotate.d/{}'.format(service)
17+ logrotate_template = 'logrotate/{}-logrotate.conf.tmpl'.format(service)
18+ logrotate_context = {
19+ 'logrotate_rotate': config['logrotate_rotate'],
20+ 'logrotate_count': config['logrotate_count'],
21+ 'logrotate_dateext': config['logrotate_dateext'],
22+ }
23+ templating.render(logrotate_template, logrotate_filename, logrotate_context, perms=0o644)
24
25 if not os.path.exists(CONFIG_DIR):
26 host.mkdir(CONFIG_DIR)
27
28=== renamed file 'templates/logrotate/logrotate.conf.template' => 'templates/logrotate/apache2-logrotate.conf.tmpl'
29--- templates/logrotate/logrotate.conf.template 2020-10-13 03:41:08 +0000
30+++ templates/logrotate/apache2-logrotate.conf.tmpl 2021-02-01 02:01:01 +0000
31@@ -1,36 +1,25 @@
32 # This file is managed by Juju. Do not make local changes
33
34 /var/log/apache2/*.log {
35- {{ logrotate_rotate }}
36-{%- if logrotate_dateext %}
37- dateext
38-{%- endif %}
39- missingok
40- rotate {{ logrotate_count }}
41- compress
42- delaycompress
43- notifempty
44- create 640 root adm
45- sharedscripts
46- postrotate
47- /etc/init.d/apache2 reload > /dev/null
48- endscript
49- prerotate
50- if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
51- run-parts /etc/logrotate.d/httpd-prerotate; \
52- fi; \
53- endscript
54-}
55-
56-/var/log/repository-sync/repository-sync-cron.log {
57- {{ logrotate_rotate }}
58-{%- if logrotate_dateext %}
59- dateext
60-{%- endif %}
61- rotate {{ logrotate_count }}
62- missingok
63- compress
64- delaycompress
65- notifempty
66- create 640 www-sync adm
67+ {{ logrotate_rotate }}
68+{%- if logrotate_dateext %}
69+ dateext
70+{%- endif %}
71+ missingok
72+ rotate {{ logrotate_count }}
73+ compress
74+ delaycompress
75+ notifempty
76+ create 640 root adm
77+ sharedscripts
78+ postrotate
79+ if invoke-rc.d apache2 status > /dev/null 2>&1; then \
80+ invoke-rc.d apache2 reload > /dev/null 2>&1; \
81+ fi;
82+ endscript
83+ prerotate
84+ if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
85+ run-parts /etc/logrotate.d/httpd-prerotate; \
86+ fi; \
87+ endscript
88 }
89
90=== added file 'templates/logrotate/squid-deb-proxy-logrotate.conf.tmpl'
91--- templates/logrotate/squid-deb-proxy-logrotate.conf.tmpl 1970-01-01 00:00:00 +0000
92+++ templates/logrotate/squid-deb-proxy-logrotate.conf.tmpl 2021-02-01 02:01:01 +0000
93@@ -0,0 +1,24 @@
94+# This file is managed by Juju. Do not make local changes
95+
96+/var/log/squid-deb-proxy/*.log {
97+ {{ logrotate_rotate }}
98+{%- if logrotate_dateext %}
99+ dateext
100+{%- endif %}
101+ missingok
102+ rotate {{ logrotate_count }}
103+ compress
104+ delaycompress
105+ nocreate
106+ sharedscripts
107+ postrotate
108+ if [ -x /usr/sbin/squid ]; then
109+ SQUID=/usr/sbin/squid
110+ else
111+ echo "No squid binary found"
112+ exit 1
113+ fi
114+
115+ test ! -e /var/run/squid-deb-proxy.pid || $SQUID -f /etc/squid-deb-proxy/squid-deb-proxy.conf -k rotate
116+ endscript
117+}
118
119=== added file 'templates/logrotate/squid-logrotate.conf.tmpl'
120--- templates/logrotate/squid-logrotate.conf.tmpl 1970-01-01 00:00:00 +0000
121+++ templates/logrotate/squid-logrotate.conf.tmpl 2021-02-01 02:01:01 +0000
122@@ -0,0 +1,21 @@
123+# This file is managed by Juju. Do not make local changes
124+
125+/var/log/squid/*.log {
126+ {{ logrotate_rotate }}
127+{%- if logrotate_dateext %}
128+ dateext
129+{%- endif %}
130+ missingok
131+ rotate {{ logrotate_count }}
132+ compress
133+ delaycompress
134+ notifempty
135+ nocreate
136+ sharedscripts
137+ prerotate
138+ test ! -x /usr/sbin/sarg-reports || /usr/sbin/sarg-reports daily
139+ endscript
140+ postrotate
141+ test ! -e /var/run/squid.pid || test ! -x /usr/sbin/squid || /usr/sbin/squid -k rotate
142+ endscript
143+}
144
145=== added file 'templates/logrotate/ubuntu-repository-sync-logrotate.conf.tmpl'
146--- templates/logrotate/ubuntu-repository-sync-logrotate.conf.tmpl 1970-01-01 00:00:00 +0000
147+++ templates/logrotate/ubuntu-repository-sync-logrotate.conf.tmpl 2021-02-01 02:01:01 +0000
148@@ -0,0 +1,14 @@
149+# This file is managed by Juju. Do not make local changes
150+
151+/var/log/repository-sync/repository-sync-cron.log {
152+ {{ logrotate_rotate }}
153+{%- if logrotate_dateext %}
154+ dateext
155+{%- endif %}
156+ rotate {{ logrotate_count }}
157+ missingok
158+ compress
159+ delaycompress
160+ notifempty
161+ create 640 www-sync adm
162+}

Subscribers

People subscribed via source and target branches