From bbefaca2ef4103e99ff614a03bdb3315d87aa2fa Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Mon, 16 Jan 2017 01:31:05 -0800 Subject: [PATCH] Fix unnecessary for-loop and mis docs This is follow-up for https://review.openstack.org/#/c/419107 to address: - Remove unnecessary for-loop block that breaks the end of the loop always - Correct mis document says "two more times" but actually does only "one more time" Change-Id: I3d76275afc6448709a4b3588259e085bce7fa21d --- swift/common/ring/builder.py | 26 +++++++++++++------------- test/unit/common/ring/test_builder.py | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/swift/common/ring/builder.py b/swift/common/ring/builder.py index 327de56b25..0e9756bdff 100644 --- a/swift/common/ring/builder.py +++ b/swift/common/ring/builder.py @@ -1138,19 +1138,19 @@ class RingBuilder(object): overweight_dev_replica.sort( key=lambda dr: dr[0]['parts_wanted']) - for dev, replica in overweight_dev_replica: - # this is the most overweight_device holding a replica of this - # part we don't know where it's going to end up - but we'll - # pick it up and hope for the best. - dev['parts_wanted'] += 1 - dev['parts'] -= 1 - assign_parts[part].append(replica) - self.logger.debug( - "Gathered %d/%d from dev %d [weight forced]", - part, replica, dev['id']) - self._replica2part2dev[replica][part] = NONE_DEV - self._set_part_moved(part) - break + + dev, replica = overweight_dev_replica[0] + # this is the most overweight_device holding a replica of this + # part we don't know where it's going to end up - but we'll + # pick it up and hope for the best. + dev['parts_wanted'] += 1 + dev['parts'] -= 1 + assign_parts[part].append(replica) + self.logger.debug( + "Gathered %d/%d from dev %d [weight forced]", + part, replica, dev['id']) + self._replica2part2dev[replica][part] = NONE_DEV + self._set_part_moved(part) def _reassign_parts(self, reassign_parts, replica_plan): """ diff --git a/test/unit/common/ring/test_builder.py b/test/unit/common/ring/test_builder.py index 0f07673005..b5f740b8c7 100644 --- a/test/unit/common/ring/test_builder.py +++ b/test/unit/common/ring/test_builder.py @@ -743,7 +743,7 @@ class TestRingBuilder(unittest.TestCase): } self.assertEqual(zone_histogram, expected) - # After rebalancing two more times, we expect that everything is in a + # After rebalancing one more times, we expect that everything is in a # good state rb.rebalance(seed=3)