← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1282702] [NEW] Division by 0 error in CPU monitor

 

Public bug reported:

When enabling the CPU monitor, the code calculcates cputime as cputime =
float(stats["total"] - self._cpu_stats.get("total", 0)) ... under normal
scenarios, this is fine.

However, if the underlying stats haven't changed since the previous
call, the cputime can be 0 if the underlying stats haven't changed,
which results in nova-compute errors such as:

2014-02-20 12:29:48.949 81658 ERROR nova.compute.resource_tracker [-] float division
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker Traceback (most recent call last):
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/resource_tracker.py", line 277, in _get_host_metrics
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     metrics += monitor.get_metrics(nodename=nodename)
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/__init__.py", line 100, in get_metrics
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     ret = func(self, **kwargs)
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/virt/cpu_monitor.py", line 74, in wrapper
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     self._update_cpustat()
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/virt/cpu_monitor.py", line 151, in _update_cpustat
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     perc = (stats["user"] - self._cpu_stats.get("user", 0)) / cputime
2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker ZeroDivisionError: float division

The fix for this is probably to ensure that cputime is non-zero before
continuing the logic.

** Affects: nova
     Importance: Undecided
         Status: New

** Description changed:

- When enabling the CPU monitor, the code calculcated cputime as cputime =
+ When enabling the CPU monitor, the code calculcates cputime as cputime =
  float(stats["total"] - self._cpu_stats.get("total", 0)) ... under normal
  scenarios, this is fine.
  
  However, if the underlying stats haven't changed since the previous
  call, the cputime can be 0 if the underlying stats haven't changed,
  which results in nova-compute errors such as:
  
  2014-02-20 12:29:48.949 81658 ERROR nova.compute.resource_tracker [-] float division
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker Traceback (most recent call last):
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/resource_tracker.py", line 277, in _get_host_metrics
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     metrics += monitor.get_metrics(nodename=nodename)
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/__init__.py", line 100, in get_metrics
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     ret = func(self, **kwargs)
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/virt/cpu_monitor.py", line 74, in wrapper
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     self._update_cpustat()
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/virt/cpu_monitor.py", line 151, in _update_cpustat
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     perc = (stats["user"] - self._cpu_stats.get("user", 0)) / cputime
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker ZeroDivisionError: float division
  
  The fix for this is probably to ensure that cputime is non-zero before
  continuing the logic.

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1282702

Title:
  Division by 0 error in CPU monitor

Status in OpenStack Compute (Nova):
  New

Bug description:
  When enabling the CPU monitor, the code calculcates cputime as cputime
  = float(stats["total"] - self._cpu_stats.get("total", 0)) ... under
  normal scenarios, this is fine.

  However, if the underlying stats haven't changed since the previous
  call, the cputime can be 0 if the underlying stats haven't changed,
  which results in nova-compute errors such as:

  2014-02-20 12:29:48.949 81658 ERROR nova.compute.resource_tracker [-] float division
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker Traceback (most recent call last):
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/resource_tracker.py", line 277, in _get_host_metrics
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     metrics += monitor.get_metrics(nodename=nodename)
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/__init__.py", line 100, in get_metrics
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     ret = func(self, **kwargs)
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/virt/cpu_monitor.py", line 74, in wrapper
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     self._update_cpustat()
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker   File "/usr/lib/python2.6/site-packages/nova/compute/monitors/virt/cpu_monitor.py", line 151, in _update_cpustat
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker     perc = (stats["user"] - self._cpu_stats.get("user", 0)) / cputime
  2014-02-20 12:29:48.949 81658 TRACE nova.compute.resource_tracker ZeroDivisionError: float division

  The fix for this is probably to ensure that cputime is non-zero before
  continuing the logic.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1282702/+subscriptions


Follow ups

References