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
diff --git a/src/reactive/telegraf.py b/src/reactive/telegraf.py
index 058380c..1b1208e 100644
--- a/src/reactive/telegraf.py
+++ b/src/reactive/telegraf.py
@@ -675,6 +675,7 @@ def configure_extra_plugins():
675675
676676
677@when("elasticsearch.available")677@when("elasticsearch.available")
678@when("telegraf.installed")
678def elasticsearch_input(es):679def elasticsearch_input(es):
679 template = """680 template = """
680[[inputs.elasticsearch]]681[[inputs.elasticsearch]]
@@ -705,6 +706,7 @@ def elasticsearch_input(es):
705706
706707
707@when("memcached.available")708@when("memcached.available")
709@when("telegraf.installed")
708def memcached_input(memcache):710def memcached_input(memcache):
709 template = """711 template = """
710[[inputs.memcached]]712[[inputs.memcached]]
@@ -734,6 +736,7 @@ def memcached_input(memcache):
734736
735737
736@when("mongodb.database.available")738@when("mongodb.database.available")
739@when("telegraf.installed")
737def mongodb_input(mongodb):740def mongodb_input(mongodb):
738 template = """741 template = """
739[[inputs.mongodb]]742[[inputs.mongodb]]
@@ -764,6 +767,7 @@ def mongodb_input(mongodb):
764767
765768
766@when("mysql.available")769@when("mysql.available")
770@when("telegraf.installed")
767def mysql_input(mysql):771def mysql_input(mysql):
768 contexts = []772 contexts = []
769 for relid, relation in context.Relations()[mysql.relation_name].items():773 for relid, relation in context.Relations()[mysql.relation_name].items():
@@ -805,6 +809,7 @@ def postgresql_waiting():
805809
806810
807@when("postgresql.database.available", "postgresql.database.changed")811@when("postgresql.database.available", "postgresql.database.changed")
812@when("telegraf.installed")
808def postgresql_input():813def postgresql_input():
809 # The subordinate may be connected to several services.814 # The subordinate may be connected to several services.
810 contexts = []815 contexts = []
@@ -877,6 +882,7 @@ def render_postgresql_tmpl(contexts):
877882
878883
879@when("haproxy.available")884@when("haproxy.available")
885@when("telegraf.installed")
880def haproxy_input(haproxy):886def haproxy_input(haproxy):
881 template = """887 template = """
882[[inputs.haproxy]]888[[inputs.haproxy]]
@@ -919,6 +925,7 @@ def haproxy_input(haproxy):
919925
920926
921@when("apache.available")927@when("apache.available")
928@when("telegraf.installed")
922def apache_input(apache):929def apache_input(apache):
923 template = """930 template = """
924[[inputs.apache]]931[[inputs.apache]]
@@ -960,6 +967,7 @@ def apache_input(apache):
960967
961968
962@when("endpoint.redis.available")969@when("endpoint.redis.available")
970@when("telegraf.installed")
963def redis_input(redis):971def redis_input(redis):
964 template = """972 template = """
965[[inputs.redis]]973[[inputs.redis]]
@@ -995,6 +1003,7 @@ def redis_input(redis):
9951003
9961004
997@when("endpoint.sentry.joined")1005@when("endpoint.sentry.joined")
1006@when("telegraf.installed")
998def sentry_input(sentry):1007def sentry_input(sentry):
999 template = """1008 template = """
1000[[inputs.statsd]]1009[[inputs.statsd]]
@@ -1024,6 +1033,7 @@ def sentry_input(sentry):
10241033
10251034
1026@when("exec.available")1035@when("exec.available")
1036@when("telegraf.installed")
1027def exec_input(exec_rel):1037def exec_input(exec_rel):
1028 template = """1038 template = """
1029{% for cmd in commands %}1039{% for cmd in commands %}
@@ -1089,6 +1099,7 @@ def rabbitmq_input_setup(rabbitmq):
10891099
10901100
1091@when("amqp.available")1101@when("amqp.available")
1102@when("telegraf.installed")
1092def rabbitmq_input(rabbitmq):1103def rabbitmq_input(rabbitmq):
1093 template = """1104 template = """
1094[[inputs.rabbitmq]]1105[[inputs.rabbitmq]]
@@ -1129,6 +1140,7 @@ def rabbitmq_input_departed():
11291140
11301141
1131@when("influxdb-api.available")1142@when("influxdb-api.available")
1143@when("telegraf.installed")
1132def influxdb_api_output(influxdb):1144def influxdb_api_output(influxdb):
1133 required_keys = ["hostname", "port", "user", "password"]1145 required_keys = ["hostname", "port", "user", "password"]
1134 rels = hookenv.relations_of_type("influxdb-api")1146 rels = hookenv.relations_of_type("influxdb-api")
@@ -1164,6 +1176,7 @@ def influxdb_api_output(influxdb):
11641176
11651177
1166@when("prometheus-client.available")1178@when("prometheus-client.available")
1179@when("telegraf.installed")
1167def prometheus_client(prometheus):1180def prometheus_client(prometheus):
1168 template = """1181 template = """
1169[[outputs.prometheus_client]]1182[[outputs.prometheus_client]]

Subscribers

People subscribed via source and target branches

to all changes: