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-26098: Port v6d interface from Camlp4 to PPX #186

Merged
merged 6 commits into from
Jan 26, 2018

Conversation

minishrink
Copy link
Contributor

@minishrink minishrink commented Jan 8, 2018

This PR is the second of three which port the licensing daemon to PPX:

  1. xcp-idl: port V6d interface to use PPX
  2. xapi: update references to v6 interface
  3. v6d: port daemons to ppx.

This PR in particular includes the following changes:

  • ports v6d_interface from Camlp4 to PPX
  • updates the v6 jbuild file to no longer use camlp4
  • updates v6_client error handling

Possible follow-up: A .mli file defining the v6 interface
Note: CP-26098 is part of REQ-417

@coveralls
Copy link

coveralls commented Jan 8, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling 068682d on minishrink:ppx into 144fa27 on xapi-project:master.

Copy link
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

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

This looks good. Could you group this into fewer commits? I have minor comments.


let json_url () = "file:" ^ json_path
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe a file URL needs to start with file://, see https://en.wikipedia.org/wiki/File_URI_scheme

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to change it, but I'm curious: I've had a look at how other daemon interfaces define the json_url/json_path function, and it seems like they all follow this pattern, which would presumably result in something like this:
file:/var/path/to/file.extension
Given that there haven't been any issues so far (that I know of) with this format, is the change just a matter of following conventions? Also, is it worth changing for all interfaces?

Copy link
Contributor

Choose a reason for hiding this comment

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

I might have raised this in the past. It's wrong but it works. So let's keep it.

Copy link
Contributor Author

@minishrink minishrink Jan 8, 2018

Choose a reason for hiding this comment

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

I can leave this for now and change it for all interfaces in a separate PR, would that work?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure. Let's stick with it for the moment

(** handle exception generation and raising *)
let err = Error.{
def = errors;
raiser = (function
Copy link
Contributor

Choose a reason for hiding this comment

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

Either both, raiser and matcher, should be in parenthesis, or none.

@minishrink
Copy link
Contributor Author

Is there a way to group this into smaller commits without force pushing?

@lindig
Copy link
Contributor

lindig commented Jan 8, 2018

No. I would suggest you do this after all comments have been addressed but before we merge.

@coveralls
Copy link

coveralls commented Jan 8, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling 2763830 on minishrink:ppx into 144fa27 on xapi-project:master.

@minishrink
Copy link
Contributor Author

minishrink commented Jan 8, 2018

If this PR is ready, I can merge this branch into it.

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.

Just a minor thing. It looks good overall

v6/jbuild Outdated
(flags (:standard -w -39 %s))
(modules (:standard))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the default value, you can delete this line

[@@deriving rpcty]

(** handle exception generation and raising *)
let err = Error.{
Copy link
Collaborator

Choose a reason for hiding this comment

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

A PR to ocaml-rpc to autogenerate err passing the exception wrapper type into a functor is welcome :)

@coveralls
Copy link

coveralls commented Jan 10, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling b917654 on minishrink:ppx into 144fa27 on xapi-project:master.

@lindig
Copy link
Contributor

lindig commented Jan 11, 2018

Is this ready to go in, @mseri?

@robhoes
Copy link
Member

robhoes commented Jan 15, 2018

Quick observation: the commit messages don't have "Signed-off-by" lines yet.

Copy link
Member

@robhoes robhoes left a comment

Choose a reason for hiding this comment

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

This like quite good, I've just added some minor comments.

However, the way this PR is split into commits does not make a lot of sense to me. Each commit should represent a logical change that is useful (and reviewable) on its own. But this looks more like a sequence of changes and corrections, and whitespace fixes mixed together. I'd personally just squash all changes to v6_interface.ml into a single patch. And separate ones for the client and jbuild file perhaps.

exception License_expired
exception License_processing_error
exception Missing_connection_details
exception License_checkout_error of string
Copy link
Member

Choose a reason for hiding this comment

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

Do we not need License_checkout_error anymore? It's not there in type errors.

| License_processing_error
(** License could not be processed *)
| Missing_connection_details
(** Thrown if connection port or address parameter not supplied to check_license *)
Copy link
Member

Choose a reason for hiding this comment

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

check_license isn't part of the interface. I think that this should be apply_edition, which needs such parameters in some cases.

namespace = None;
description = [
"This interface is used by Xapi and V6d to manage ";
"XenServer edition licensing of hosts.";
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer something like: "This interface is used by xapi and v6d to manage enabling and disabling features". Note that this interface is not restricted to XenServer (it's part of the xapi project). And it's also used for things such as controlling experimental features.

let apply_edition =
declare
"apply_edition"
["Checks license info and ensures provided features are compatible."]
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer something like "checks whether the given edition can be applied, and if successful, returns a list of enabled features and other details".

@@ -67,12 +73,18 @@ type errors =
(** Thrown by license_check when expiry date matches or precedes current date *)
| License_processing_error
(** License could not be processed *)
| License_checkout_error of string
(** License could not be checked out *)
Copy link
Member

Choose a reason for hiding this comment

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

Ah, there it is ;)

"apply_edition"
let edition_p = Param.mk ~description:["Edition tite"] Types.string in
let edition_info_p = Param.mk ~description:["Edition info"] edition_info in
let current_params_p = Param.mk ~description:["Xapi paramaters"] stringPairLst in
Copy link
Member

Choose a reason for hiding this comment

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

"parameters"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh god I fixed that in one version and must have lost it among the many rebases. I'll go hang my head in shame now

@@ -56,6 +58,10 @@ type edition_info = {
}
[@@deriving rpcty]

type stringPairLst = (string * string) list
Copy link
Member

Choose a reason for hiding this comment

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

We tend_to_use_underscores_to_separate_words ratherThanCamelCase.

with low numbers corresponding to editions with fewer features, and vice versa *)
}
{
ed_title : string ;
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need these prefixes? I generally prefer to wrap a type in a module instead. In this case, this type is already in module V6_interface and the field names don't seem to conflict with anything else in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They were originally necessary to prevent namespace clashes in large functions with an indiscriminate let open V6_interface in , but now all functions using them are wrapped in the module namespace, so I can remove the prefixes.

(* --- API interface --- *)

(** Generic licensing error of error variant type *)
exception LicensingError of errors
Copy link
Member

Choose a reason for hiding this comment

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

V6_error perhaps?

@coveralls
Copy link

coveralls commented Jan 17, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling 14247eb on minishrink:ppx into 144fa27 on xapi-project:master.

@coveralls
Copy link

coveralls commented Jan 18, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling decb961 on minishrink:ppx into 2b50792 on xapi-project:master.

@coveralls
Copy link

coveralls commented Jan 19, 2018

Coverage Status

Coverage remained the same at 54.268% when pulling 47160fe on minishrink:ppx into 0d8714a on xapi-project:master.

Akanksha Mathur added 5 commits January 22, 2018 14:48
[v6d] Define functor to generate RPC code

Note: Functor was originally just called API, changed this to prevent
namespace clashes with an autogenerated module titled API

[v6d] Type functions and parameters for PPX code generation
includes the following:
- refactor error handling
- rename record fields and functor to prevent namespace clashes
- edit docstrings

Note: Types require a docstring above, not below

ocp-indent

[v6d] Define error handling, rename record fields and functor to avoid namespace
clashes

Edit v6 interface docstrings

Signed-off-by: Akanksha Mathur <akanksha.mathur@citrix.com>

CP-26098: Wrap matcher and raiser in parentheses

Signed-off-by: Akanksha Mathur <akanksha.mathur@citrix.com>
- fix typo (paramaters -> parameters)
- rename type (stringPairLst -> string_pair_lst)
- rename edition record field names (ed_title -> title etc)
- edit docstrings to accurately describe feature handling
- rename exception (LicensingError -> V6d_error)
Signed-off-by: Akanksha Mathur <akanksha.mathur@citrix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants