dbadmin interface sets incorrect hostname on all telegraf subordinates

Bug #1775062 reported by Shane Peters
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Telegraf Charm
Fix Released
Medium
Alvaro Uria

Bug Description

When using the mysql:dbadmin interface to have telegraf poll mysql-specific metrics, the hostname across other telegraf subordinates changes to 'mysql/x'.

The issue lies in get_remote_unit_name which returns the unit_name for the first relation found, without confirming it's for that specific unit.

This is due to the removal of a test which used the IP address determine the correct unit.
https://git.launchpad.net/telegraf-charm/commit/?id=2920829b8dc4671c0685c86d575a639833ec699c

From a debug session, we can see that the 'mysql' relation will be tested before the juju-info relation and will the return the mysql unit name:

(Pdb) hookenv.metadata()['requires'].keys()
dict_keys(['exec', 'haproxy', 'apache', 'mysql', 'postgresql', 'influxdb-api', 'juju-info', 'mongodb', 'elasticsearch', 'memcached'])

The workaround here is to remove the mysql:dbadmin relation.

Tags: sts

Related branches

Shane Peters (shaner)
description: updated
Revision history for this message
Alvaro Uria (aluria) wrote :

Shane, my bad

It looks I didn't understand correctly the following:
"""
rels = hookenv.relations_of_type(rel_type)
"""

However, my quick test works as I expected:
"""
juju deploy ubuntu --to lxd:0
juju deploy mysql --to lxd:1
juju deploy telegraf

juju add-relation ubuntu telegraf:juju-info
juju add-relation mysql:db-admin telegraf:mysql
juju add-relation mysql:juju-info telegraf:juju-info
"""

"juju status --format yaml" shows
https://pastebin.ubuntu.com/p/KPQvMfgbgc/

And the "host" label in the /metrics page is:
"""
$ juju machines | egrep -o '([0-9]+\.){3}[0-9]+' | xargs -I@ bash -xc 'curl -s @:9103/metrics | egrep -o "host=\"[^\"]+\"" | sort -u'
+ curl -s 10.66.111.122:9103/metrics
+ egrep -o 'host="[^"]+"'
+ sort -u
host="tgraf:ubuntu-0"
+ curl -s 10.66.111.200:9103/metrics
+ egrep -o 'host="[^"]+"'
+ sort -u
host="tgraf:mysql-0"

"""
Note: "tgraf" is the model name

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

From the above, I understand:
* ubuntu unit has rel['unit-name'] = 'ubuntu-0'
* mysql unit, not matter the type of relation, has rel['unit-name'] = 'mysql-0'

Could you please provide a way to reproduce the issue? Thank you!

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

I see now:

juju debug-hooks telegraf/2 # in another terminal, run juju run --unit telegraf/2 hoosk/update-status
"""
>>> from charmhelpers.core import hookenv
>>> hookenv.metadata()['requires'].keys()
dict_keys(['elasticsearch', 'juju-info', 'haproxy', 'memcached', 'apache', 'influxdb-api', 'postgresql', 'exec', 'mysql', 'mongodb'])
>>> hookenv.relations_of_type('juju-info')
[{'egress-subnets': '10.66.111.139/32', 'private-address': '10.66.111.139', 'ingress-address': '10.66.111.139', '__relid__': 'juju-info:4', '__unit__': 'ubuntu-lxd/0'}]
>>> hookenv.relations_of_type('mysql')
[{'egress-subnets': '10.66.111.200/32', 'private-address': '10.66.111.200', 'ingress-address': '10.66.111.200', '__relid__': 'mysql:3', 'database': 'telegraf', 'password': 'lai7Uo6uKahquai', 'slave': 'False', 'user': 'quoh3JiG8ahchuu', 'host': '10.66.111.200', '__unit__': 'mysql/0'}]
"""

I didn't expect hookenv.relations_of_type(...) to return units which the current telegraf unit is not subordinate of.

I'll work on a patch

Changed in telegraf-charm:
importance: Undecided → Medium
assignee: nobody → Alvaro Uría (aluria)
Revision history for this message
Shane Peters (shaner) wrote :

Thanks Alvaro!

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

Fix has been reviewed and released to the charm store. cs:telegraf-14.

Changed in telegraf-charm:
status: New → Fix Released
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.