mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-17 18:33:32 +09:00
Bug #2741: Do not use floats to calculate cpu quotas in fsck
(cherry picked from commit 3a0fefc1c1)
Conflicts:
src/onedb/fsck.rb
This commit is contained in:
1 parent
95785b264b
commit
0c360cd2b2
1 file changed
+4
-3
+4
-3
@@ -1348,7 +1348,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
|
||||
@@ -1365,9 +1365,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|
|
||||
@@ -1437,6 +1436,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) )
|
||||
|
||||
|
||||
Reference in new issue
Block a user