diff --git a/swift/common/ring/builder.py b/swift/common/ring/builder.py index 2244de65a8..293d522e08 100644 --- a/swift/common/ring/builder.py +++ b/swift/common/ring/builder.py @@ -146,6 +146,10 @@ class RingBuilder(object): def part_shift(self): return 32 - self.part_power + @property + def ever_rebalanced(self): + return self._last_part_moves is not None + def _set_part_moved(self, part): self._last_part_moves[part] = 0 byte, bit = divmod(part, 8) @@ -485,7 +489,7 @@ class RingBuilder(object): old_replica2part2dev = copy.deepcopy(self._replica2part2dev) - if self._last_part_moves is None: + if not self.ever_rebalanced: self.logger.debug("New builder; performing initial balance") self._last_part_moves = array('B', itertools.repeat(0, self.parts)) self._update_last_part_moves() diff --git a/swift/common/ring/composite_builder.py b/swift/common/ring/composite_builder.py index f8789763b8..7f4dc9944a 100644 --- a/swift/common/ring/composite_builder.py +++ b/swift/common/ring/composite_builder.py @@ -719,7 +719,7 @@ class CooperativeRingBuilder(RingBuilder): :return: True if the partition can be moved, False otherwise. """ # called by parent_builder - now forward to the superclass - return (not self._last_part_moves or + return (not self.ever_rebalanced or super(CooperativeRingBuilder, self)._can_part_move(part)) def _update_last_part_moves(self):