Merge "Downgrade 'infinite' and 'unknown' capacity in weigher"
This commit is contained in:
commit
42641fe79e
|
@ -67,7 +67,11 @@ class CapacityWeigher(weights.BaseHostWeigher):
|
|||
if free_space == 'infinite' or free_space == 'unknown':
|
||||
#(zhiteng) 'infinite' and 'unknown' are treated the same
|
||||
# here, for sorting purpose.
|
||||
free = float('inf')
|
||||
|
||||
# As a partial fix for bug #1350638, 'infinite' and 'unknown' are
|
||||
# given the lowest weight to discourage driver from report such
|
||||
# capacity anymore.
|
||||
free = -1 if CONF.capacity_weight_multiplier > 0 else float('inf')
|
||||
else:
|
||||
free = math.floor(host_state.free_capacity_gb * (1 - reserved))
|
||||
return free
|
||||
|
|
|
@ -57,8 +57,8 @@ class FakeHostManager(host_manager.HostManager):
|
|||
'volume_backend_name': 'lvm4',
|
||||
'timestamp': None,
|
||||
'consistencygroup_support': True},
|
||||
'host5': {'total_capacity_gb': 2048,
|
||||
'free_capacity_gb': 500,
|
||||
'host5': {'total_capacity_gb': 'infinite',
|
||||
'free_capacity_gb': 'unknown',
|
||||
'allocated_capacity_gb': 1548,
|
||||
'reserved_percentage': 5,
|
||||
'timestamp': None},
|
||||
|
|
|
@ -59,6 +59,7 @@ class CapacityWeigherTestCase(test.TestCase):
|
|||
# host2: free_capacity_gb=300, free=300*(1-0.1)
|
||||
# host3: free_capacity_gb=512, free=256
|
||||
# host4: free_capacity_gb=200, free=200*(1-0.05)
|
||||
# host5: free_capacity_gb=unknown free=-1
|
||||
|
||||
# so, host1 should win:
|
||||
weighed_host = self._get_weighed_host(hostinfo_list)
|
||||
|
@ -74,6 +75,7 @@ class CapacityWeigherTestCase(test.TestCase):
|
|||
# host2: free_capacity_gb=300, free=-300*(1-0.1)
|
||||
# host3: free_capacity_gb=512, free=-256
|
||||
# host4: free_capacity_gb=200, free=-200*(1-0.05)
|
||||
# host5: free_capacity_gb=unknown free=-float('inf')
|
||||
|
||||
# so, host4 should win:
|
||||
weighed_host = self._get_weighed_host(hostinfo_list)
|
||||
|
@ -89,6 +91,7 @@ class CapacityWeigherTestCase(test.TestCase):
|
|||
# host2: free_capacity_gb=300, free=300*(1-0.1)*2
|
||||
# host3: free_capacity_gb=512, free=256*2
|
||||
# host4: free_capacity_gb=200, free=200*(1-0.05)*2
|
||||
# host5: free_capacity_gb=unknown free=-2
|
||||
|
||||
# so, host1 should win:
|
||||
weighed_host = self._get_weighed_host(hostinfo_list)
|
||||
|
|
Loading…
Reference in New Issue