Fix pool creation for single zone setups.
Deprecate 'pool-prefix' charm config. Change-Id: I34079d8975d995ea958f219e0516a972d73319f7 Closes-Bug: #1856106 Co-Authored-By: Andrei Bacos <abacos@cloudbasesolutions.com>
This commit is contained in:
parent
85b3b74026
commit
2466691f85
15
config.yaml
15
config.yaml
|
@ -77,12 +77,13 @@ options:
|
|||
type: string
|
||||
default:
|
||||
description: |
|
||||
The rados gateway stores objects in many different pools. If you would
|
||||
like to have multiple rados gateways each pointing to a separate set of
|
||||
pools set this prefix. The charm will then set up a new set of pools.
|
||||
If your prefix has a dash in it that will be used to split the prefix
|
||||
into region and zone. Please read the documentation on federated rados
|
||||
gateways for more information on region and zone.
|
||||
DEPRECATED, use zone instead - pool name can be inherited from the zone config
|
||||
option. The rados gateway stores objects in many different pools. If you
|
||||
would like to have multiple rados gateways each pointing to a separate
|
||||
set of pools set this prefix. The charm will then set up a new set of pools.
|
||||
If your prefix has a dash in it that will be used to split the prefix into
|
||||
region and zone. Please read the documentation on federated rados gateways
|
||||
for more information on region and zone.
|
||||
restrict-ceph-pools:
|
||||
type: boolean
|
||||
default: False
|
||||
|
@ -414,7 +415,7 @@ options:
|
|||
Name of RADOS Gateway Zone Group to create for multi-site replication.
|
||||
zone:
|
||||
type: string
|
||||
default:
|
||||
default: default
|
||||
description: |
|
||||
Name of RADOS Gateway Zone to create for multi-site replication. This
|
||||
option must be specific to the local site e.g. us-west or us-east.
|
||||
|
|
|
@ -259,7 +259,6 @@ def mon_relation(rid=None, unit=None):
|
|||
relation_set(relation_id=rid,
|
||||
key_name=key_name)
|
||||
try:
|
||||
# NOTE: prefer zone name if in use over pool-prefix.
|
||||
rq = ceph.get_create_rgw_pools_rq(
|
||||
prefix=config('zone') or config('pool-prefix'))
|
||||
except ValueError as e:
|
||||
|
@ -271,6 +270,7 @@ def mon_relation(rid=None, unit=None):
|
|||
'configuration?: "{}"'.format(str(e)),
|
||||
level=DEBUG)
|
||||
return
|
||||
|
||||
if is_request_complete(rq, relation='mon'):
|
||||
log('Broker request complete', level=DEBUG)
|
||||
CONFIGS.write_all()
|
||||
|
@ -313,7 +313,24 @@ def mon_relation(rid=None, unit=None):
|
|||
.format(service_name()), level=DEBUG)
|
||||
service_resume(service_name())
|
||||
|
||||
process_multisite_relations()
|
||||
if multisite_deployment():
|
||||
process_multisite_relations()
|
||||
elif is_leader():
|
||||
# In a non multi-site deployment create the
|
||||
# zone using the default zonegroup and restart the service
|
||||
internal_url = '{}:{}'.format(
|
||||
canonical_url(CONFIGS, INTERNAL),
|
||||
listen_port(),
|
||||
)
|
||||
endpoints = [internal_url]
|
||||
zonegroup = 'default'
|
||||
zone = config('zone')
|
||||
if zone not in multisite.list_zones():
|
||||
multisite.create_zone(zone,
|
||||
endpoints=endpoints,
|
||||
default=True, master=True,
|
||||
zonegroup=zonegroup)
|
||||
service_restart(service_name())
|
||||
else:
|
||||
send_request_if_needed(rq, relation='mon')
|
||||
_mon_relation()
|
||||
|
|
|
@ -103,6 +103,7 @@ class MultisiteActionsTestCase(CharmTestCase):
|
|||
self.multisite.update_period.assert_called_once_with()
|
||||
|
||||
def test_promote_unconfigured(self):
|
||||
self.test_config.set('zone', None)
|
||||
actions.promote([])
|
||||
self.action_fail.assert_called_once()
|
||||
|
||||
|
@ -116,6 +117,7 @@ class MultisiteActionsTestCase(CharmTestCase):
|
|||
self.multisite.update_period.assert_called_once_with()
|
||||
|
||||
def test_readonly_unconfigured(self):
|
||||
self.test_config.set('zone', None)
|
||||
actions.readonly([])
|
||||
self.action_fail.assert_called_once()
|
||||
|
||||
|
@ -129,6 +131,7 @@ class MultisiteActionsTestCase(CharmTestCase):
|
|||
self.multisite.update_period.assert_called_once_with()
|
||||
|
||||
def test_readwrite_unconfigured(self):
|
||||
self.test_config.set('zone', None)
|
||||
actions.readwrite([])
|
||||
self.action_fail.assert_called_once()
|
||||
|
||||
|
@ -138,5 +141,6 @@ class MultisiteActionsTestCase(CharmTestCase):
|
|||
self.multisite.tidy_defaults.assert_called_once_with()
|
||||
|
||||
def test_tidydefaults_unconfigured(self):
|
||||
self.test_config.set('zone', None)
|
||||
actions.tidydefaults([])
|
||||
self.action_fail.assert_called_once()
|
||||
|
|
|
@ -385,7 +385,7 @@ class MonContextTest(CharmTestCase):
|
|||
'port': 70,
|
||||
'client_radosgw_gateway': {'rgw init timeout': 60},
|
||||
'ipv6': False,
|
||||
'rgw_zone': None,
|
||||
'rgw_zone': 'default',
|
||||
'fsid': 'testfsid',
|
||||
}
|
||||
self.assertEqual(expect, mon_ctxt())
|
||||
|
@ -433,7 +433,7 @@ class MonContextTest(CharmTestCase):
|
|||
'port': 70,
|
||||
'client_radosgw_gateway': {'rgw init timeout': 60},
|
||||
'ipv6': False,
|
||||
'rgw_zone': None,
|
||||
'rgw_zone': 'default',
|
||||
'fsid': 'testfsid',
|
||||
}
|
||||
self.assertEqual(expect, mon_ctxt())
|
||||
|
@ -490,7 +490,7 @@ class MonContextTest(CharmTestCase):
|
|||
'port': 70,
|
||||
'client_radosgw_gateway': {'rgw init timeout': 60},
|
||||
'ipv6': False,
|
||||
'rgw_zone': None,
|
||||
'rgw_zone': 'default',
|
||||
'fsid': 'testfsid',
|
||||
}
|
||||
self.assertEqual(expect, mon_ctxt())
|
||||
|
@ -529,7 +529,7 @@ class MonContextTest(CharmTestCase):
|
|||
'port': 70,
|
||||
'client_radosgw_gateway': {'rgw init timeout': 60},
|
||||
'ipv6': False,
|
||||
'rgw_zone': None,
|
||||
'rgw_zone': 'default',
|
||||
'fsid': 'testfsid',
|
||||
}
|
||||
self.assertEqual(expect, mon_ctxt())
|
||||
|
|
|
@ -68,6 +68,7 @@ TO_PATCH = [
|
|||
'filter_missing_packages',
|
||||
'ceph_utils',
|
||||
'multisite_deployment',
|
||||
'multisite',
|
||||
]
|
||||
|
||||
|
||||
|
@ -189,10 +190,15 @@ class CephRadosGWTests(CharmTestCase):
|
|||
|
||||
@patch.object(ceph_hooks, 'is_request_complete',
|
||||
lambda *args, **kwargs: True)
|
||||
def test_mon_relation(self):
|
||||
@patch.object(ceph_hooks, 'is_leader')
|
||||
@patch('charmhelpers.contrib.openstack.ip.resolve_address')
|
||||
@patch('charmhelpers.contrib.openstack.ip.config')
|
||||
def test_mon_relation(self, _config, _resolve_address, is_leader):
|
||||
_ceph = self.patch('ceph')
|
||||
_ceph.import_radosgw_key.return_value = True
|
||||
is_leader.return_value = True
|
||||
self.relation_get.return_value = 'seckey'
|
||||
self.multisite.list_zones.return_value = []
|
||||
self.socket.gethostname.return_value = 'testinghostname'
|
||||
ceph_hooks.mon_relation()
|
||||
self.relation_set.assert_not_called()
|
||||
|
@ -203,9 +209,14 @@ class CephRadosGWTests(CharmTestCase):
|
|||
|
||||
@patch.object(ceph_hooks, 'is_request_complete',
|
||||
lambda *args, **kwargs: True)
|
||||
def test_mon_relation_request_key(self):
|
||||
@patch.object(ceph_hooks, 'is_leader')
|
||||
@patch('charmhelpers.contrib.openstack.ip.resolve_address')
|
||||
@patch('charmhelpers.contrib.openstack.ip.config')
|
||||
def test_mon_relation_request_key(self, _config,
|
||||
_resolve_address, is_leader):
|
||||
_ceph = self.patch('ceph')
|
||||
_ceph.import_radosgw_key.return_value = True
|
||||
is_leader.return_value = True
|
||||
self.relation_get.return_value = 'seckey'
|
||||
self.socket.gethostname.return_value = 'testinghostname'
|
||||
self.request_per_unit_key.return_value = True
|
||||
|
@ -221,10 +232,15 @@ class CephRadosGWTests(CharmTestCase):
|
|||
|
||||
@patch.object(ceph_hooks, 'is_request_complete',
|
||||
lambda *args, **kwargs: True)
|
||||
def test_mon_relation_nokey(self):
|
||||
@patch.object(ceph_hooks, 'is_leader')
|
||||
@patch('charmhelpers.contrib.openstack.ip.resolve_address')
|
||||
@patch('charmhelpers.contrib.openstack.ip.config')
|
||||
def test_mon_relation_nokey(self, _config,
|
||||
_resolve_address, is_leader):
|
||||
_ceph = self.patch('ceph')
|
||||
_ceph.import_radosgw_key.return_value = False
|
||||
self.relation_get.return_value = None
|
||||
is_leader.return_value = True
|
||||
ceph_hooks.mon_relation()
|
||||
self.assertFalse(_ceph.import_radosgw_key.called)
|
||||
self.service_resume.assert_not_called()
|
||||
|
@ -493,6 +509,7 @@ class MiscMultisiteTests(CharmTestCase):
|
|||
'slave_relation_changed',
|
||||
'service_restart',
|
||||
'service_name',
|
||||
'multisite'
|
||||
]
|
||||
|
||||
_relation_ids = {
|
||||
|
|
Loading…
Reference in New Issue