Report reserved_host_disk_mb in GB not KB

We were reporting reserved_host_disk_mb as GB not KB.

This created this log message:
  Invalid inventory for 'DISK_GB' on resource provider <uuid>.
  The reserved value is greater than or equal to total.

This corrects the reporting of reserved_host_disk_mb to the placement
API when updating the compute node inventory.

Closes-Bug: #1661243

Change-Id: I5573c82eb99cde13c407c8d6a06ecb04165ab9c5
This commit is contained in:
John Garbutt
2017-02-02 12:51:36 +00:00
parent f40467b0eb
commit d4502e1f53
2 changed files with 11 additions and 3 deletions

View File

@ -14,6 +14,7 @@
# under the License.
import functools
import math
import re
from six.moves.urllib import parse
import time
@ -115,9 +116,16 @@ def _compute_node_to_inventory_dict(compute_node):
'allocation_ratio': compute_node.ram_allocation_ratio,
}
if compute_node.local_gb > 0:
reserved_disk_gb = 0
# TODO(johngarbutt) We should either move to reserved_host_disk_gb
# or start tracking DISK_MB.
if CONF.reserved_host_disk_mb:
reserved_disk_gb = CONF.reserved_host_disk_mb / 1024.0
# ensure we reserve enough space by rounding up to nearest GB
reserved_disk_gb = int(math.ceil(reserved_disk_gb))
result[DISK_GB] = {
'total': compute_node.local_gb,
'reserved': CONF.reserved_host_disk_mb * 1024,
'reserved': reserved_disk_gb,
'min_unit': 1,
'max_unit': compute_node.local_gb,
'step_size': 1,

View File

@ -556,7 +556,7 @@ class TestComputeNodeToInventoryDict(test.NoDBTestCase):
disk_allocation_ratio=1.0)
self.flags(reserved_host_memory_mb=1000)
self.flags(reserved_host_disk_mb=2000)
self.flags(reserved_host_disk_mb=200)
result = report._compute_node_to_inventory_dict(compute_node)
@ -579,7 +579,7 @@ class TestComputeNodeToInventoryDict(test.NoDBTestCase):
},
'DISK_GB': {
'total': compute_node.local_gb,
'reserved': CONF.reserved_host_disk_mb * 1024,
'reserved': 1, # this is ceil(1000/1024)
'min_unit': 1,
'max_unit': compute_node.local_gb,
'step_size': 1,