diff --git a/.gitignore b/.gitignore index 8e3abb7a..6b54800c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ xenial/ precise/ tests/cirros-*-disk.img .unit-state.db +.idea diff --git a/config.yaml b/config.yaml index 17d205c0..4bd5950b 100644 --- a/config.yaml +++ b/config.yaml @@ -268,6 +268,21 @@ options: rbd pool has been created, changing this value will not have any effect (although it can be changed in ceph by manually configuring your ceph cluster). + ceph-pool-weight: + type: int + default: 30 + description: | + Defines a relative weighting of the pool as a percentage of the total + amount of data in the Ceph cluster. This effectively weights the number + of placement groups for the pool created to be appropriately portioned + to the amount of data expected. For example, if the ephemeral volumes + for the OpenStack compute instances are expected to take up 20% of the + overall configuration then this value would be specified as 20. Note - + it is important to choose an appropriate value for the pool weight as + this directly affects the number of placement groups which will be + created for the pool. The number of placement groups for a pool can + only be increased, never decreased - so it is important to identify the + percent of data that will likely reside in the pool. # Other configuration options sysctl: type: string diff --git a/hooks/nova_compute_hooks.py b/hooks/nova_compute_hooks.py index 61c07fff..602f3628 100755 --- a/hooks/nova_compute_hooks.py +++ b/hooks/nova_compute_hooks.py @@ -332,8 +332,10 @@ def ceph_joined(): def get_ceph_request(): rq = CephBrokerRq() + name = config('rbd-pool') replicas = config('ceph-osd-replication-count') - rq.add_op_create_pool(name=config('rbd-pool'), replica_count=replicas) + weight = config('ceph-pool-weight') + rq.add_op_create_pool(name=name, replica_count=replicas, weight=weight) return rq diff --git a/unit_tests/test_nova_compute_hooks.py b/unit_tests/test_nova_compute_hooks.py index b57ef3cd..9936d432 100644 --- a/unit_tests/test_nova_compute_hooks.py +++ b/unit_tests/test_nova_compute_hooks.py @@ -500,6 +500,15 @@ class NovaComputeRelationsTests(CharmTestCase): self.assertEquals(ex, configs.write.call_args_list) self.service_restart.assert_called_with('nova-compute') + @patch('charmhelpers.contrib.storage.linux.ceph.CephBrokerRq' + '.add_op_create_pool') + def test_get_ceph_request(self, mock_add_op): + self.test_config.set('rbd-pool', 'nova') + self.test_config.set('ceph-osd-replication-count', 3) + self.test_config.set('ceph-pool-weight', 28) + hooks.get_ceph_request() + mock_add_op.assert_called_with(name='nova', replica_count=3, weight=28) + @patch.object(hooks, 'CONFIGS') def test_neutron_plugin_changed(self, configs): self.nova_metadata_requirement.return_value = (True,