Merge lp:~james-page/charm-helpers/lp1607961 into lp:charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 618
Proposed branch: lp:~james-page/charm-helpers/lp1607961
Merge into: lp:charm-helpers
Diff against target: 41 lines (+13/-0)
2 files modified
charmhelpers/contrib/storage/linux/ceph.py (+6/-0)
tests/contrib/storage/test_linux_ceph.py (+7/-0)
To merge this branch: bzr merge lp:~james-page/charm-helpers/lp1607961
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+301753@code.launchpad.net

Description of the change

Ensure that a minimum PG count of 2 is used in small OSD configurations with pools with very low weights.

To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/storage/linux/ceph.py'
2--- charmhelpers/contrib/storage/linux/ceph.py 2016-07-13 18:56:39 +0000
3+++ charmhelpers/contrib/storage/linux/ceph.py 2016-08-02 09:12:06 +0000
4@@ -87,6 +87,7 @@
5 DEFAULT_PGS_PER_OSD_TARGET = 100
6 DEFAULT_POOL_WEIGHT = 10.0
7 LEGACY_PG_COUNT = 200
8+DEFAULT_MINIMUM_PGS = 2
9
10
11 def validator(value, valid_type, valid_range=None):
12@@ -266,6 +267,11 @@
13 target_pgs_per_osd = config('pgs-per-osd') or DEFAULT_PGS_PER_OSD_TARGET
14 num_pg = (target_pgs_per_osd * osd_count * percent_data) // pool_size
15
16+ # NOTE: ensure a sane minimum number of PGS otherwise we do get any
17+ # reasonable data distribution in minimal OSD configurations
18+ if num_pg < DEFAULT_MINIMUM_PGS:
19+ num_pg = DEFAULT_MINIMUM_PGS
20+
21 # The CRUSH algorithm has a slight optimization for placement groups
22 # with powers of 2 so find the nearest power of 2. If the nearest
23 # power of 2 is more than 25% below the original value, the next
24
25=== modified file 'tests/contrib/storage/test_linux_ceph.py'
26--- tests/contrib/storage/test_linux_ceph.py 2016-07-13 18:56:39 +0000
27+++ tests/contrib/storage/test_linux_ceph.py 2016-08-02 09:12:06 +0000
28@@ -271,6 +271,13 @@
29 pg_num = p.get_pgs(pool_size=3, percent_data=100)
30 self.assertEquals(512, pg_num)
31
32+ # Test small % weight with minimal OSD count (3)
33+ get_osds.return_value = range(1, 3)
34+ self.test_config.set('expected-osd-count', None)
35+ self.test_config.set('pgs-per-osd', None)
36+ pg_num = p.get_pgs(pool_size=3, percent_data=0.1)
37+ self.assertEquals(2, pg_num)
38+
39 @patch.object(ceph_utils, 'get_osds')
40 def test_replicated_pool_create_old_ceph(self, get_osds):
41 get_osds.return_value = None

Subscribers

People subscribed via source and target branches