Make initial ring balance robust to "holes".

Make initial ring building robust to "holes" (None values in self.devs).
Having these None values in the self.devs array is fine later in the
builder file's life.  Making it okay upon initial balance makes
builder files easier to programatically manipulate.

Change-Id: Icca9c1aa4fd0aae12168998acc39e52f95989b7d
This commit is contained in:
Darrell Bishop 2012-02-17 11:28:37 -08:00
parent 15faa1e672
commit 413173088c
2 changed files with 6 additions and 3 deletions

View File

@ -16,6 +16,7 @@ Chuck Thier (cthier@gmail.com)
Contributors
------------
Joe Arnold (joe@swiftstack.com)
Darrell Bishop (darrell@swiftstack.com)
James E. Blair (james.blair@rackspace.com)
Chmouel Boudjnah (chmouel@chmouel.com)
Russell Bryant (rbryant@redhat.com)

View File

@ -400,8 +400,9 @@ class RingBuilder(object):
restrictions.
"""
for dev in self.devs:
dev['sort_key'] = \
'%08x.%04x' % (dev['parts_wanted'], randint(0, 0xffff))
if dev is not None:
dev['sort_key'] = \
'%08x.%04x' % (dev['parts_wanted'], randint(0, 0xffff))
available_devs = sorted((d for d in self.devs if d is not None),
key=lambda x: x['sort_key'])
self._replica2part2dev = \
@ -431,7 +432,8 @@ class RingBuilder(object):
self._last_part_moves = array('B', (0 for _junk in xrange(self.parts)))
self._last_part_moves_epoch = int(time())
for dev in self.devs:
del dev['sort_key']
if dev is not None:
del dev['sort_key']
def _update_last_part_moves(self):
"""