From 66add4a785bdebf94392e7ec617e50845e6726ce Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Thu, 17 Feb 2011 02:49:24 +0000 Subject: [PATCH 1/2] workload_balancing.ml: Clean up whitespace before semantic change. Signed-off-by: Matthias Goergens --- ocaml/xapi/workload_balancing.ml | 41 +++++++++++++------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/ocaml/xapi/workload_balancing.ml b/ocaml/xapi/workload_balancing.ml index 17c259f2567..f45a1e86016 100755 --- a/ocaml/xapi/workload_balancing.ml +++ b/ocaml/xapi/workload_balancing.ml @@ -223,32 +223,25 @@ let generate_safe_param tag_name tag_value = Xml.to_string (Xml.Element(tag_name, [], [Xml.PCData tag_value])) (* if the call has failed we should try and retrieve the result code and any error messages*) -let parse_result_code meth xml_data response initial_error enable_log = - let code = - try - data_from_leaf (descend_and_match ["ResultCode"] xml_data) - with - | Xml_parse_failure error -> - raise_malformed_response' meth - (sprintf "After failing to retrieve valid response, an error code\ +let parse_result_code meth xml_data response initial_error enable_log = + let code = + try + data_from_leaf (descend_and_match ["ResultCode"] xml_data) + with | Xml_parse_failure error -> + raise_malformed_response' meth + (sprintf "After failing to retrieve valid response, an error code\ could not be found. Some data is missing or corrupt. Attempt retrieve valid response: (%s) -Attempt to retrieve error code: (%s)" - initial_error error) - (if enable_log - then - response - else - "Logging output disabled for this call.") - in - let message = - try - data_from_leaf (descend_and_match ["ErrorMessage"] xml_data) - with - | Xml_parse_failure msg -> "" - in - raise_internal_error [code; message] - +Attempt to retrieve error code: (%s)" + initial_error error) + (if enable_log + then response + else "Logging output disabled for this call.") in + let message = + try data_from_leaf (descend_and_match ["ErrorMessage"] xml_data) + with | Xml_parse_failure msg -> "" in + raise_internal_error [code; message] + let retrieve_inner_xml meth response enable_log= try descend_and_match (path_to_inner meth) response From fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Thu, 17 Feb 2011 03:08:52 +0000 Subject: [PATCH 2/2] Check error code, instead of assuming failure. parse_result_code of ocaml/xapi/workload_balancing.ml is called if there is a result from a call to the WLB server. In Windows, WLB's Windows-Communication-Foundation web service returns no result when a call is successful (obeying the WCF data contract). When the same code is run under Mono, the web service returns ResultCode = 0, which XAPI is currently treating as an actual error. The change is meant to check the actual code rather than just assuming that since there is one, that there was an error. Brian Donegan sent in the original patch, that Matthias adapted. Signed-off-by: Matthias Goergens --- ocaml/xapi/workload_balancing.ml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ocaml/xapi/workload_balancing.ml b/ocaml/xapi/workload_balancing.ml index f45a1e86016..e3079c352f1 100755 --- a/ocaml/xapi/workload_balancing.ml +++ b/ocaml/xapi/workload_balancing.ml @@ -237,10 +237,11 @@ Attempt to retrieve error code: (%s)" (if enable_log then response else "Logging output disabled for this call.") in - let message = - try data_from_leaf (descend_and_match ["ErrorMessage"] xml_data) - with | Xml_parse_failure msg -> "" in - raise_internal_error [code; message] + if (code != 0) then + let message = + try data_from_leaf (descend_and_match ["ErrorMessage"] xml_data) + with | Xml_parse_failure msg -> "" in + raise_internal_error [code; message] let retrieve_inner_xml meth response enable_log= try