Comment 0 for bug 1488696

Revision history for this message
Joe Cropper (jwcroppe) wrote : Compute *.percent metrics are always 0

It seems that with the recent update to the Nova virt metrics framework, the 'percent' related metrics always 0 now in the database. After tracing through the code, I determined tha the virt_driver and resource tracker will still behaving properly and the compute_driver::get_host_cpu_stats work as expected.

It seems that the root cause is:

https://github.com/openstack/nova/blob/master/nova/objects/monitor_metric.py#L29

This shows that the metric value is expected to be an integer in nova object, but the percentage metrics are all floating points and range in value from [0, 1] -- e.g., so 17.5% has been historically represented as 0.175 using the monitor framework. This causes the percentage values to assume the value 0, as shown below in the snippet from `select metrics from compute_nodes`:

"cpu.user.percent", "value": 0,
"cpu.percent", "value": 0,

...so on and so forth.

I'm not sure if the intended behavior here was to only support integer-style values. If so, we probably need to do some "multiply by 100" logic when putting them into the MonitorMetric object and then divide by 100 (we'll lose precision, though) when we convert back to the values stored in the compute_nodes.metrics column, otherwise we will break backwards compatibility in terms of what folks were expecting to find in the DB.