cannot modify prometheus_client.listen via extra_options

Bug #1977920 reported by Paul Collins
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Telegraf Charm
New
Undecided
Unassigned

Bug Description

The charm tries to allow modifying outputs.prometheus_client.listen via the extra_options setting: https://git.launchpad.net/charm-telegraf/tree/src/reactive/telegraf.py?h=stable/21.10#n1536

However, when I tried this, using the following command:

juju config telegraf extra_options='outputs:
    prometheus_client:
      listen: 10.131.59.185:9103'

The charm crashed as follows:

2022-06-08 04:42:12 WARNING config-changed File "/var/lib/juju/agents/unit-ubuntu-torrent-telegraf-0/charm/reactive/telegraf.py", line 1630, in generate_prometheus_output_config
2022-06-08 04:42:12 WARNING config-changed elif int(listen.split(":", 1)[1]) != prometheus_output_port:
2022-06-08 04:42:12 WARNING config-changed ValueError: invalid literal for int() with base 10: '9103"'

(Note the double-quote character after the four digit characters of 9103.)

This seems to be due to get_extra_configs's "JSONification": https://git.launchpad.net/charm-telegraf/tree/src/reactive/telegraf.py?h=stable/21.10#n489

You can see below that `json.dumps` does indeed wrap the value in quotes:

>>> import json, yaml
>>> x = '''outputs:
... prometheus_client:
... listen: 10.131.59.185:9103
... '''
>>> y = yaml.full_load(x)
>>> y
{'outputs': {'prometheus_client': {'listen': '10.131.59.185:9103'}}}
>>> print(y['outputs']['prometheus_client']['listen'])
10.131.59.185:9103
>>> print(json.dumps(y['outputs']['prometheus_client']['listen']))
"10.131.59.185:9103"
>>> _

This deployment is kind of weird, hence this weird configuration, but it would useful if it worked as it would allow me to get rid of some potentially expensive iptables on a high-traffic service.

Paul Collins (pjdc)
summary: - cannot modify prometheus_client.listen via extra_configs
+ cannot modify prometheus_client.listen via extra_options
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.