When the requirer side of the relation has more than one unit, i.e. when the tls_certificates
lib is run on non leader units, it fails for:
File "/var/lib/juju/agents/unit-am-1/charm/lib/charms/tls_certificates_interface/v2/tls_certificates.py", line 1365, in _on_relation_changed
secret = self.charm.app.add_secret(
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 427, in add_secret
id = self._backend.secret_add(
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 3119, in secret_add
result = self._run('secret-add', *args, return_output=True)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 2695, in _run
raise ModelError(e.stderr)
ops.model.ModelError: ERROR this unit is not the leader
unit-am-1: 09:14:08.602 DEBUG unit.am/1.juju-log certificates:9: Emitting Juju event certificates_relation_changed.
unit-am-1: 09:14:08.643 ERROR unit.am/1.juju-log certificates:9: Uncaught exception while in charm code:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 2693, in _run
result = subprocess.run(args, **kwargs) # type: ignore
File "/usr/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('/var/lib/juju/tools/unit-am-1/secret-get', '--label', 'afd8c2bccf834997afce12c2706d2ede------BEGIN CERTIFICATE REQUEST-----\nMIIC4DCCAcgCAQAwPjENMAsGA1UEAwwEYW0vMTEtMCsGA1UELQwkZmJlYmZkMmMt\nMWE4My00ZDU5LWFiYmYtYzEyNzhlNThmNzc1MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAr/1OM2Jdh8IpqhA74xvsFOJZhel6nkJMVkO3zPtX8Ghz65z1\nl4bmoP2bkwEOI1n9tyEmzObHKh30KmnMMGby/1FVOd9MlQ5+jnF3uO5yTcDdO721\n+4qPuzOEfcm46zwVnqskB2yTSNAp8YrItWbT9L1iHm/Hzkw7IYd5yhSZVIDCkdTg\nX2Buifc++SDIurDGwUbHmgGkqJwgYglaU2HfBe5rzGTXKQ6bOZeWpuVvm11j1bU9\ncVyWvDmj9wY9un+C2FEeFpGfuQn5VEmcovuR1jRmu5vr2cvCpEj6tQAO9IGOCl3s\n0skaSmb9bSd91rftpblmZcjcBV6oKQK7Uag0BQIDAQABoF0wWwYJKoZIhvcNAQkO\nMU4wTDBKBgNVHREEQzBBgj9hbS0xLmFtLWVuZHBvaW50cy50ZXN0LXByb21ldGhl\ndXMtYWxlcnRzLTMyazQuc3ZjLmNsdXN0ZXIubG9jYWwwDQYJKoZIhvcNAQELBQAD\nggEBAI66l+73jTigQvvUNs/cfWGQIPj18ED6pXWZcBjrUGueM47JXBP8hvZx5JuY\nw/myI90LPZMV/z7HZVJtadv9mpF3mefEtY5ul1liO4PG/47iQnyQmzI61revsUex\nqiCOB6WChdxdoBmHhGaL7VnWBajHZ+QL+I1Xo0hYdcwNE+vJqTKXwy6cI9bNNkVV\nIpxOjL+AYUn5qt3s1qkYAkCZvSmNswwlh5gSFAEBrO8fUtEj9i1Fwo8iq4HbJ6vZ\n1RWFaNDwNjgZ09TGm47xBk39XD9UpdOrBBYEvG4NOljmSeFBy3OeDZ/phzBLOsuc\nB19EN9zx6B6uqV7Io2s0nSbtD9Y=\n-----END CERTIFICATE REQUEST-----', '--format=json')' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 3049, in secret_get
result = self._run('secret-get', *args, return_output=True, use_json=True)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 2695, in _run
raise ModelError(e.stderr)
ops.model.ModelError: ERROR consumer label "afd8c2bccf834997afce12c2706d2ede------BEGIN CERTIFICATE REQUEST-----\nMIIC4DCCAcgCAQAwPjENMAsGA1UEAwwEYW0vMTEtMCsGA1UELQwkZmJlYmZkMmMt\nMWE4My00ZDU5LWFiYmYtYzEyNzhlNThmNzc1MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAr/1OM2Jdh8IpqhA74xvsFOJZhel6nkJMVkO3zPtX8Ghz65z1\nl4bmoP2bkwEOI1n9tyEmzObHKh30KmnMMGby/1FVOd9MlQ5+jnF3uO5yTcDdO721\n+4qPuzOEfcm46zwVnqskB2yTSNAp8YrItWbT9L1iHm/Hzkw7IYd5yhSZVIDCkdTg\nX2Buifc++SDIurDGwUbHmgGkqJwgYglaU2HfBe5rzGTXKQ6bOZeWpuVvm11j1bU9\ncVyWvDmj9wY9un+C2FEeFpGfuQn5VEmcovuR1jRmu5vr2cvCpEj6tQAO9IGOCl3s\n0skaSmb9bSd91rftpblmZcjcBV6oKQK7Uag0BQIDAQABoF0wWwYJKoZIhvcNAQkO\nMU4wTDBKBgNVHREEQzBBgj9hbS0xLmFtLWVuZHBvaW50cy50ZXN0LXByb21ldGhl\ndXMtYWxlcnRzLTMyazQuc3ZjLmNsdXN0ZXIubG9jYWwwDQYJKoZIhvcNAQELBQAD\nggEBAI66l+73jTigQvvUNs/cfWGQIPj18ED6pXWZcBjrUGueM47JXBP8hvZx5JuY\nw/myI90LPZMV/z7HZVJtadv9mpF3mefEtY5ul1liO4PG/47iQnyQmzI61revsUex\nqiCOB6WChdxdoBmHhGaL7VnWBajHZ+QL+I1Xo0hYdcwNE+vJqTKXwy6cI9bNNkVV\nIpxOjL+AYUn5qt3s1qkYAkCZvSmNswwlh5gSFAEBrO8fUtEj9i1Fwo8iq4HbJ6vZ\n1RWFaNDwNjgZ09TGm47xBk39XD9UpdOrBBYEvG4NOljmSeFBy3OeDZ/phzBLOsuc\nB19EN9zx6B6uqV7Io2s0nSbtD9Y=\n-----END CERTIFICATE REQUEST-----" not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 269, in get_secret
content = self._backend.secret_get(id=id, label=label)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 3052, in secret_get
raise SecretNotFoundError() from e
ops.model.SecretNotFoundError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 2693, in _run
result = subprocess.run(args, **kwargs) # type: ignore
File "/usr/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('/var/lib/juju/tools/unit-am-1/secret-info-get', '--label', 'afd8c2bccf834997afce12c2706d2ede------BEGIN CERTIFICATE REQUEST-----\nMIIC4DCCAcgCAQAwPjENMAsGA1UEAwwEYW0vMTEtMCsGA1UELQwkZmJlYmZkMmMt\nMWE4My00ZDU5LWFiYmYtYzEyNzhlNThmNzc1MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAr/1OM2Jdh8IpqhA74xvsFOJZhel6nkJMVkO3zPtX8Ghz65z1\nl4bmoP2bkwEOI1n9tyEmzObHKh30KmnMMGby/1FVOd9MlQ5+jnF3uO5yTcDdO721\n+4qPuzOEfcm46zwVnqskB2yTSNAp8YrItWbT9L1iHm/Hzkw7IYd5yhSZVIDCkdTg\nX2Buifc++SDIurDGwUbHmgGkqJwgYglaU2HfBe5rzGTXKQ6bOZeWpuVvm11j1bU9\ncVyWvDmj9wY9un+C2FEeFpGfuQn5VEmcovuR1jRmu5vr2cvCpEj6tQAO9IGOCl3s\n0skaSmb9bSd91rftpblmZcjcBV6oKQK7Uag0BQIDAQABoF0wWwYJKoZIhvcNAQkO\nMU4wTDBKBgNVHREEQzBBgj9hbS0xLmFtLWVuZHBvaW50cy50ZXN0LXByb21ldGhl\ndXMtYWxlcnRzLTMyazQuc3ZjLmNsdXN0ZXIubG9jYWwwDQYJKoZIhvcNAQELBQAD\nggEBAI66l+73jTigQvvUNs/cfWGQIPj18ED6pXWZcBjrUGueM47JXBP8hvZx5JuY\nw/myI90LPZMV/z7HZVJtadv9mpF3mefEtY5ul1liO4PG/47iQnyQmzI61revsUex\nqiCOB6WChdxdoBmHhGaL7VnWBajHZ+QL+I1Xo0hYdcwNE+vJqTKXwy6cI9bNNkVV\nIpxOjL+AYUn5qt3s1qkYAkCZvSmNswwlh5gSFAEBrO8fUtEj9i1Fwo8iq4HbJ6vZ\n1RWFaNDwNjgZ09TGm47xBk39XD9UpdOrBBYEvG4NOljmSeFBy3OeDZ/phzBLOsuc\nB19EN9zx6B6uqV7Io2s0nSbtD9Y=\n-----END CERTIFICATE REQUEST-----', '--format=json')' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 3059, in _run_for_secret
return self._run(*args, return_output=return_output, use_json=use_json)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 2695, in _run
raise ModelError(e.stderr)
ops.model.ModelError: ERROR secret "afd8c2bccf834997afce12c2706d2ede------BEGIN CERTIFICATE REQUEST-----\nMIIC4DCCAcgCAQAwPjENMAsGA1UEAwwEYW0vMTEtMCsGA1UELQwkZmJlYmZkMmMt\nMWE4My00ZDU5LWFiYmYtYzEyNzhlNThmNzc1MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAr/1OM2Jdh8IpqhA74xvsFOJZhel6nkJMVkO3zPtX8Ghz65z1\nl4bmoP2bkwEOI1n9tyEmzObHKh30KmnMMGby/1FVOd9MlQ5+jnF3uO5yTcDdO721\n+4qPuzOEfcm46zwVnqskB2yTSNAp8YrItWbT9L1iHm/Hzkw7IYd5yhSZVIDCkdTg\nX2Buifc++SDIurDGwUbHmgGkqJwgYglaU2HfBe5rzGTXKQ6bOZeWpuVvm11j1bU9\ncVyWvDmj9wY9un+C2FEeFpGfuQn5VEmcovuR1jRmu5vr2cvCpEj6tQAO9IGOCl3s\n0skaSmb9bSd91rftpblmZcjcBV6oKQK7Uag0BQIDAQABoF0wWwYJKoZIhvcNAQkO\nMU4wTDBKBgNVHREEQzBBgj9hbS0xLmFtLWVuZHBvaW50cy50ZXN0LXByb21ldGhl\ndXMtYWxlcnRzLTMyazQuc3ZjLmNsdXN0ZXIubG9jYWwwDQYJKoZIhvcNAQELBQAD\nggEBAI66l+73jTigQvvUNs/cfWGQIPj18ED6pXWZcBjrUGueM47JXBP8hvZx5JuY\nw/myI90LPZMV/z7HZVJtadv9mpF3mefEtY5ul1liO4PG/47iQnyQmzI61revsUex\nqiCOB6WChdxdoBmHhGaL7VnWBajHZ+QL+I1Xo0hYdcwNE+vJqTKXwy6cI9bNNkVV\nIpxOjL+AYUn5qt3s1qkYAkCZvSmNswwlh5gSFAEBrO8fUtEj9i1Fwo8iq4HbJ6vZ\n1RWFaNDwNjgZ09TGm47xBk39XD9UpdOrBBYEvG4NOljmSeFBy3OeDZ/phzBLOsuc\nB19EN9zx6B6uqV7Io2s0nSbtD9Y=\n-----END CERTIFICATE REQUEST-----" not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-am-1/charm/lib/charms/tls_certificates_interface/v2/tls_certificates.py", line 1355, in _on_relation_changed
secret = self.model.get_secret(
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 274, in get_secret
info = self._backend.secret_info_get(id=id, label=label)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 3073, in secret_info_get
result = self._run_for_secret('secret-info-get', *args, return_output=True, use_json=True)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 3062, in _run_for_secret
raise SecretNotFoundError() from e
ops.model.SecretNotFoundError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 2693, in _run
result = subprocess.run(args, **kwargs) # type: ignore
File "/usr/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('/var/lib/juju/tools/unit-am-1/secret-add', '--label', 'afd8c2bccf834997afce12c2706d2ede------BEGIN CERTIFICATE REQUEST-----\nMIIC4DCCAcgCAQAwPjENMAsGA1UEAwwEYW0vMTEtMCsGA1UELQwkZmJlYmZkMmMt\nMWE4My00ZDU5LWFiYmYtYzEyNzhlNThmNzc1MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAr/1OM2Jdh8IpqhA74xvsFOJZhel6nkJMVkO3zPtX8Ghz65z1\nl4bmoP2bkwEOI1n9tyEmzObHKh30KmnMMGby/1FVOd9MlQ5+jnF3uO5yTcDdO721\n+4qPuzOEfcm46zwVnqskB2yTSNAp8YrItWbT9L1iHm/Hzkw7IYd5yhSZVIDCkdTg\nX2Buifc++SDIurDGwUbHmgGkqJwgYglaU2HfBe5rzGTXKQ6bOZeWpuVvm11j1bU9\ncVyWvDmj9wY9un+C2FEeFpGfuQn5VEmcovuR1jRmu5vr2cvCpEj6tQAO9IGOCl3s\n0skaSmb9bSd91rftpblmZcjcBV6oKQK7Uag0BQIDAQABoF0wWwYJKoZIhvcNAQkO\nMU4wTDBKBgNVHREEQzBBgj9hbS0xLmFtLWVuZHBvaW50cy50ZXN0LXByb21ldGhl\ndXMtYWxlcnRzLTMyazQuc3ZjLmNsdXN0ZXIubG9jYWwwDQYJKoZIhvcNAQELBQAD\nggEBAI66l+73jTigQvvUNs/cfWGQIPj18ED6pXWZcBjrUGueM47JXBP8hvZx5JuY\nw/myI90LPZMV/z7HZVJtadv9mpF3mefEtY5ul1liO4PG/47iQnyQmzI61revsUex\nqiCOB6WChdxdoBmHhGaL7VnWBajHZ+QL+I1Xo0hYdcwNE+vJqTKXwy6cI9bNNkVV\nIpxOjL+AYUn5qt3s1qkYAkCZvSmNswwlh5gSFAEBrO8fUtEj9i1Fwo8iq4HbJ6vZ\n1RWFaNDwNjgZ09TGm47xBk39XD9UpdOrBBYEvG4NOljmSeFBy3OeDZ/phzBLOsuc\nB19EN9zx6B6uqV7Io2s0nSbtD9Y=\n-----END CERTIFICATE REQUEST-----', '--expire', '2024-07-04T13:13:51', '--owner', 'application', 'certificate=-----BEGIN CERTIFICATE-----\nMIIDUzCCAjugAwIBAgIUf9FNOkfPS0Z82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b7z1+5uZ4oU5ElKt3CW\n7PH3oSCrHrx8iXg31/3yP+415tRb5cWotQRFE8Ev8pHz72dBUNx3\n-----END CERTIFICATE-----')' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./src/charm.py", line 542, in <module>
main(AlertmanagerCharm)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/main.py", line 441, in main
_emit_charm_event(charm, dispatcher.event_name)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/main.py", line 149, in _emit_charm_event
event_to_emit.emit(*args, **kwargs)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/framework.py", line 344, in emit
framework._emit(event)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/framework.py", line 833, in _emit
self._reemit(event_path)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/framework.py", line 922, in _reemit
custom_handler(event)
File "/var/lib/juju/agents/unit-am-1/charm/lib/charms/tls_certificates_interface/v2/tls_certificates.py", line 1365, in _on_relation_changed
secret = self.charm.app.add_secret(
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 427, in add_secret
id = self._backend.secret_add(
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 3119, in secret_add
result = self._run('secret-add', *args, return_output=True)
File "/var/lib/juju/agents/unit-am-1/charm/venv/ops/model.py", line 2695, in _run
raise ModelError(e.stderr)
ops.model.ModelError: ERROR this unit is not the leader