Merge ~sajoupa/charm-telegraf:plugins-when-telegraf-installed into charm-telegraf:master

Proposed by Laurent Sesquès
Status: Merged
Approved by: Alvaro Uria
Approved revision: f7faae92b7a93ab687ea57e1be771687a9712d67
Merged at revision: ee1a92f9c0787413dea69a9a8c0d08a111a2d4be
Proposed branch: ~sajoupa/charm-telegraf:plugins-when-telegraf-installed
Merge into: charm-telegraf:master
Diff against target: 108 lines (+13/-0)
1 file modified
src/reactive/telegraf.py (+13/-0)
Reviewer Review Type Date Requested Status
Alvaro Uria (community) Approve
Tom Haddon Approve
Review via email: mp+388652@code.launchpad.net

Commit message

wait for telegraf to be installed before configuring plugins

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
Laurent Sesquès (sajoupa) wrote :

On an existing unit with configured extra plugins in telegraf.d/, switching from the deb install to the snap, the charm will try to write to /var/snap/telegraf/current/telegraf.d before the snap is installed, leading to e.g.:
FileNotFoundError: [Errno 2] No such file or directory: '/var/snap/telegraf/current/telegraf.d/haproxy.conf'

This patched fixes it by waiting for telegraf to be installed before configuring extra plugins.

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

(successfully passed `make test`)

Revision history for this message
Tom Haddon (mthaddon) wrote :

LGTM, thx

review: Approve
Revision history for this message
Alvaro Uria (aluria) wrote :

Change looks good (no missing @when state in other functions). However, since the MP was proposed, the charm has been restructured and reactive/telegraf.py is now located in src/reactive/telegraf.py. Sorry for that. Could you rebase it against master so I can run the same "make test" you did and approve it?

Thank you.

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

Rebased, replaced single quotes in @when with double quotes, and passed `make test`.

Revision history for this message
Alvaro Uria (aluria) wrote :

lgtm, thank you

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

Change successfully merged at revision ee1a92f9c0787413dea69a9a8c0d08a111a2d4be

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/reactive/telegraf.py b/src/reactive/telegraf.py
2index 058380c..1b1208e 100644
3--- a/src/reactive/telegraf.py
4+++ b/src/reactive/telegraf.py
5@@ -675,6 +675,7 @@ def configure_extra_plugins():
6
7
8 @when("elasticsearch.available")
9+@when("telegraf.installed")
10 def elasticsearch_input(es):
11 template = """
12 [[inputs.elasticsearch]]
13@@ -705,6 +706,7 @@ def elasticsearch_input(es):
14
15
16 @when("memcached.available")
17+@when("telegraf.installed")
18 def memcached_input(memcache):
19 template = """
20 [[inputs.memcached]]
21@@ -734,6 +736,7 @@ def memcached_input(memcache):
22
23
24 @when("mongodb.database.available")
25+@when("telegraf.installed")
26 def mongodb_input(mongodb):
27 template = """
28 [[inputs.mongodb]]
29@@ -764,6 +767,7 @@ def mongodb_input(mongodb):
30
31
32 @when("mysql.available")
33+@when("telegraf.installed")
34 def mysql_input(mysql):
35 contexts = []
36 for relid, relation in context.Relations()[mysql.relation_name].items():
37@@ -805,6 +809,7 @@ def postgresql_waiting():
38
39
40 @when("postgresql.database.available", "postgresql.database.changed")
41+@when("telegraf.installed")
42 def postgresql_input():
43 # The subordinate may be connected to several services.
44 contexts = []
45@@ -877,6 +882,7 @@ def render_postgresql_tmpl(contexts):
46
47
48 @when("haproxy.available")
49+@when("telegraf.installed")
50 def haproxy_input(haproxy):
51 template = """
52 [[inputs.haproxy]]
53@@ -919,6 +925,7 @@ def haproxy_input(haproxy):
54
55
56 @when("apache.available")
57+@when("telegraf.installed")
58 def apache_input(apache):
59 template = """
60 [[inputs.apache]]
61@@ -960,6 +967,7 @@ def apache_input(apache):
62
63
64 @when("endpoint.redis.available")
65+@when("telegraf.installed")
66 def redis_input(redis):
67 template = """
68 [[inputs.redis]]
69@@ -995,6 +1003,7 @@ def redis_input(redis):
70
71
72 @when("endpoint.sentry.joined")
73+@when("telegraf.installed")
74 def sentry_input(sentry):
75 template = """
76 [[inputs.statsd]]
77@@ -1024,6 +1033,7 @@ def sentry_input(sentry):
78
79
80 @when("exec.available")
81+@when("telegraf.installed")
82 def exec_input(exec_rel):
83 template = """
84 {% for cmd in commands %}
85@@ -1089,6 +1099,7 @@ def rabbitmq_input_setup(rabbitmq):
86
87
88 @when("amqp.available")
89+@when("telegraf.installed")
90 def rabbitmq_input(rabbitmq):
91 template = """
92 [[inputs.rabbitmq]]
93@@ -1129,6 +1140,7 @@ def rabbitmq_input_departed():
94
95
96 @when("influxdb-api.available")
97+@when("telegraf.installed")
98 def influxdb_api_output(influxdb):
99 required_keys = ["hostname", "port", "user", "password"]
100 rels = hookenv.relations_of_type("influxdb-api")
101@@ -1164,6 +1176,7 @@ def influxdb_api_output(influxdb):
102
103
104 @when("prometheus-client.available")
105+@when("telegraf.installed")
106 def prometheus_client(prometheus):
107 template = """
108 [[outputs.prometheus_client]]

Subscribers

People subscribed via source and target branches

to all changes: