Trouble with mysql-shared interface


I am new to Juju and I’ve been trying to build a charm using the mysql-shared interface and the reactive framework. The database.connected flag is being by the interface, but I’ve been unsuccessful in getting the database.available flag to trigger.

To isolate the problem I’ve simplified the charm as much as I could here.

Could anyone tell me what I am doing wrong?


@cory_fu would have a lot more to offer than me, but my feedback would be:

  1. I think you want to use the “mysql” interface
  2. Are you trying to write a charm that consumes a mysql database? It looks like it since your metadata.yaml declares that the charm requires mysql. But the configure_database() reactive code looks like it’s cribbed from a charm which provides mysql.
  3. Generally, the use of unit_get() is not advisable if you want the charm to be cross model relations aware. Use network_info() instead.

Here’s a link to some doc which gives an example of writing a charm which consumes mysql.

Please ask again if the doc link doesn’t help or anything is unclear. Cory may be able to provide additional material to help you get started.


I get the same result as @tyler when I build his example and relate it to mysql/percona-cluster. The database.available flag is never set.


The mysql interface is giving me better results so far, thanks!


Just to clarify, the mysql-shared interface is intended to be used when the charm needs a database that can be shared across multiple applications, or if the application needs the database to have a specific name instead of getting a randomly generated database name. In that context, the configure call is actually correct, in that it is required to inform the database of the desired name and other admin info.

As far as I could tell, the usage was correct, so it seems like there was a bug in the database charm being connected to, or in the interface layer. You might try with one of the other charms that provide that relation interface, such as MariaDB, Percona Cluster, or Galera Cluster.

But, if you don’t need the named database functionality, then the plain mysql interface is fine to use instead.


@tyler See Cory’s reply. Apologies for my misinformation about the use of the mysql-shared interface. I’ve only ever used the plain mysql interface before so clearly was not aware of how the shared interface was to work.


To me it seems that the interface is being used just like the example in the readme for MySQL-shared and it is not setting the correct flag. Am I missing something? I’ve been debugging this stupid little thing trying to get it to work with no luck.


I think I may have isolated the issue.

When configuring the database for the shared relation, passing prefix='mysql_test' results in the database.available flag never being set, but prefix='mysqltest' works fine. This was when relating it to the percona-cluster charm. No idea why the underscore should matter but it seems it does.

I’ve pushed two charms to the charm store to help with debugging, cs:~tscheuble/mysql-test-working and cs:~tscheuble/mysql-test-broken. There should only be the one character different between them.
EDIT: Unfortunately there are some issues with these charms. I’ll try to get them working tomorrow.