What could make a relation setting be "forgotten"?

Andreas Hasenack andreas at canonical.com
Thu Jun 6 20:16:22 UTC 2013


On Thu, Jun 6, 2013 at 4:56 PM, Andreas Hasenack <andreas at canonical.com>wrote:

> The postgresql charm has this snipped:
>
> def db_admin_relation_joined_changed(user, database='all'):
>     if not user_exists(user):
>         password = create_user(user, admin=True)
>         run("relation-set user='%s' password='%s'" % (user, password))
>
> I see it being called:
> 2013-06-06 18:35:04 INFO juju server.go:105 worker/uniter/jujuc: running
> hook tool "relation-set" ["user=db_admin_10_landscape_admin"
> "password=33jArfAYrCwQKA4B5QdCj"]
>
> After that, there was a backtrace caused by a bug further down in that
> method. But the user was created in the DB (that's create_user() from the
> snipped above).
>
> To fix the bug I had to issue a few upgrade-charms and resolved --retry.
> The relation-set for user and password was never called again, because the
> user exists in the database already.
>
> But once I got all bugs fixed, via upgrade-charms and resolved --retry,
> the other end of the relation doesn't see user and password.
>
> So, could that first call to relation-set, that worked and created the
> user, somehow have been "forgotten" due to the backtrace in the hook and
> sequence of upgrade-charm and resolved calls? I will debug further in the
> charm, try to reproduce it, etc., but maybe someone knows this already.
>
>
Oh, of course. I see what happened. Since the hook failed, the relation-set
wasn't committed. But the user that was created in the postgresql database
remained there of course, and when the hook finally ran without errors, it
just didn't run relation-set because the user existed already. But the
relation data was never actually set successfully before.



> Thanks!
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20130606/9da53a2a/attachment.html>


More information about the Juju mailing list