Created
November 10, 2015 23:12
-
-
Save clayg/edf91dbdec109a01c811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/swift/common/ring/builder.py b/swift/common/ring/builder.py | |
index b5dfcef..14e1346 100644 | |
--- a/swift/common/ring/builder.py | |
+++ b/swift/common/ring/builder.py | |
@@ -1352,9 +1352,15 @@ class RingBuilder(object): | |
continue | |
assigned_replicanths = weighted_replicas_for_dev[dev['id']] | |
dev_tier = (dev['region'], dev['zone'], dev['ip'], dev['id']) | |
- for i in range(len(dev_tier) + 1): | |
- tier = dev_tier[:i] | |
- weighted_replicas_by_tier[tier] += assigned_replicanths | |
+ weighted_replicas_by_tier[dev_tier] = assigned_replicanths | |
+ | |
+ for tier_len in (4, 3, 2, 1): | |
+ tiers = set(t[:-1] for t in weighted_replicas_by_tier | |
+ if len(t) == tier_len) | |
+ for tier in tiers: | |
+ weighted_replicas_by_tier[tier] = sum( | |
+ r for t, r in weighted_replicas_by_tier.items() | |
+ if t[:-1] == tier) | |
# belts & suspenders/paranoia - at every level, the sum of | |
# wanted_replicas should be very close to the total number of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment