Comment 14 for bug 1717590

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote : Re: percona-cluster unit constantly fires hooks, blocks hacluster unit from being setup

Jason, I suspect that having a non-container-scoped relation will generate a lot of unnecessary traffic.

I think we might need to change telegraf's mysql relation scope to "container".

"requires":
  "mysql":
    "interface": "mysql-root"
     "scope": "container"

I pasted "reactive" framework side of it on top which isn't exactly right.

Relation scope is a juju-level not a reactive library level concept:

https://github.com/juju/juju/blob/juju-2.2.4/apiserver/uniter/subordinaterelationwatcher.go#L27-L33
// newSubordinateRelationsWatcher creates a watcher that will notify
// about relation lifecycle events for subordinateApp, but filtered to
// be relevant to a unit deployed to a container with the
// principalName app. Global relations will be included, but only
// container-scoped relations for the principal application will be
// emitted - other container-scoped relations will be filtered out.

https://jujucharms.com/docs/2.2/authors-subordinate-applications
"Principal application: A traditional application or charm in whose container subordinate applications will execute.

Subordinate application/charm: An application designed for and deployed to the running container of another application unit.

Container relation: A scope:container relationship. While modeled identically to traditional, scope: global, relationships, juju only implements the relationship between the units belonging to the same container."

So, we need to make sure that telegraf, while being a subordinate charm (subordinate": "true" in metadata.yaml), also has a proper relation scope for mysql (and pgsql) relation so that mysql-relation-{joined,changed} events are not fired for other telegraf units that do not collect data from mysql and do not reside on the same host.

Just in case, telegraf collects metrics from mysql so a single agent only needs to reside on the same host and talk to a particular mysql instance https://github.com/influxdata/telegraf/tree/master/plugins/inputs/mysql