Enable network-spaces for swift-storage relation
Ensure that any network space binding provided by the end user is used as units join the swift-storage relation. This allows backend communication to swift-storage units to be network isolated from frontend public access to the swift deployment. Change-Id: If29ba3dfb1379f0cda20d9685e654d911d67df1d Closes-Bug: 1697491
This commit is contained in:
parent
51eac2be45
commit
27c669a657
|
@ -1,6 +1,7 @@
|
|||
bin
|
||||
.coverage
|
||||
.testrepository
|
||||
.stestr
|
||||
.tox
|
||||
tags
|
||||
*.sw[nop]
|
||||
|
|
|
@ -228,7 +228,7 @@ def keystone_changed():
|
|||
|
||||
|
||||
@hooks.hook('swift-storage-relation-joined')
|
||||
def storage_joined():
|
||||
def storage_joined(rid=None):
|
||||
if not is_elected_leader(SWIFT_HA_RES):
|
||||
log("New storage relation joined - stopping proxy until ring builder "
|
||||
"synced", level=INFO)
|
||||
|
@ -241,6 +241,13 @@ def storage_joined():
|
|||
mark_www_rings_deleted()
|
||||
try_initialize_swauth()
|
||||
|
||||
# NOTE(jamespage): Ensure private-address is set to any network-space
|
||||
# binding provided by the charm user.
|
||||
relation_set(
|
||||
relation_id=rid,
|
||||
relation_settings={'private-address': get_relation_ip('swift-storage')}
|
||||
)
|
||||
|
||||
|
||||
def get_host_ip(rid=None, unit=None):
|
||||
addr = relation_get('private-address', rid=rid, unit=unit)
|
||||
|
|
|
@ -233,7 +233,7 @@ class SwiftHooksTestCase(unittest.TestCase):
|
|||
@patch.object(swift_hooks, 'update_dns_ha_resource_params')
|
||||
@patch.object(swift_hooks, 'get_hacluster_config')
|
||||
@patch.object(swift_hooks, 'config')
|
||||
def test_ha_jrelation_oined_dns_ha(self, test_config, get_hacluster_config,
|
||||
def test_ha_relation_joined_dns_ha(self, test_config, get_hacluster_config,
|
||||
update_dns_ha_resource_params,
|
||||
relation_set):
|
||||
def _fake_update(resources, resource_params, relation_id=None):
|
||||
|
@ -271,3 +271,24 @@ class SwiftHooksTestCase(unittest.TestCase):
|
|||
swift_hooks.ha_relation_joined()
|
||||
self.assertTrue(update_dns_ha_resource_params.called)
|
||||
relation_set.assert_called_with(**args)
|
||||
|
||||
@patch.object(swift_hooks, 'is_elected_leader')
|
||||
@patch.object(swift_hooks, 'get_relation_ip')
|
||||
@patch.object(swift_hooks, 'try_initialize_swauth')
|
||||
@patch.object(swift_hooks, 'mark_www_rings_deleted')
|
||||
@patch.object(swift_hooks, 'service_stop')
|
||||
@patch.object(swift_hooks, 'relation_set')
|
||||
def test_swift_storage_joined(self, relation_set, service_stop,
|
||||
mark_www_rings_deleted,
|
||||
try_initialize_swauth,
|
||||
get_relation_ip,
|
||||
is_elected_leader):
|
||||
is_elected_leader.return_value = False
|
||||
get_relation_ip.return_value = '10.10.20.243'
|
||||
swift_hooks.storage_joined(rid='swift-storage:23')
|
||||
get_relation_ip.assert_called_with('swift-storage')
|
||||
relation_set.assert_called_with(
|
||||
relation_id='swift-storage:23',
|
||||
relation_settings={'private-address': '10.10.20.243'}
|
||||
)
|
||||
try_initialize_swauth.assert_called_once()
|
||||
|
|
Loading…
Reference in New Issue