Merge lp:~roadmr/charms/trusty/logstash-forwarder/tunable-spool-size into lp:~canonical-is-sa/charms/trusty/logstash-forwarder/trunk

Proposed by Daniel Manrique
Status: Merged
Approved by: Laurent Sesquès
Approved revision: 25
Merged at revision: 23
Proposed branch: lp:~roadmr/charms/trusty/logstash-forwarder/tunable-spool-size
Merge into: lp:~canonical-is-sa/charms/trusty/logstash-forwarder/trunk
Diff against target: 86 lines (+17/-3)
5 files modified
config.yaml (+5/-0)
hooks/Config.py (+3/-0)
hooks/hooks.py (+1/-0)
templates/etcdefault.tmpl (+1/-1)
tests/10-install-tests (+7/-2)
To merge this branch: bzr merge lp:~roadmr/charms/trusty/logstash-forwarder/tunable-spool-size
Reviewer Review Type Date Requested Status
Laurent Sesquès Approve
Guillermo Gonzalez (community) Approve
Review via email: mp+344184@code.launchpad.net

Commit message

Make logstash-forwarder spool-size parameter tunable via a charm option.

This defaults to the same value the charm used before for backward compatibility.

Description of the change

Make logstash-forwarder spool-size parameter tunable via a charm option.

This defaults to the same value the charm used before for backward compatibility.

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

LGTM

review: Approve
Revision history for this message
Laurent Sesquès (sajoupa) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-11-13 22:39:14 +0000
3+++ config.yaml 2018-04-24 20:10:38 +0000
4@@ -55,6 +55,11 @@
5 is a yaml dict, e.g:
6 servers_name_map: |
7 logstash.devel.canonical.com: ip-of-logstash-or-logstash-haproxy
8+ spool_size:
9+ default: 100
10+ description: >
11+ event count spool threshold - forces network flush
12+ type: int
13 ssl_ca_cert:
14 default: ""
15 type: string
16
17=== modified file 'hooks/Config.py'
18--- hooks/Config.py 2015-10-27 02:28:53 +0000
19+++ hooks/Config.py 2018-04-24 20:10:38 +0000
20@@ -48,6 +48,9 @@
21 def serverPort(self):
22 return self.getConfig("server_port")
23
24+ def spoolSize(self):
25+ return self.getConfig("spool_size")
26+
27 def servers(self):
28 return self.getConfig("servers").split()
29
30
31=== modified file 'hooks/hooks.py'
32--- hooks/hooks.py 2018-04-17 20:14:18 +0000
33+++ hooks/hooks.py 2018-04-24 20:10:38 +0000
34@@ -58,6 +58,7 @@
35 def writeEtcDefault():
36 tmplData = {}
37 tmplData["config_file"] = conf.configFile()
38+ tmplData["spool_size"] = conf.spoolSize()
39 templateFile = os.path.join(charm_dir(), "templates", "etcdefault.tmpl")
40 t = Template(file=templateFile, searchList=tmplData)
41 with open("/etc/default/logstash-forwarder", "w") as f:
42
43=== modified file 'templates/etcdefault.tmpl'
44--- templates/etcdefault.tmpl 2015-05-22 03:31:40 +0000
45+++ templates/etcdefault.tmpl 2018-04-24 20:10:38 +0000
46@@ -2,4 +2,4 @@
47 group="root"
48 chroot="/"
49 chdir="/var/lib/logstash-forwarder"
50-args="-config ${config_file} -spool-size 100"
51+args="-config ${config_file} -spool-size ${spool_size}"
52
53=== modified file 'tests/10-install-tests'
54--- tests/10-install-tests 2018-04-17 20:05:44 +0000
55+++ tests/10-install-tests 2018-04-24 20:10:38 +0000
56@@ -11,6 +11,7 @@
57
58 d.configure("logstash-forwarder", {
59 "files": '{"apache":["/var/log/apache2/*log"]}',
60+ "spool_size": 4242,
61 })
62
63 d.relate('apache2:juju-info', 'logstash-forwarder:juju-info')
64@@ -26,16 +27,20 @@
65 unit = d.sentry['apache2/0']
66
67 # Did the package install ok?
68-# We overwrite the init script, so ignore that one
69+# We overwrite the init script and may modify /etc/default file so ignore those.
70 ret = unit.run("dpkg --verify logstash-forwarder")
71 for line in ret[0].split("\n"):
72- if "init.d" not in line:
73+ if "init.d" not in line and "/etc/default/logstash-forwarder" not in line:
74 amulet.raise_status(amulet.FAIL, msg="logstash-forwarder package failed verification")
75
76 # Do we have an /etc/default file?
77 if "logstash-forwarder" not in unit.directory_contents("/etc/default")["files"]:
78 amulet.raise_status(amulet.FAIL, msg="/etc/default file was not created")
79
80+# Does /etc/default have our custom spool size?
81+if "-spool-size 4242" not in unit.file_contents("/etc/default/logstash-forwarder"):
82+ amulet.raise_status(amulet.FAIL, msg="spool_size config option not honored")
83+
84 # Check the config file
85 cfg = json.loads(unit.file_contents("/etc/logstash-forwarder/logstash-forwarder.conf"))
86 if cfg["files"][0]["paths"][0] != "/var/log/apache2/*log":

Subscribers

People subscribed via source and target branches