Skip to content

Commit 0242eea

Browse files
authored
CA-407322 - libs/rrd: Keep lastupdate XML field as int, XenCenter relies on it (#6320)
Instead of waiting for a complicated fix on XC side, switch back to outputting integers when dumping XMLs. Implementations that already switched to float should be good, since converting int to float is fine, but not the other way around. XML is an outdated format, JSON should be preferrably used, and it will keep using floats with larger precision. Fixes: a897b53 ("CA-391651: Use per-datasource last_updated timestamp during updating and archiving")
2 parents b604721 + d3612d1 commit 0242eea

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,14 @@ let xml_to_output internal rrd output =
999999
(fun output ->
10001000
tag "version" (data "0003") output ;
10011001
tag "step" (data (Int64.to_string rrd.timestep)) output ;
1002-
tag "lastupdate" (data (Utils.f_to_s rrd.last_updated)) output ;
1002+
(* XenCenter and other legacy users expect this to be an integer
1003+
representing the number of seconds, so keep it an integer to avoid
1004+
breaking them. Some other libraries (e.g. the Python rrd parser,
1005+
the C rrd parser, xenrt) will expect a float and can easily convert
1006+
an int to it. *)
1007+
tag "lastupdate"
1008+
(data (Printf.sprintf "%Ld" (Int64.of_float rrd.last_updated)))
1009+
output ;
10031010
do_dss rrd.rrd_dss output ;
10041011
do_rras rrd.rrd_rras output
10051012
)

0 commit comments

Comments
 (0)