get_ring method can make empty rings
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Object Storage (swift) |
Fix Released
|
Low
|
Christopher Bartz |
Bug Description
You can't rebalance an empty builder, because you can't have zero devices in a ring.
Even if rebalance worked validate is gunna check you have devices, because you can't have a zero devices in a ring.
You can't remove a device if it's the last one, because you dan't have zero devices in a ring.
You can't set the weight of all devices to 0, because you can't have zero devices in a ring.
If you try use write_ring on an empty builder, you get a *warning*, because you can't have zero devices in the ring...
... but it still does it - and you get a ring with zero devices.
I'm not sure exactly the history behind the write_ring's insane ability to create these quite useless bytes on disk - but from a code sanity point of view I think it would drastically better if most of the checks there that are ever so carefully going about printing the *warning* were dropped right down into RingBuilder.
Removing the ability entirely to have an invalid set of RingData on which write_ring can call save.
Swift definitely can't make any use of these empty rings, and it blows up in terrible Index/ValueError-y ways if you give it rings that didn't get proper validation.
If anyone ever thinks they *really* need an empty Ring on disk - they can run this:
>>> from swift.common.ring import RingData
>>> part_power = 10
>>> RingData([], [], part_power)
But let's not let RingBuilder give it up without a fight.
description: | updated |
Changed in swift: | |
assignee: | nobody → Christopher Bartz (bartz) |
swift@ vm-15:~ /swift$ swift-ring-builder foo create 8 1 1 15:~/swift$ swift-ring-builder foo ba95c881b74780b 66 15:~/swift$ swift-ring-builder foo write_ring 15:~/swift$ ls foo.ring.gz
swift@vm-
foo, build version 0, id 0261d562a8d64d2
256 partitions, 1.000000 replicas, 0 regions, 0 zones, 0 devices, 0.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file foo.ring.gz not found, probably it hasn't been written yet
swift@vm-
Warning: Writing an empty ring
swift@vm-
foo.ring.gz