Merge "Handle when allowed_units is None"

This commit is contained in:
Zuul
2020-12-11 07:29:33 +00:00
committed by Gerrit Code Review
2 changed files with 14 additions and 1 deletions

View File

@@ -255,7 +255,8 @@ def configure_vault_psql(psql):
@when('shared-db.available')
@when('vault.ssl.configured')
def configure_vault_mysql(mysql):
if local_unit() not in mysql.allowed_units():
if (not mysql.allowed_units() or
local_unit() not in mysql.allowed_units()):
log("Deferring vault configuration until"
" MySQL access is granted", level=DEBUG)
return

View File

@@ -188,6 +188,18 @@ class TestHandlers(unit_tests.test_utils.CharmTestCase):
'storage_name': 'mysql',
'mysql_db_relation': mysql})
# Not ready
configure_vault.reset_mock()
mysql.allowed_units.return_value = None
handlers.configure_vault_mysql(mysql)
configure_vault.assert_not_called()
# Not ready
configure_vault.reset_mock()
mysql.allowed_units.return_value = ['vault/382']
handlers.configure_vault_mysql(mysql)
configure_vault.assert_not_called()
@patch.object(handlers, 'base64')
@patch.object(handlers, 'write_file')
@patch.object(handlers, 'configure_vault')