Skip to content

Commit 9385c0d

Browse files
committed
CA-85545: do not spamm the logs with harmless parsing errors
Signed-off-by: Thomas Gazagnaire <[email protected]>
1 parent 5ec0668 commit 9385c0d

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

ocaml/xapi/helpers.ml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,25 +302,17 @@ let rolling_upgrade_in_progress ~__context =
302302
false
303303

304304
let parse_boot_record ~string:lbr =
305-
try
306-
begin
307-
(* initially, try to parse lbr using new default sexpr format *)
308-
API.From.vM_t "ret_val" (Xmlrpc_sexpr.sexpr_str_to_xmlrpc lbr)
309-
end
310-
with
311-
(* xapi import/upgrade fallback: if sexpr parsing fails, try parsing using legacy xmlrpc format*)
312-
Api_errors.Server_error (code,_) when code=Api_errors.field_type_error ->
313-
begin
314-
API.From.vM_t "ret_val" (Xml.parse_string lbr)
315-
end
305+
match Xmlrpc_sexpr.sexpr_str_to_xmlrpc lbr with
306+
| None -> API.From.vM_t "ret_val" (Xml.parse_string lbr)
307+
| Some xml -> API.From.vM_t "ret_val" xml
316308

317309
(** Fetch the configuration the VM was booted with *)
318310
let get_boot_record_of_record ~__context ~string:lbr ~uuid:current_vm_uuid =
319311
try
320312
parse_boot_record lbr
321313
with e ->
322-
warn "Warning: exception '%s' parsing last booted record - returning current record instead" (ExnHelper.string_of_exn e);
323-
Db.VM.get_record ~__context ~self:(Db.VM.get_by_uuid ~__context ~uuid:current_vm_uuid)
314+
(* warn "Warning: exception '%s' parsing last booted record (%s) - returning current record instead" lbr (ExnHelper.string_of_exn e); *)
315+
Db.VM.get_record ~__context ~self:(Db.VM.get_by_uuid ~__context ~uuid:current_vm_uuid)
324316

325317
let get_boot_record ~__context ~self =
326318
let r = Db.VM.get_record_internal ~__context ~self in

ocaml/xapi/xmlrpc_sexpr.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ let sexpr_to_xmlrpc (root:SExpr.t) =
153153
let sexpr_str_to_xmlrpc (sexpr_str:string) =
154154
let sroot1 = SExpr_TS.of_string sexpr_str in
155155
let xroot1 = sexpr_to_xmlrpc sroot1 in
156-
(xroot1)
156+
match xroot1 with
157+
| Element("value", [], [Element("WRONG_SEXPR",[],[])]) -> None
158+
| _ -> Some xroot1
157159

158160
(** helper function that maps between xml-rpc trees and sexpr strings *)
159161
let xmlrpc_to_sexpr_str xml=

0 commit comments

Comments
 (0)