From 413173088c45340e0ecc89711726d08fceab0d53 Mon Sep 17 00:00:00 2001 From: Darrell Bishop Date: Fri, 17 Feb 2012 11:28:37 -0800 Subject: [PATCH] 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 --- AUTHORS | 1 + swift/common/ring/builder.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 492bb74133..087a510ed6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -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) diff --git a/swift/common/ring/builder.py b/swift/common/ring/builder.py index 96eccd5f75..32195eadaf 100644 --- a/swift/common/ring/builder.py +++ b/swift/common/ring/builder.py @@ -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): """