After successfully deploying mariadb-k8s and gitlab-k8s to our GKE cluster, we attempted to relate them with juju relate gitlab-k8s mariadb-k8s. This resulted in a hook failure with mariadb-k8s’ status showing “error” and the note “hook failed: "server-relation-joined".” The debug log indicated there was an exception:
Traceback (most recent call last):
File "lib/charms/reactive/__init__.py", line 73, in main
bus.dispatch(restricted=restricted_mode)
File "lib/charms/reactive/bus.py", line 390, in dispatch
_invoke(other_handlers)
File "lib/charms/reactive/bus.py", line 359, in _invoke
handler.invoke()
File "lib/charms/reactive/bus.py", line 181, in invoke
self._action(*args)
File "/var/lib/juju/agents/unit-mariadb-k8s-2/charm/reactive/mysql.py", line 78, in provide_database
host = info['ingress-addresses'][0]
KeyError: 'ingress-addresses'
On k8s, the service/pod address may not be available immediately when a relation is joined. When the address does become available, the config-changed hook is called. So the mysql interface needs to be able to handle this situation.
After successfully deploying mariadb-k8s and gitlab-k8s to our GKE cluster, we attempted to relate them with juju relate gitlab-k8s mariadb-k8s. This resulted in a hook failure with mariadb-k8s’ status showing “error” and the note “hook failed: "server-relation-joined".” The debug log indicated there was an exception:
On k8s, the service/pod address may not be available immediately when a relation is joined. When the address does become available, the config-changed hook is called. So the mysql interface needs to be able to handle this situation.