Merge ~ines-almeida/txpkgupload:add-logrotate-to-charm into txpkgupload:master

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: bd27ec4d9213eba876c60f08333dc979ade37e5d
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/txpkgupload:add-logrotate-to-charm
Merge into: txpkgupload:master
Diff against target: 50 lines (+26/-0)
2 files modified
charm/txpkgupload/reactive/txpkgupload.py (+11/-0)
charm/txpkgupload/templates/logrotate.conf.j2 (+15/-0)
Reviewer Review Type Date Requested Status
Colin Watson Approve
Simone Pelosi Approve
Review via email: mp+449426@code.launchpad.net

Commit message

Add logrotate to txpkgupload charm

This is based on the logrotate files in ppa.lp.internal in production

To post a comment you must log in.
Revision history for this message
Simone Pelosi (pelpsi) wrote :

LGTM!

review: Approve
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charm/txpkgupload/reactive/txpkgupload.py b/charm/txpkgupload/reactive/txpkgupload.py
2index 2ec1e90..a8a5b66 100644
3--- a/charm/txpkgupload/reactive/txpkgupload.py
4+++ b/charm/txpkgupload/reactive/txpkgupload.py
5@@ -19,6 +19,16 @@ from charms.reactive import (
6 from ols import base
7
8
9+def configure_logrotate(config):
10+ hookenv.log("Writing logrotate configuration.")
11+ templating.render(
12+ "logrotate.conf.j2",
13+ "/etc/logrotate.d/txpkgupload",
14+ config,
15+ perms=0o644,
16+ )
17+
18+
19 def create_virtualenv(wheels_dir, codedir, python_exe):
20 hookenv.log("Creating virtualenv for txpkgupload charm")
21 subprocess.check_call(
22@@ -131,6 +141,7 @@ def configure_txpkgupload(config: Dict):
23 "/lib/systemd/system/txpkgupload.socket",
24 config
25 )
26+ configure_logrotate(config)
27
28 hookenv.log("Starting txpkgupload")
29 subprocess.check_call(["systemctl", "daemon-reload"])
30diff --git a/charm/txpkgupload/templates/logrotate.conf.j2 b/charm/txpkgupload/templates/logrotate.conf.j2
31new file mode 100644
32index 0000000..9d82965
33--- /dev/null
34+++ b/charm/txpkgupload/templates/logrotate.conf.j2
35@@ -0,0 +1,15 @@
36+{{ logs_dir }}/*.log
37+{
38+ rotate 90
39+ daily
40+ dateext
41+ delaycompress
42+ compress
43+ notifempty
44+ missingok
45+ create 0664 txpkgupload txpkgupload
46+ sharedscripts
47+ postrotate
48+ systemctl reload txpkgupload.service
49+ endscript
50+}

Subscribers

People subscribed via source and target branches

to all changes: