-
Notifications
You must be signed in to change notification settings - Fork 41
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Is there a way to group this into smaller commits without force pushing? |
No. I would suggest you do this after all comments have been addressed but before we merge. |
If this PR is ready, I can merge this branch into it. |
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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
v6/v6_interface.ml
Outdated
[@@deriving rpcty] | ||
|
||
(** handle exception generation and raising *) | ||
let err = Error.{ |
There was a problem hiding this comment.
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 :)
f5cc77f
to
b917654
Compare
Is this ready to go in, @mseri? |
Quick observation: the commit messages don't have "Signed-off-by" lines yet. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
.
v6/v6_interface.ml
Outdated
| License_processing_error | ||
(** License could not be processed *) | ||
| Missing_connection_details | ||
(** Thrown if connection port or address parameter not supplied to check_license *) |
There was a problem hiding this comment.
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.
v6/v6_interface.ml
Outdated
namespace = None; | ||
description = [ | ||
"This interface is used by Xapi and V6d to manage "; | ||
"XenServer edition licensing of hosts."; |
There was a problem hiding this comment.
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.
v6/v6_interface.ml
Outdated
let apply_edition = | ||
declare | ||
"apply_edition" | ||
["Checks license info and ensures provided features are compatible."] |
There was a problem hiding this comment.
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".
v6/v6_interface.ml
Outdated
@@ -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 *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, there it is ;)
v6/v6_interface.ml
Outdated
"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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"parameters"
There was a problem hiding this comment.
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
v6/v6_interface.ml
Outdated
@@ -56,6 +58,10 @@ type edition_info = { | |||
} | |||
[@@deriving rpcty] | |||
|
|||
type stringPairLst = (string * string) list |
There was a problem hiding this comment.
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.
v6/v6_interface.ml
Outdated
with low numbers corresponding to editions with fewer features, and vice versa *) | ||
} | ||
{ | ||
ed_title : string ; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
v6/v6_interface.ml
Outdated
(* --- API interface --- *) | ||
|
||
(** Generic licensing error of error variant type *) | ||
exception LicensingError of errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V6_error
perhaps?
[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>
This PR is the second of three which port the licensing daemon to PPX:
This PR in particular includes the following changes:
Possible follow-up: A .mli file defining the v6 interface
Note: CP-26098 is part of REQ-417