In Ring Build Negative value is allow in <part_power> parameter

Bug #1697860 reported by Adeeb khan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
swift-bench
New
Undecided
Unassigned

Bug Description

When executing swift-ring-builder command by passing negative value for <part_power> parameter, use case is executed successfully. When user rebalance the ring it does throw error "TypeError: integer argument expected, got float" . This happens because <part_power> is used to calculate number of partitions (2^<part_power>). When <part_power> is negative, number of partitions are calculated as float value which is incorrect.
Steps:
1.Build a ring
swift-ring-builder account.builder create -10 2 1 <<< There should be an error here >>>
2.Add device to it.
swift-ring-builder account.builder add --region 1 --zone 1 --ip 10.0.2.15 --port 6202 --device sda1 --weight 100
swift-ring-builder account.builder add --region 1 --zone 1 --ip 10.0.2.15 --port 6202 --device loop0 --weight 100
3.Rebalance the ring.
swift-ring-builder account.builder rebalance

Error message:
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 859, in rebalance
    parts, balance, removed_devs = builder.rebalance(seed=get_seed(3))
  File "/usr/lib/python2.7/site-packages/swift/common/ring/builder.py", line 454, in rebalance
    self._last_part_moves = array('B', itertools.repeat(0, self.parts))
TypeError: integer argument expected, got float

Error is displayed after step 3 but error should be displayed after executing step 1.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.31.1

This issue was fixed in the openstack/swift 2.31.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.