swift-ring-builder inconsistent behavior if only devices with 0 weight in the ring

Bug #1651087 reported by Christian Schwede on 2016-12-19
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Low
Christian Schwede

Bug Description

When there are only devices with a weight of 0 left in the ring the swift-ring-builder CLI
raises an exception. However, without any device in the ring this doesn't happen and the output simply tells me there are 0 devices in the ring:

[stack@undercloud tmp]$ swift-ring-builder sample.builder create 8 1 0
[stack@undercloud tmp]$ swift-ring-builder sample.builder
sample.builder, build version 0
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 0 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file sample.ring.gz is obsolete

Now let's add a device with a weight of 0:

[stack@undercloud tmp]$ swift-ring-builder sample.builder add r1z1-127.0.0.1:6200/sdb_ 0
Device d0r1z1-127.0.0.1:6200R127.0.0.1:6200/sdb_"" with 0.0 weight got id 0

And try to output the builder again:

[stack@undercloud tmp]$ swift-ring-builder sample.builder
sample.builder, build version 1
Traceback (most recent call last):
  File "/usr/bin/swift-ring-builder", line 24, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/swift/cli/ringbuilder.py", line 1287, in main
    getattr(Commands, command, Commands.unknown)()
  File "/usr/lib/python2.7/site-packages/swift/cli/ringbuilder.py", line 481, in default
    balance = builder.get_balance()
  File "/usr/lib/python2.7/site-packages/swift/common/ring/builder.py", line 704, in get_balance
    balance_per_dev = self._build_balance_per_dev()
  File "/usr/lib/python2.7/site-packages/swift/common/ring/builder.py", line 676, in _build_balance_per_dev
    weight_of_one_part = self.weight_of_one_part()
  File "/usr/lib/python2.7/site-packages/swift/common/ring/builder.py", line 157, in weight_of_one_part
    raise exceptions.EmptyRingError('There are no devices in this '
swift.common.exceptions.EmptyRingError: There are no devices in this ring, or all devices have been deleted

This is wrong (there is an device), but also an inconsistent behaviour. Even if it would be true that there is no device, the ring-builder shouldn't raise an exception in some cases - either never, or always.

Changed in swift:
status: New → In Progress
clayg (clay-gerrard) on 2016-12-19
summary: - swift-ring-builder incosistend behavior if only devices with 0 weight in
- the ring
+ swift-ring-builder inconsistent behavior if only devices with 0 weight
+ in the ring
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers