Hello juju switching to postgresql database example failure

Hello,

new to juju, I tried the ‘Getting started with Juju’ tutorial, but something went wrong at the end :slight_smile:

the juju relate postgresql:db hello-juju command fails with this message : hook failed: "db-relation-changed"

Can someone help ? I don’t know what to do to fix it.

I also see the same error. There seems to be a bug in the hello-juju charm, which I’ve filed as https://github.com/juju/hello-juju-charm/issues/1.

I saw this by running juju debug-log, in case you’re interested.

Hopefully someone will be able to take a look at this soon and get it fixed up.

Thank you. I saw the same log, but was wondering if the problem could be on the other side of the relation, as unit-postgresql showed errors too :

unit-postgresql-1: 01:04:09 ERROR unit.postgresql/1.juju-log Unable to find implementation for relation: provides of block-storage
unit-postgresql-1: 01:04:09 ERROR unit.postgresql/1.juju-log Unable to find implementation for relation: provides of local-monitors
unit-postgresql-1: 01:04:09 ERROR unit.postgresql/1.juju-log Unable to find implementation for relation: provides of pgreplication
unit-postgresql-1: 01:04:09 ERROR unit.postgresql/1.juju-log Unable to find implementation for relation: peers of pgpeer

Hello again,

I don’t understand, is it so difficult to fix the first example one will see when trying to understand juju and the juju relations ?

Thanks for the report. This has been fixed. I’ll get it published to the store presently.

After re-deploying

I get the same error : ‘hook failed: “db-relation-changed”’

and the logs are very similar

unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed TypeError: expected bytes, str found
unit-hello-juju-5: 11:52:22 ERROR unit.hello-juju/5.juju-log db:19: Hook error:
self._action(*args)
File “/var/lib/juju/agents/unit-hello-juju-5/charm/reactive/hello_juju.py”, line 103, in create_and_configure_database
create_database_tables()
File “/var/lib/juju/agents/unit-hello-juju-5/charm/reactive/hello_juju.py”, line 66, in create_database_tables
check_call(str(‘sudo -u www-data /srv/hello-juju/venv/bin/python3 /srv/hello-juju/current/init.py’).split())
File “/usr/lib/python3.6/subprocess.py”, line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘sudo’, ‘-u’, ‘www-data’, ‘/srv/hello-juju/venv/bin/python3’, ‘/srv/hello-juju/current/init.py’]’ returned non-zero exit status 1.
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed Traceback (most recent call last):
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed File “/var/lib/juju/agents/unit-hello-juju-5/charm/hooks/db-relation-changed”, line 22, in
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed main()
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed File “/var/lib/juju/agents/unit-hello-juju-5/.venv/lib/python3.6/site-packages/charms/reactive/init.py”, line 74, in main
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed bus.dispatch(restricted=restricted_mode)
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed File “/var/lib/juju/agents/unit-hello-juju-5/.venv/lib/python3.6/site-packages/charms/reactive/bus.py”, line 390, in dispatch
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed _invoke(other_handlers)
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed File “/var/lib/juju/agents/unit-hello-juju-5/.venv/lib/python3.6/site-packages/charms/reactive/bus.py”, line 359, in _invoke
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed handler.invoke()
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed File “/var/lib/juju/agents/unit-hello-juju-5/.venv/lib/python3.6/site-packages/charms/reactive/bus.py”, line 181, in invoke
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed self._action(*args)
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed File “/var/lib/juju/agents/unit-hello-juju-5/charm/reactive/hello_juju.py”, line 103, in create_and_configure_database
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed create_database_tables()
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed File “/var/lib/juju/agents/unit-hello-juju-5/charm/reactive/hello_juju.py”, line 66, in create_database_tables
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed check_call(str(‘sudo -u www-data /srv/hello-juju/venv/bin/python3 /srv/hello-juju/current/init.py’).split())
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed File “/usr/lib/python3.6/subprocess.py”, line 311, in check_call
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed raise CalledProcessError(retcode, cmd)
unit-hello-juju-5: 11:52:22 WARNING unit.hello-juju/5.db-relation-changed subprocess.CalledProcessError: Command ‘[‘sudo’, ‘-u’, ‘www-data’, ‘/srv/hello-juju/venv/bin/python3’, ‘/srv/hello-juju/current/init.py’]’ returned non-zero exit status 1.
unit-hello-juju-5: 11:52:22 ERROR juju.worker.uniter.operation hook “db-relation-changed” (via explicit, bespoke hook script) failed: exit status 1
unit-hello-juju-5: 11:52:22 INFO juju.worker.uniter awaiting error resolution for “relation-changed” hook
unit-hello-juju-5: 11:52:32 INFO juju.worker.uniter awaiting error resolution for “relation-changed” hook
unit-hello-juju-5: 11:52:33 INFO unit.hello-juju/5.juju-log db:19: Reactive main running for hook db-relation-changed
unit-hello-juju-5: 11:52:33 INFO unit.hello-juju/5.juju-log db:19: Invoking reactive handler: reactive/hello_juju.py:45:configure_gunicorn
unit-hello-juju-5: 11:52:34 INFO unit.hello-juju/5.juju-log db:19: Invoking reactive handler: reactive/hello_juju.py:86:pending
unit-hello-juju-5: 11:52:34 INFO unit.hello-juju/5.juju-log db:19: Invoking reactive handler: hooks/relations/pgsql/requires.py:388:_joined:db
unit-hello-juju-5: 11:52:34 INFO unit.hello-juju/5.juju-log db:19: Invoking reactive handler: hooks/relations/pgsql/requires.py:404:_changed:db
unit-hello-juju-5: 11:52:34 INFO unit.hello-juju/5.juju-log db:19: Invoking reactive handler: reactive/hello_juju.py:91:create_and_configure_database

It should work now.
Fixed by https://github.com/juju/hello-juju/pull/1

It worked indeed. Thanks.