xapi-project / xcp-networkd

The XCP networking daemon
Other
14 stars 42 forks source link

CA-291197: Toolstack no longer ignores junk at the end of JSON-RPC re… #142

Closed YarsinCitrix closed 6 years ago

YarsinCitrix commented 6 years ago

…sponses from pvsproxy

This is resulted by CA-236855, in that the read strategy is changed to assume all good data will come from PVSproxy side. However, in testing, it is found a bug in PVSproxy, which was not fatal locally, but resulted issue in overall scenario. It is decided to enhance the solution a little bit based on previous change.

The updates as to integrate some part in the old byte by byte read, where a function is used to prescreen the data read from PVSproxy, and tailing junk is discarded, so the only json part is further processed. Here we most copied the original function, but added:

  1. to get input chars from a string;
  2. to tolerant heading spaces/junk (in screening);

Signed-off-by: YarsinCitrix yarsin.he@citrix.com

YarsinCitrix commented 6 years ago

I was trying to alter a little bit Yojson to get just one json out and ignores tailing junk, and then pass it to jsonrpc. The Yojson part could be done, as most of the related functions are exposed in read.mli. However, functions like json_to_rpc in jsonrpc is not exposed, so we cannot create an updated jsonrpc module to adopt the json out of yojson from the input string. The other way left is just use the updated Yojson to get the json, from the initial output string, and then convert the json back to string, and pass it to jsonrpc as normal. This is considered a little bit complex and less efficient, after discussion with Yang. So we are trying to start with integrate the original code.

lindig commented 6 years ago

Just some general remarks:

edwintorok commented 6 years ago

I agree with @lindig last point above, this sounds like a bug that should be fixed in pvsproxy and not here.

robhoes commented 6 years ago

It is also being fixed in pvsproxy, but we should be more robust in xcp-networkd as well. And we were robust in this way until a recent patch, which is another reason to revert to this behaviour for compatibility.

jonludlam commented 6 years ago

we kind-of have to fix this in xcp-networkd as well as pvsproxy because pvsproxy won't be upgraded at the same time as xcp-networkd (pvsproxy is delivered separately). Ideally I'd like to remove this in the next release.

robhoes commented 6 years ago

Meanwhile, the pvsproxy has been fixed to not have junk at the end of the message anymore, so the problem is now less urgent. However, we still want to fix it here as well (as hinted at above), but there is no need to make a temporary fix first. @jonludlam says that an update to ocaml-rpc to address this would not be too hard to do, and recommends doing that instead and closing this PR. So let's do that.