Merge ~tcuthbert/container-log-archive-charm:master into container-log-archive-charm:master

Proposed by Thomas Cuthbert
Status: Merged
Approved by: Thomas Cuthbert
Approved revision: 0d1549693a2ba93018e237cc67b6f89f307ea260
Merged at revision: d46f03a00a338068588e2e00da9304619e4f6f6c
Proposed branch: ~tcuthbert/container-log-archive-charm:master
Merge into: container-log-archive-charm:master
Diff against target: 49 lines (+12/-4)
2 files modified
files/container-log-archive.logrotate (+1/-1)
hooks/hooks.py (+11/-3)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Container Log Archive Charmers Pending
Review via email: mp+388283@code.launchpad.net

Commit message

Ensure that when we install the logrotate config we also initialise the logfile with the correct permissions

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
Stuart Bishop (stub) wrote :

This looks fine.

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

Change successfully merged at revision d46f03a00a338068588e2e00da9304619e4f6f6c

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/files/container-log-archive.logrotate b/files/container-log-archive.logrotate
2index 5dd38b0..ae743eb 100644
3--- a/files/container-log-archive.logrotate
4+++ b/files/container-log-archive.logrotate
5@@ -8,5 +8,5 @@
6 compress
7 notifempty
8 missingok
9- create 0644 root root
10+ create 0664 root log-archive
11 }
12diff --git a/hooks/hooks.py b/hooks/hooks.py
13index 0d36c77..fed7a0c 100755
14--- a/hooks/hooks.py
15+++ b/hooks/hooks.py
16@@ -3,12 +3,13 @@
17 # Copyright 2014 Canonical Ltd. All rights reserved
18 # Author: Chris Stratford <chris.stratford@canonical.com>
19
20-import sys
21-import random
22+import grp
23 import os
24-import stat
25 import os.path
26+import random
27 import shutil
28+import stat
29+import sys
30 import socket
31 import time
32 sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))
33@@ -263,9 +264,16 @@ def deconfigure_nrpe():
34
35
36 def configure_logrotate():
37+ log_path = "/var/log/container-log-archive.log"
38 logrotate_etcdir = "/etc/logrotate.d"
39 logrotate_file = "files/container-log-archive.logrotate"
40 logrotate_path = os.path.join(logrotate_etcdir, "container-log-archive")
41+ # Initialise the log file with the correct permissions
42+ with open(log_path, "w"):
43+ pass
44+ os.chmod(log_path, "0o664")
45+ gid = grp.getgrgid("log-archive")
46+ os.chown(log_path, "root", gid)
47 try:
48 shutil.copyfile(logrotate_file, logrotate_path)
49 except OSError as e:

Subscribers

People subscribed via source and target branches