When trying to use this library in Alertmanager, I got the following error:
File "/var/lib/juju/agents/unit-am-0/charm/lib/charms/observability_libs/v1/cert_handler.py", line 214, in _on_config_changed
self._generate_csr(renew=True)
File "/var/lib/juju/agents/unit-am-0/charm/lib/charms/observability_libs/v1/cert_handler.py", line 233, in _generate_csr
raise RuntimeError(
RuntimeError: private key unset. call _generate_privkey() before you call this method.
In fact, _on_config_changed() doesn't call _generate_privkey().
The issue is that a race condition probably causes config-changed to arrive before certificates-relation-joined, which doesn't generate the private key beforehand.
Please note that calling the function multiple times isn't a problem as the function will just skip :)
Solution
Add a call to _generate_privkey() in the _on_config_changed() handler.
Issue
When trying to use this library in Alertmanager, I got the following error:
In fact,
_on_config_changed()
doesn't call_generate_privkey()
.The issue is that a race condition probably causes config-changed to arrive before certificates-relation-joined, which doesn't generate the private key beforehand.
Please note that calling the function multiple times isn't a problem as the function will just skip :)
Solution
Add a call to
_generate_privkey()
in the_on_config_changed()
handler.