Noticed while reviewing https://review.openstack.org/#/c/525192/2 - would be nicer if this case also showed a clean error message:
- new ring builder
- add a dev
- remove the dev
- display ring builder -> traceback
swift@vm-16:~/swift$ git log --oneline -n 1
c53d5bf Merge "Better handle missing files in _construct_from_data_file"
swift@vm-16:~/swift$ swift-ring-builder foo create 8 3 1
swift@vm-16:~/swift$ swift-ring-builder foo add r1z1-127.0.0.1:3180/sdb1 100
Device d0r1z1-127.0.0.1:3180R127.0.0.1:3180/sdb1_"" with 100.0 weight got id 0
swift@vm-16:~/swift$ swift-ring-builder foo remove r1z1-127.0.0.1:3180/sdb1
d0r1z1-127.0.0.1:3180R127.0.0.1:3180/sdb1_"" marked for removal and will be removed next rebalance.
swift@vm-16:~/swift$ swift-ring-builder foo
foo, build version 2, id 2c4ad2706fbc4698b1378afdc954c3e7
Traceback (most recent call last):
File "/usr/local/bin/swift-ring-builder", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/home/swift/swift/bin/swift-ring-builder", line 24, in <module>
sys.exit(main())
File "/home/swift/swift/swift/cli/ringbuilder.py", line 1482, in main
getattr(Commands, command, Commands.unknown)()
File "/home/swift/swift/swift/cli/ringbuilder.py", line 485, in default
balance = builder.get_balance()
File "/home/swift/swift/swift/common/ring/builder.py", line 779, in get_balance
balance_per_dev = self._build_balance_per_dev()
File "/home/swift/swift/swift/common/ring/builder.py", line 751, in _build_balance_per_dev
weight_of_one_part = self.weight_of_one_part()
File "/home/swift/swift/swift/common/ring/builder.py", line 217, 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
fix proposed here https:/ /review. openstack. org/#/c/ 529791/