Skip to content

Commit fef11a3

Browse files
authored
CA-408126 follow-up: Fix negative ds_min and RRD values in historical archives (#6359)
When reading RRD archives from XML, make sure ds_min is (almost never) negative, this will convert negative values to NaNs as well.
2 parents 18e93ff + c1f02ed commit fef11a3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ocaml/libs/xapi-rrd/lib/rrd.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,11 @@ let from_xml input =
744744
let name = get_el "name" i in
745745
let type_ = get_el "type" i in
746746
let min_hb = get_el "minimal_heartbeat" i in
747-
let min = get_el "min" i in
747+
(* CA-408126 - work around negative data in historical RRDs
748+
where ds_min could have been incorrectly set to neg_infinity.
749+
Setting ds_min to 0. means Fring.make below will turn negative
750+
historical values to NaNs.*)
751+
let min = max (float_of_string (get_el "min" i)) 0. in
748752
let max = get_el "max" i in
749753
ignore (get_el "last_ds" i) ;
750754
let value = get_el "value" i in
@@ -767,7 +771,7 @@ let from_xml input =
767771
failwith "Bad format"
768772
)
769773
; ds_mrhb= float_of_string min_hb
770-
; ds_min= float_of_string min
774+
; ds_min= min
771775
; ds_max= float_of_string max
772776
; ds_last= VT_Unknown
773777
; (* float_of_string "last_ds"; *)

0 commit comments

Comments
 (0)