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