Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Working on the postgresql charm a bit, and I'm wondering if there is a way to supply overrides for default values in a "juju-way".

In my charm that will be consuming the services provided by postgresql, I was thinking I could override things like the database name, or the name of the super_user created. If I stick something like this in the relation-joined:

relation-set user=my_superuser

I'm having an issue where the postgres/db-admin-relation-changed can actually run before the consumer joins runs (or finishes running at least).

Eventually, the postgresql/db-admin-relation-changed will run and get my data, but if it runs too quickly, I could wind up with 2 superusers.

TL;DR: Is there a way to guarantee that default configuration is overridden in a service on the provides side of the relationship?

share|improve this question
up vote 3 down vote accepted

There is no way to guarantee which hook runs first in the hook execution scheme, but you can predict which hook series will execute first. When a relation is added the *-relation-joined hooks are fired first (on both services, with no clear winner of who goes first), followed by the *-relation-changed hooks for each service. Since you can't guarantee which of the who hooks in a given relation state will fire first you can trump the relation-changed hook on the Postgres charm by placing your relation-set commands in relation-joined hook in your charm.

This won't work for every charm/relation as it depends on where the heavy lifting is done for each relation. For example, the MySQL charm does all the database creation instructions during the relation-joined hook, so the above wouldn't actually help you achieve anything as you'd still have the race condition.

Ideally unless there's a really good reason using what the postgres charm provides is probably the best way to go.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.