-
Notifications
You must be signed in to change notification settings - Fork 292
Remove Legacy API module #3490
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
Remove Legacy API module #3490
Conversation
I think originally the issue with |
Hope this will be merged soon as it will make my work easier ^^ |
I'm running BVT and BST right now, if there are no further failures, and if somebody has the patience to review it in the meanwhile, we could proceed |
Actually I only need the commits that remove the Legacy module and |
Figured out how to solve my problem, so it's not that urgent now :) |
The others are necessary to remove the Legacy module :P |
For reference:
|
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
This greatly simplifies the changes needed in import.ml Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Here we are performing an itermediate re-serialization to string. It will be possible to simplify that further by implementing an Xmlrpc.of_xml method in ocaml-rpc. Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
This removes the necessity to pass trough an intermediate re-stringification of the various datastructures. There is still an open question about the need of Bigbuffer. If we can cope with strings as done now, we could actually get rif of Bigbuffer in all the rpc interaction, and maybe in xapi itself. If it is needed it should not be hard to provide the necessary infrastructure in ocaml-rpc to deal with it. We could also probably rely on Xmlrpc.from_a although I am a bit wary of that call... Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Now (64bit) that strings can hold 144 Petabytes of data, this module is no longer necessary. Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
…stead Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
…tive Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
… code that break the unmarshaller Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
… API generator Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
sprintf "%s = %s_of_rpc (List.assoc \"%s\" x)" (field fld) (OU.alias_of_ty fld.DT.ty) | ||
(String.concat "_" fld.DT.full_name) | ||
sprintf {|%s = %s_of_rpc (assocer "%s" x %s)|} (field fld) (OU.alias_of_ty fld.DT.ty) | ||
(String.concat "_" fld.DT.full_name) (get_default fld) |
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.
It is not necessary to generate these X_of_rpc
, and rpc_of_X
things, rpclib can do it for us. I have a set of working patches, one of which removes these custom functions and moves to ones generated by rpclib:
gaborigloi@2c4fc73
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.
Not in this case, we need to customise them and replace the autogenerated ones.
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.
Maybe we can use the new [@default ...]
key to resolve the main issues, but it needs more work to serialize it correctly and it needs further testing. It is an improvement that can be added later and we should keep in mind to try it
ocaml/idl/ocaml_backend/gen_api.ml
Outdated
in | ||
match default_value with | ||
None -> "" | ||
| Some default -> sprintf "[@default (%s)]" (Datamodel_values.to_ocaml_string ~v2:true default) |
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.
Jon said this is okay
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.
:)
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.
Unfortunately it doesn't but we have a plan to fix ocaml-rpc and make it possible
As it is now, this code passed both the BVT and the BST (jobs 80812 and 80813) 🎉 😄 |
If it is fine for you, I'd suggest that we review and proceed with the current changes, and we keep working to improve them to use only |
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.
Nice! Just some minor comments - it's not important to change the code, good to merge IMO
ocaml/database/db_interface.ml
Outdated
type response = | ||
| String of string | ||
| Bigbuf of Xapi_stdext_bigbuffer.Bigbuffer.t | ||
type response = String 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.
Would it be worth to just say type response = 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.
Probably it is fine. I wanted to minimize the changes. I’ll have a look
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.
It's fine. Done
let xml_string = Bigbuffer.make () in | ||
really_read_bigbuffer fd xml_string hdr.Tar_unix.Header.file_size; | ||
Xml.parse_bigbuffer xml_string | ||
Unixext.really_read_string fd (Int64.to_int hdr.Tar_unix.Header.file_size) |
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 could be renamed to read_next_file
, or we could add a Xmlrpc.of_string
to the end.
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.
There was a reason I did not add the Xmlrpc.to_string but I think that woth the latest changes that reason is no longer there. I’ll fix it or let you know the reason :)
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.
Found it. The old Xva module uses a direct approach manipulating and marshalling/unmarshalling the xml. The read_xml
function is used both by our new Xmlrpc
and that old Xml.parse_String |> Xva.from_xml
. Changing that is invasive and out of scope for this pr
ocaml/xapi/importexport.ml
Outdated
; xapi_vsn_minor = Rpc.int_of_rpc (find _xapi_minor) | ||
; export_vsn = try Rpc.int_of_rpc (find _export_vsn) with _ -> 0 | ||
} | ||
| rpc -> raise (Failure(Printf.sprintf "version_of_rpc: malformed RPC %s" (Jsonrpc.to_string rpc))) |
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 a minor point, but I'd use Rpc.to_string
here, because we're dealing with a generic Rpc structure 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.
Faor enough. I uesd json only because I find it more readable but it is more natural to use Rpc.to_string. I’ll change it
|> Xmlrpc.of_string | ||
|> API.ref_VM_set_of_rpc | ||
with | ||
parse_error -> raise Api_errors.(Server_error (field_type_error, [Printexc.to_string parse_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.
This is a very minor point again, but the param of this error seems to the field:
91 error Api_errors.field_type_error ["field"]
92 ~doc:"The value specified is of the wrong type" ();
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.
The error is bogus. Before we were not even adding the field, and passing an empty string instead.
Using the printexc I am printing the real reason we cannot unmarshal the type. It is still a field type error, but with a useful string in the metadata. I think that even if is not what announced the errors with that content are way more readable and understandable. I agree that it is anstretch, but I will keep them as they are
|> Xmlrpc.of_string | ||
|> API.ref_VDI_of_rpc | ||
with | ||
parse_error -> raise Api_errors.(Server_error (field_type_error, [Printexc.to_string parse_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.
Same as above.
Thanks for the review. I think it’s worth making some of the changes before merging |
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
This gets rid of a leftover of 0583a91 Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
This looks really good! |
Nice cleanup: +202 −477 👍 |
I had an old experiment lying around, I've decided to resurrect it and polish it after a Slack discussion today. I've rewritten the commit history to reflect more it's evolution and avoid intermediate debugging commits.
I am going to test it on a private branch, this should not be merged until testing is done and we agree on what to do with the
Bigbuffer
story (look forBigbuffer.to_string
, it appears in a few places in the new code).