mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Bug #2741: Do not use floats to calculate cpu quotas in fsck
This commit is contained in:
parent
1e096aa69c
commit
3a0fefc1c1
@ -22,7 +22,7 @@ require 'set'
|
||||
require 'nokogiri'
|
||||
|
||||
module OneDBFsck
|
||||
VERSION = "4.5.0"
|
||||
VERSION = "4.5.80"
|
||||
|
||||
def db_version
|
||||
VERSION
|
||||
@ -1368,7 +1368,7 @@ module OneDBFsck
|
||||
oid = doc.root.at_xpath("ID").text.to_i
|
||||
|
||||
# VM quotas
|
||||
cpu_used = 0.0
|
||||
cpu_used = 0
|
||||
mem_used = 0
|
||||
vms_used = 0
|
||||
vol_used = 0
|
||||
@ -1385,9 +1385,8 @@ module OneDBFsck
|
||||
# VM quotas
|
||||
vmdoc.root.xpath("TEMPLATE/CPU").each { |e|
|
||||
# truncate to 2 decimals
|
||||
cpu = (e.text.to_f * 100).to_i / 100.0
|
||||
cpu = (e.text.to_f * 100).to_i
|
||||
cpu_used += cpu
|
||||
cpu_used = (cpu_used * 100).to_i / 100.0
|
||||
}
|
||||
|
||||
vmdoc.root.xpath("TEMPLATE/MEMORY").each { |e|
|
||||
@ -1457,6 +1456,8 @@ module OneDBFsck
|
||||
# Check if the float value or the string representation mismatch,
|
||||
# but ignoring the precision
|
||||
|
||||
cpu_used = (cpu_used / 100.0)
|
||||
|
||||
different = ( e.text.to_f != cpu_used ||
|
||||
![sprintf('%.2f', cpu_used), sprintf('%.1f', cpu_used), sprintf('%.0f', cpu_used)].include?(e.text) )
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user