Re: database-relation-join not invoked
Hi Giuseppe On Thu, 25 May 2017 at 18:00 Giuseppe Attardiwrote: > 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 -- Juju mailing list Juju@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju
Re: database-relation-join not invoked
It depends if your hook goes into 'error' state or 'blocked'. Error should generally be avoided because it is a signal to Juju that you can no longer make forward progress (generally meant to mean there is a logic bug/typo/etc in your charm). With Error Juju may retry the hook that failed but it will not run other hooks until error is cleared (juju resolved) Using 'status-set blocked [message]' you can report to the user that you are missing a relation, but Juju will continue to fire other hooks as normal. John =:-> On May 25, 2017 21:00, "Giuseppe Attardi"wrote: > I have written a charm for OpenStack Gnocchi. > 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? > > 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 tried with > > db=`relation-get -r database host` > > but it fails with: > > INFO start error: invalid value "database" for flag -r: invalid > relation id > > I am using juju-2.1.2 > > Thanks for the help. > > — Beppe Attardi > -- > Juju mailing list > Juju@lists.ubuntu.com > Modify settings or unsubscribe at: https://lists.ubuntu.com/ > mailman/listinfo/juju > -- Juju mailing list Juju@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju
Re: database-relation-join not invoked
On Thu, May 25, 2017 at 12:59 PM, Giuseppe Attardiwrote: > I have written a charm for OpenStack Gnocchi. > 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 it will. Assuming your relation is named 'database', then the database-relation-joined will be triggered when that relation is established. For more help debugging you may need to post a link to your code. > 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? > You should start the service in the database-relation-changed hook handler, once you have received all necessary relation data. > > I tried with > > db=`relation-get -r database host` > > but it fails with: > > INFO start error: invalid value "database" for flag -r: invalid > relation id > > I am using juju-2.1.2 > > Thanks for the help. > > — Beppe Attardi > -- > Juju mailing list > Juju@lists.ubuntu.com > Modify settings or unsubscribe at: https://lists.ubuntu.com/ > mailman/listinfo/juju > -- Juju mailing list Juju@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju
database-relation-join not invoked
I have written a charm for OpenStack Gnocchi. 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? 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 tried with db=`relation-get -r database host` but it fails with: INFO start error: invalid value "database" for flag -r: invalid relation id I am using juju-2.1.2 Thanks for the help. — Beppe Attardi -- Juju mailing list Juju@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju