Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-26352 Port xcp-idl/network interface from Camlp4 to PPX #189

Closed

Conversation

krizex
Copy link
Member

@krizex krizex commented Jan 17, 2018

Signed-off-by: Yang Qian yang.qian@citrix.com

Prototype of porting network interface to ppx.

Because of below cases, we have to update client and server part accordingly:

  1. type dhcp_options should change from polymorphic variant to variant
  2. variant Basic of type port_kind should change to Basic_port because the Basic definition conflicts with that in rpc.ml
  3. field ipv4_routes of type interface_config_t should change to record.
  4. the optional arguments of interfaces should move to use option so all client and server part code should update at same time.
  5. rpc_of_x and x_of_rpc function not exists yet, should replace them with Rpcmarshal.marshal and Rpcmarshal.unmarshal
  6. Move the definition of exceptions to xcp-networkd and update the code of processing exceptions in client part

This PR should goes in with xapi-project/xcp-networkd#128 and xapi-project/xen-api#3439

@krizex
Copy link
Member Author

krizex commented Jan 17, 2018

@robhoes @jonludlam Please have a look and help confirm whether I am on the right direction.

@coveralls
Copy link

coveralls commented Jan 17, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling 6cdd636 on krizex:private/yangqi/CP-26352 into 144fa27 on xapi-project:ppx_network.

@robhoes
Copy link
Member

robhoes commented Jan 17, 2018

@minishrink, could you please review this, since you have the most experience with this stuff now?

interface_config = [];
bridge_config = [];
gateway_interface = None;
dns_interface = None
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need these default_* any more because you've got the in-line defaults defined above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, idl do not need this anymore, but xcp-networkd need them, so I will move them to xcp-networkd repo.

@krizex
Copy link
Member Author

krizex commented Jan 17, 2018 via email

network/jbuild Outdated
@@ -32,7 +32,7 @@ let () = Printf.ksprintf Jbuild_plugin.V1.send {|
((name xcp_network_interface)
(public_name xcp.network.interface)
(modules (network_interface))
(flags (:standard -w -39 %s))
(flags (:standard -w -39 -w -34 -w -27 %s))
Copy link
Collaborator

@mseri mseri Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not silence warnings 27 and 34. In general they can be fixed prefixing variables or types with _ or deleting them if they are unused or unexposed. They can also be silenced locally if really needed. But I'd rather see them than ignore them

Copy link
Member Author

@krizex krizex Jan 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-w -34 has been deleted, but I cannot delete -w -27 because if delete it the compiler will complains

File "network/network_interface.ml", line 116, characters 0-611:
Warning 27: unused variable x.

The corresponding code is:

type interface_config_t = {   (* Line 116 *)
  ipv4_conf: ipv4 [@default None4];
  ipv4_gateway: Unix.inet_addr option [@default None];
  ipv6_conf: ipv6 [@default None6];
  ipv6_gateway: Unix.inet_addr option [@default None];
  (* Change from ipv4_routes: (Unix.inet_addr * int * Unix.inet_addr) list; *)
  ipv4_routes: ipv4_route_t list [@default []];
  dns: Unix.inet_addr list * string list [@default [], []];
  mtu: int [@default 1500];
  ethtool_settings: (string * string) list [@default []];
  ethtool_offload: (string * string) list [@default ["lro", "off"]];
  persistent_i: bool [@default false];
}
[@@deriving rpcty]

Any idea about the warning? I think it comes from ppx_core

Copy link
Collaborator

@mseri mseri Jan 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning above should not break the compilation though, we could live with the warning. I'll have a look at the generated file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a bug of ocaml-rpc that does generate some code like:

typ_of_interface_config_t =
  let open! Rpc.Types in
      Struct
        ({
           fields =
             [BoxedField interface_config_t_ipv4_conf;
             BoxedField interface_config_t_ipv4_gateway;
             BoxedField interface_config_t_ipv6_conf;
             BoxedField interface_config_t_ipv6_gateway;
             BoxedField interface_config_t_ipv4_routes;
             BoxedField interface_config_t_dns;
             BoxedField interface_config_t_mtu;
             BoxedField interface_config_t_ethtool_settings;
             BoxedField interface_config_t_ethtool_offload;
             BoxedField interface_config_t_persistent_i];
           sname = "interface_config_t";
           version = None;
           constructor =
             (fun getter  ->
                let open Rresult.R in
                  (match getter.Rpc.Types.fget "persistent_i"
                           (let open! Rpc.Types in Basic Bool)
                   with
                   | Result.Ok x as y -> y
                   | Result.Error _ -> Result.Ok false) >>=
                    (fun interface_config_t_persistent_i  ->
                       (match getter.Rpc.Types.fget "ethtool_offload"
                                (let open! Rpc.Types in
                                   Dict
                                     (String,
                                       (let open! Rpc.Types in Basic String)))
                        with
                        | Result.Ok x as y -> y
                        | Result.Error _ -> Result.Ok [("lro", "off")]) >>=
                         (fun interface_config_t_ethtool_offload  ->
                            (match getter.Rpc.Types.fget "ethtool_settings"
                                     (let open! Rpc.Types in
                                        Dict
                                          (String,
                                            (let open! Rpc.Types in
                                               Basic String)))
                             with
                             | Result.Ok x as y -> y
                             | Result.Error _ -> Result.Ok []) >>=
                              (fun interface_config_t_ethtool_settings  ->
                                 (match getter.Rpc.Types.fget "mtu"
                                          (let open! Rpc.Types in Basic Int)
[...]

We'll fix it there, please leave the warning on and instead modify the Makefile as follows:

Change

build:
            jbuilder build @install --dev -j $$(getconf _NPROCESSORS_ONLN)
release:
            jbuilder build @install

into

release:
            jbuilder build @install -j $$(getconf _NPROCESSORS_ONLN)

build:
            jbuilder build @install --dev

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made a PR to fix the issue upstream: mirage/ocaml-rpc#77
We will get it in xenserver after the opam-next merge

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mseri ! BTW, can you show me how to get the code that generated by ocaml-rpc that as you showed above so I can check them when I get a compilation error?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After jbuilder build, if you enter into _build/default, you can run the ppx rewriters generated by jbuilder as follows

$ .ppx/ppx_deriving_rpc/ppx.exe --impl network/network_interface.ml > network_interface.generated.ml

Depending on the file, you may need to use ppx_deriving_rpc+ppx_sexp_conv instead of ppx_deriving_rpc, or some other combination or rewriters, but you get the idea

Copy link
Member Author

@krizex krizex Feb 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mseri However I cannot find .ppx/ppx_deriving_rpc/ppx.exe after executing jbuilder build in xcp-idl repo.
I have tried to build the executable file by

ocamlfind ocamlopt -predicates ppx_driver -o ppx -linkpkg  -package ppx_deriving_rpc -package ppx_bin_prot -package ppx_driver.runner

but when executing it complains

[planex xcp-idl]$ ./ppx --impl network/network_interface.ml
File "network/network_interface.ml", line 67, characters 37-42:
Error: ppx_type_conv: 'rpcty' is not a supported type type-conv generator

network/jbuild Outdated
@@ -23,7 +23,7 @@ let coverage_rewriter =
""

let rewriters_camlp4 = ["rpclib.idl -syntax camlp4o"]
let rewriters_ppx = ["ppx_deriving_rpc"; "ppx_sexp_conv"]
let rewriters_ppx = ["ppx_deriving_rpc"; "ppx_sexp_conv";]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last semicolon should not be there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@coveralls
Copy link

coveralls commented Jan 18, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling 2442376 on krizex:private/yangqi/CP-26352 into 144fa27 on xapi-project:ppx_network.

@coveralls
Copy link

coveralls commented Jan 18, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling 2442376 on krizex:private/yangqi/CP-26352 into 144fa27 on xapi-project:ppx_network.

@coveralls
Copy link

coveralls commented Jan 18, 2018

Coverage Status

Coverage remained the same at 61.934% when pulling 47a25db on krizex:private/yangqi/CP-26352 into 236beab on xapi-project:ppx_network.

@@ -11,8 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)

(** {2 Helper functions} *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave this header below the module openings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

let masks = List.map ((-) 255) [a; b; c; d] in
32 - (List.fold_left length 0 masks)
)
Scanf.sscanf netmask "%d.%d.%d.%d" (fun a b c d ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you separate the white space changes from the actual code changes in two different commits?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meanwhile I have found that adding &w=true to the url, github ignores the whitespace. You cannot add review comment on the ignore-whitespace versions but it made reviewing much easier

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, it could be better to separate the whitespace changes into an individual commit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sure

include Unix
let typ_of_inet_addr = Rpc.Types.Abstract ({
rpc_of = (fun t -> Rpc.String (Unix.string_of_inet_addr t));
of_rpc = (function | Rpc.String s -> Ok (Unix.inet_addr_of_string s) | _ -> Error (`Msg "Expecting value of string type when unmarshalling inet_addr"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use multiple lines

function 
| Rpc.String s -> Ok (Unix.inet_addr_of_string s)
| _ -> Error (`Msg "Expecting value of string type when unmarshalling inet_addr")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

let masks = List.map (string_of_int ++ mask) lens in
String.concat "." masks

(** {2 Exceptions} *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this header in the appropriate place

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

exception Not_implemented
exception Vlan_in_use of (string * int)

(** {2 Types} *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this header in the appropriate place

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

"The default variant for forward compatibility."
]]
[@@default Unknown_error]
[@@deriving rpcty]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are fine, when you have such long types it make sense to append them to the bottom.

Not that you can replace the decorated strings with actual docstrings:

 [@doc [
        "[PVS_proxy_connection_error] is reported ";
        "when unable to connect PVS proxy"]]

into

 (** [PVS_proxy_connection_error] is reported
     "when unable to connect PVS proxy *)

and in this way they will appear both in the rpc documentation and in the ocaml one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be more readable, but where to put the docstring? before the match pattern or after?
e.g.

| PVS_proxy_connection_error 
(** [PVS_proxy_connection_error] is reported
     "when unable to connect PVS proxy *)

or

| (** [PVS_proxy_connection_error] is reported
     "when unable to connect PVS proxy *)
PVS_proxy_connection_error 

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They go after, you can use https://caml.inria.fr/pub/docs/manual-ocaml/ocamldoc.html#sec349 as a reference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!


let unit_p = Param.mk Types.unit

(* external clear_state: unit -> unit = "" *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need any of these comments, the type is explicit in the definitions and the old type can be recovered using git

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that used to help you review the code changes.
I will remove them now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

(* external get_all : debug_info -> unit -> iface list = "" *)
let get_all =
let module T = struct
type _iface_list_t = iface list [@@deriving rpcty]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonludlam why do we need this kind of type juggling for polymorphic types like lists or options?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a convenience approach to handle this stuff, but I cannot find it, need Jon's help.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure there is, that's why I wanted to double check


exception PVS_proxy_connection_error
Copy link
Collaborator

@mseri mseri Jan 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonludlam can we have multiple kind or errors err, pvs_err, ... so that specific calls are bound to return specific errors? @robhoes do you thin would be worth doing it?

@@ -119,7 +119,9 @@ let read_stats () =
if payload |> Digest.string |> Digest.to_hex <> checksum then
raise Invalid_checksum
else
payload |> Jsonrpc.of_string |> stats_t_of_rpc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to change this instead of keeping the deriving rpc annotation and using the generated stats_t_of_rpc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By deriving rpcty, there are no stats_t_of_rpc again.

Copy link
Collaborator

@mseri mseri Jan 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to derive rpcty instead of rpc? Can we do [@@deriving rpc, rpcty], does it work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

John requests using rpcty, I think derive both from rpc and rpcty works, but it's redundant because they handle the same stuffs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I don't see the benefit. @jonludlam why rpcty for this instead of rpc?

@krizex
Copy link
Member Author

krizex commented Jan 22, 2018

Updates:

  1. Separate the white spaces changes into an individual commit
  2. Update per comments from @mseri

network/jbuild Outdated
@@ -32,7 +32,7 @@ let () = Printf.ksprintf Jbuild_plugin.V1.send {|
((name xcp_network_interface)
(public_name xcp.network.interface)
(modules (network_interface))
(flags (:standard -w -39 %s))
(flags (:standard -w -39 -w -27 %s))
Copy link
Collaborator

@mseri mseri Jan 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove -w -27. If you rebase over xcp-idl master we merged changes to the Makefile to avoid failing in case of warning. The warning will be then fixed in the next release of ocaml-rpc

@krizex
Copy link
Member Author

krizex commented Jan 23, 2018

Rebase on master and delete the -w -27 in network/jbuild.

@mseri
Copy link
Collaborator

mseri commented Jan 23, 2018

This looks good but should be first tested separately after building on a feature branch (with extreme attention to the update/upgrade tests) and will not be merged until that has happened

@krizex
Copy link
Member Author

krizex commented Jan 24, 2018

Another thing is regarding to the optional parameters in the interface, Param.mk cannot handle this case, so I replace them by adding suffix option and convert them to named parameters, but this will bring extra effort to convert them in the implementation, so @robhoes suggested to just convert them to named parameter and change client part to explicitly pass the parameter.
I will make the change with a new commit.

Copy link
Contributor

@minishrink minishrink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good PR. I would suggest you add a network CLI for debugging (if you do this, you'll have to update the jbuild file again), and prune the jbuild file of unnecessary bits.

network/jbuild Outdated
@@ -53,4 +53,4 @@ let () = Printf.ksprintf Jbuild_plugin.V1.send {|
(wrapped false)
%s))

|} (flags rewriters_camlp4) coverage_rewriter (flags rewriters_ppx) coverage_rewriter
|} (flags rewriters_ppx) coverage_rewriter (flags rewriters_ppx) coverage_rewriter
Copy link
Contributor

@minishrink minishrink Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can trim the jbuild file, as some of it is now redundant:

  • Line 25 is not needed anymore, as you're removing Camlp4 as a dependency

  • Line 26: similarly, ppx_deriving_sexp is no longer necessary

  • Lines 31-41, 46, 52: as in the jbuild files for Squeezed and V6d, you can remove explicit references to the interface without affecting the build

    • if you do this, line 56 can be changed to just
      |} (flags rewriters_ppx) coverage_rewriter
      or you can follow the squeezed jbuild file and write
let flags = flags rewriters_ppx
[...]
|} flags coverage_rewriter

if List.mem_assoc name config then
List.remove_assoc name config
else
config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A thought: List.remove_assoc doesn't throw any exceptions, but performs this check anyway, could just write this as List.remove_assoc name config?

Copy link
Member Author

@krizex krizex Jan 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will update.

def = errors;
raiser = (function | e -> raise (NetworkError e));
matcher = function | NetworkError e -> Some e | _ -> None
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you like, you can shorten this by using the error functor defined here:

module NetworkErrorHandlerOrSomething = Error.Make(struct type t = errors val t = errors end)
let err = NetworkErrorHandlerOrSomething.error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion.

"get_all"
["Get all bridges"]
(debug_info_p @-> unit_p @-> returning result err)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you add a network debugging CLI (as seen in squeezed), the CLI will be confused by two functions both called get_all, even though they're part of different modules. I'm not sure how to get around this; perhaps by creating submodules with different Interface.namespace values? Though it isn't worth it for two different API calls. @jonludlam is there a way around this without renaming API calls?

(debug_info_p @-> name_p @-> returning unit_p err)

let set_dns_interface =
let name_p = Param.mk ~name:"name" ~description:["gateway name"] iface in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_gateway_interface and set_dns_interface use the same parameter name_p, why not just declare it as a common parameter like debug_info_p, but name it gateway_name_p? You could also do the same elsewhere, e.g. bridge_name_p

Copy link
Member Author

@krizex krizex Jan 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug_info_p and unit_p is in common use (nearly in every interface), but not for the gateway_name_p and bridge_name_p etc. I'd like to keep the interface definition clear to read and easy for maintenance so keep them local definition is better than move the definition to module level.

(debug_info_p @-> unit_p @-> returning iface_list_p err)

let exists =
let result = Param.mk ~description:["existance"] Types.bool in
Copy link
Contributor

@minishrink minishrink Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo for "existence"

let result = Param.mk ~description:["interface is up"] Types.bool in
declare
"is_up"
["Interface is up"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be more explicit: "Checks whether the interface is up".

let module T = struct
type _dns_info_t = Unix.inet_addr list * string list [@@deriving rpcty]
end in
let result = Param.mk ~description:["DNS servers infomation"] T._dns_info_t in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo on information

if List.mem_assoc name config = false then
default
else
List.assoc name config

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified like so, though I'm not sure which style is preferred in this repo:

try
  List.assoc name config
with _ -> default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer keep it as is.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to keep it as it is, please do

if not List.mem_assoc name config then default
else List.assoc name config

I personally also prefer the @minishrink one that avoids a lookup.

Signed-off-by: Yang Qian <yang.qian@citrix.com>
1. all types deriving from rpcty
2. remove redundent rpc functions, replace them with `@@default` rewriter
3. rename `Basic` of `string_of_port_kind` to `Basic_port`
4. change type `ipv4_route_t` from list to a struct type
5. move exception definition to xcp-networkd
6. declare interface with new style code by using `Idl.declare`
7. replace optional parameter with position parameter or position option
parameter, remove the redundent suffix unit parameter accordingly
8. replace `rpc_of_x` and `x_of_rpc` with `Rpcmarshal.marshal` and `Rpamarshal.unmarshal`
9. update jbuilder file, remove redundant contents

Signed-off-by: Yang Qian <yang.qian@citrix.com>
@krizex
Copy link
Member Author

krizex commented Feb 9, 2018

Updated with changes of xapi and xcp-networkd

Copy link
Collaborator

@mseri mseri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I have a couple of minor comments.

call
)
end)
let rpc call =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the other modules we are moving away from global openings. Please remove open Network_interface and open Xcp_client, see e.g. https://github.com/xapi-project/xcp-idl/blob/master/gpumon/gpumon_client.ml

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

rpc_of = (fun t -> Rpc.String (Unix.string_of_inet_addr t));
of_rpc = (function
| Rpc.String s -> Ok (Unix.inet_addr_of_string s)
| _ -> Error (`Msg "Expecting value of string type when unmarshalling inet_addr"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more explicit:

| r -> Error(`Msg (Printf.printf "typ_of_inet_addr: expected rpc string, got %s" (Rpc.to_string r))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@mseri
Copy link
Collaborator

mseri commented Feb 9, 2018

Sorry, I meant to press the Comment button. With the two changes above I think it's good. But don't merge it unti testing is complete

@minishrink
Copy link
Contributor

minishrink commented Feb 9, 2018

I have a question regarding your xcp-networkd PR: I noticed that network_server includes some API calls that were never in xcp-idl/network_interface.ml to begin with, such as set_ipv6_conf, get/set_ipv6_gateway, set_dns, set_ipv4_routes, etc. Just wondering: should these be added?

Disclaimer: I don't know much about networkd, so this might be an unnecessary question.

@robhoes
Copy link
Member

robhoes commented Feb 9, 2018

@minishrink Those functions were actually part of the interface, but I have recently removed them because they were unused, and I wanted to simplify the interface. The functions are, however, used internally in the Interface module inside the server (especially by Interface.make_config).

Copy link
Collaborator

@mseri mseri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at #204 for reference

| Not_implemented (** [Not_implemented] is reported if the interface is not implemented *)
| Vlan_in_use of (string * int) (** [Vlan_in_use (bridge, vlan_id)] is reported when [vlan_id] on [bridge] is inuse *)
| PVS_proxy_connection_error (** [PVS_proxy_connection_error] is reported when unable to connect PVS proxy *)
| Unknown_error (** The default variant for forward compatibility. *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Internal_error of string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks.

let err = Error.{
def = errors;
raiser = (function | e -> raise (Network_error e));
matcher = function | Network_error e -> Some e | _ -> None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the last match with

| e -> Internal_error (Printexc.to_string e)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks.

Signed-off-by: Yang Qian <yang.qian@citrix.com>
@mseri
Copy link
Collaborator

mseri commented Feb 22, 2018

@krizex has this been built in Jenkins in a private branch and tested (BVT + BST)?

@krizex
Copy link
Member Author

krizex commented Feb 23, 2018

@mseri I have executed network regression and some bond cases need to triage. BVT is on the way.

@mseri
Copy link
Collaborator

mseri commented Feb 23, 2018

Good, please run also the ring3 BST

@krizex
Copy link
Member Author

krizex commented Feb 26, 2018

@mseri
Ring3 BVT passed in job 79965
Ring3 BST passed job 79962
Network regression passed job 80071 except infrastructure issues of bond cases on BOURNE04, I have spoke it to Rama and got confirmed, the ticket has been assigned to him.

@krizex
Copy link
Member Author

krizex commented Feb 27, 2018

Remove label of don't merge yet

Copy link
Contributor

@minishrink minishrink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ready for merging, unless @jonludlam can think of any PPX/ocaml-rpc changes to wait for.

@mseri
Copy link
Collaborator

mseri commented Feb 27, 2018

I am going to do a manual merge to master and close the PR to ppx_network

@mseri mseri closed this Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants