The problem is that the action method does not return immediately when setting status as failed when running on non-leader unit.
Additionally I see that also the problem happens for other action that relies on hookenv.leader_set like get-csr. So the patch will cover also these methods
$ juju run-action --wait vault/4 get-csr token=s.vRujzbfRgzf5fBtZKnY4HcCC ; juju debug-log
unit-vault-4:
UnitId: vault/4
id: "43"
message: 'subprocess.CalledProcessError: Command ''[''leader-set'', ''root-ca='']''
returned non-zero exit status 1.'
results:
Stderr: |
ERROR cannot write leadership settings: cannot write settings: not the leader
status: failed
timing:
completed: 2021-02-22 13:22:20 +0000 UTC
enqueued: 2021-02-22 13:22:19 +0000 UTC
started: 2021-02-22 13:22:19 +0000 UTC
The problem is that the action method does not return immediately when setting status as failed when running on non-leader unit.
Additionally I see that also the problem happens for other action that relies on hookenv.leader_set like get-csr. So the patch will cover also these methods
$ juju run-action --wait vault/4 get-csr token=s. vRujzbfRgzf5fBt ZKnY4HcCC ; juju debug-log CalledProcessEr ror: Command ''[''leader-set'', ''root-ca='']''
unit-vault-4:
UnitId: vault/4
id: "43"
message: 'subprocess.
returned non-zero exit status 1.'
results:
Stderr: |
ERROR cannot write leadership settings: cannot write settings: not the leader
status: failed
timing:
completed: 2021-02-22 13:22:20 +0000 UTC
enqueued: 2021-02-22 13:22:19 +0000 UTC
started: 2021-02-22 13:22:19 +0000 UTC