Skip to content

Commit

Permalink
Fix error if free_disk_gb is None in CellStateManager
Browse files Browse the repository at this point in the history
The field 'free_disk_gb' in Objects.ComputeNode can be nullable.
In CellStateManager._get_compute_hosts, we compute free_disk_mb
by 'free_disk_gb * 1024'. If the free_disk_gb is None, it will raise
a TypeError exception because None type can't multiply by an integer.
We should check this value, and if it's None, we just let it return
zero.

Closes-Bug: #1648983

Change-Id: I558d544ff838807c1d605cb5ed8d0e0fa97ab00e
  • Loading branch information
int32bit committed Dec 19, 2016
1 parent 6d486ff commit 58bf5d0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions nova/cells/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,9 @@ def _get_compute_hosts():

chost = compute_hosts[host]
chost['free_ram_mb'] += max(0, compute.free_ram_mb)
free_disk = compute.free_disk_gb * 1024
chost['free_disk_mb'] += max(0, free_disk)
chost['free_disk_mb'] += max(0, compute.free_disk_gb) * 1024
chost['total_ram_mb'] += max(0, compute.memory_mb)
total_disk = compute.local_gb * 1024
chost['total_disk_mb'] += max(0, total_disk)
chost['total_disk_mb'] += max(0, compute.local_gb) * 1024

_get_compute_hosts()
if not compute_hosts:
Expand Down

0 comments on commit 58bf5d0

Please sign in to comment.