database-relation-join not invoked

James Page james.page at ubuntu.com
Fri May 26 13:27:40 UTC 2017


Hi Giuseppe

On Thu, 25 May 2017 at 18:00 Giuseppe Attardi <giuseppe.attardi at garr.it>
wrote:

> I have written a charm for OpenStack Gnocchi.
>

Firstly its great that you've started work on a Gnocchi charm; this is on
the TODO list for the OpenStack Charms project for the current development
cycle and it would be great if we can converge your work with the plans we
already have!


> The service requires a postgresql database relation.
>
> The start hook fails, of course, because the relation is not set.
>
> I expected that, but I expected that when I issue
>
>         juju add-relation gnocchi postgresql:db
>
> it will invoke the database-relation-joined hook, which does set the
> required parameter and then start would work.
> However the hook is not invoked: as a sanity check I set a juju-log
> message in it and it does not run at all.
>
> Is it correct to assume that add-relation will always trigger
> database-relation-join?
>

Yes that is correct; the addition of a unit to a relation will result in
its joined hook being executed.

A second question, I would like to avoid to start the service until the
> relation has been joined.
> What is the best way to test for the relation to be present?
>

I'm also guessing that you'll want to wait until the remote database
application has provided credentials, the database has been synced with a
schema and that you have a full storage backed for metric storage such as
ceph.

This all becomes a whole lot easier by using the reactive charms framework
[0], where each of the dependent sets of configuration (database, ceph,
keystone etc..) would be managed via states; once the state for all of the
datasets is available, its possible to fully configure the service and
start it up.

We also have some templates for 'charm create' which you can use to get you
started with an OpenStack style charm like Gnocchi [1] which will do alot
of the boilerplate installation and configuration for you using the
charms.openstack python module.

If you can I'd suggest you drop into #openstack-charms on Freenode IRC and
we can chat further!

Cheers

James

[0] https://jujucharms.com/docs/stable/developer-layers
[1] https://docs.openstack.org/developer/charm-guide/new-api-charm.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20170526/6a0c12d7/attachment.html>


More information about the Juju mailing list