summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
Diffstat (limited to 'nova/compute')
-rwxr-xr-xnova/compute/manager.py8
-rw-r--r--nova/compute/utils.py9
2 files changed, 10 insertions, 7 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 2390eb3c3..8434a64ca 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -3782,7 +3782,7 @@ class ComputeManager(manager.SchedulerDependentManager):
return compute_host_bdms
- def _update_volume_usage_cache(self, context, vol_usages, refreshed):
+ def _update_volume_usage_cache(self, context, vol_usages):
"""Updates the volume usage cache table with a list of stats."""
for usage in vol_usages:
# Allow switching of greenthreads between queries.
@@ -3792,8 +3792,7 @@ class ComputeManager(manager.SchedulerDependentManager):
usage['rd_bytes'],
usage['wr_req'],
usage['wr_bytes'],
- usage['instance'],
- last_refreshed=refreshed)
+ usage['instance'])
@periodic_task.periodic_task
def _poll_volume_usage(self, context, start_time=None):
@@ -3820,8 +3819,7 @@ class ComputeManager(manager.SchedulerDependentManager):
except NotImplementedError:
return
- refreshed = timeutils.utcnow()
- self._update_volume_usage_cache(context, vol_usages, refreshed)
+ self._update_volume_usage_cache(context, vol_usages)
@periodic_task.periodic_task
def _report_driver_status(self, context):
diff --git a/nova/compute/utils.py b/nova/compute/utils.py
index 1ce115b20..621f558cb 100644
--- a/nova/compute/utils.py
+++ b/nova/compute/utils.py
@@ -290,8 +290,13 @@ def usage_volume_info(vol_usage):
tot_refreshed = vol_usage['tot_last_refreshed']
curr_refreshed = vol_usage['curr_last_refreshed']
- last_refreshed_time = (tot_refreshed if tot_refreshed > curr_refreshed
- else curr_refreshed)
+ if tot_refreshed and curr_refreshed:
+ last_refreshed_time = max(tot_refreshed, curr_refreshed)
+ elif tot_refreshed:
+ last_refreshed_time = tot_refreshed
+ else:
+ # curr_refreshed must be set
+ last_refreshed_time = curr_refreshed
usage_info = dict(
volume_id=vol_usage['volume_id'],