Ensure handler fires only when data is changed

At present the charm will attempt to request a one-shot token
multiple times which leads to hook errors.
This commit is contained in:
Frode Nordahl 2018-10-22 14:10:19 +02:00
parent cda2bdfa1b
commit 5ee8482fdc
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
2 changed files with 5 additions and 2 deletions

View File

@ -43,7 +43,8 @@ def secret_backend_vault_request():
barbican_vault_charm.secret_backend_name, isolated=False)
@reactive.when_all('endpoint.secrets.joined', 'secrets-storage.available')
@reactive.when_all('endpoint.secrets.joined', 'secrets-storage.available',
'endpoint.secrets-storage.changed')
def plugin_info_barbican_publish():
barbican = reactive.endpoint_from_flag('endpoint.secrets.joined')
secrets_storage = reactive.endpoint_from_flag(
@ -65,3 +66,4 @@ def plugin_info_barbican_publish():
ch_core.hookenv.log('Publishing vault plugin info to barbican',
level=ch_core.hookenv.INFO)
barbican.publish_plugin_info('vault', vault_data)
reactive.clear_flag('endpoint.secrets-storage.changed')

View File

@ -36,7 +36,8 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
},
'when_all': {
'plugin_info_barbican_publish': (
'endpoint.secrets.joined', 'secrets-storage.available',),
'endpoint.secrets.joined', 'secrets-storage.available',
'endpoint.secrets-storage.changed',),
},
'when_not': {
'secret_backend_vault_request': (