Be more defensive when checking Vault
When relations are departing during a unit removal, the relation to Vault can loose enough data that the vault-relation-departed hook raises an exception. The checks for Vault readiness should be more defensive to ensure that charms can successfully depart their relations Depends-On https://github.com/juju/charm-helpers/pull/445 Closes-Bug: #1868282 Change-Id: I0b6226f0f3500aef7304f8e8b38d06daebfd0c20
This commit is contained in:
parent
cb0f757f18
commit
0ecc33223c
@ -140,9 +140,16 @@ def vault_relation_complete(backend=None):
|
|||||||
:ptype backend: string
|
:ptype backend: string
|
||||||
:returns: whether the relation to vault is complete
|
:returns: whether the relation to vault is complete
|
||||||
:rtype: bool"""
|
:rtype: bool"""
|
||||||
vault_kv = VaultKVContext(secret_backend=backend or VAULTLOCKER_BACKEND)
|
try:
|
||||||
vault_kv()
|
import hvac
|
||||||
return vault_kv.complete
|
except ImportError:
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
vault_kv = VaultKVContext(secret_backend=backend or VAULTLOCKER_BACKEND)
|
||||||
|
vault_kv()
|
||||||
|
return vault_kv.complete
|
||||||
|
except hvac.exceptions.InvalidRequest:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
# TODO: contrib a high level unwrap method to hvac that works
|
# TODO: contrib a high level unwrap method to hvac that works
|
||||||
|
Loading…
Reference in New Issue
Block a user