You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
idl/gen_client: Don't specify argument values when they're equal to defaults (#6693)
#6652 added a new parameter
to `Host.disable`. Since the method is used during an RPU, when a new
client calls an older server unaware of the parameter, this broke it.
Add a test reproducing what happens during an RPU and fix the issue in
`client.ml`.
---
Adds an older `server.ml` and `client.ml` from xapi 25.30.0 (with
`server.ml`
modified to compile after the XSA-474 interface changes), before
`Host.disable`
gained the `auto_enable` parameter.
Adds compatibility tests verifying that an older client can talk to a
newer
server and the other way around.
Before the fix, both `test_compatibility_with_old_server_*` fail,
showing that
`auto_enable` in `Host.disable` is an unexpected parameter. This failure
is
triggered on RPUs, when a newer xapi talks to an older one:
[exception] Server_error(MESSAGE_PARAMETER_COUNT_MISMATCH, [
host.disable; 1; 2 ])
So allow `client.ml` to skip specifying an arbitrary number of rightmost
arguments if they're all equal to their default values (since arguments
are
positional, once an argument is not skipped, no arguments to its left
can be
skipped).
Generated code for `host.disable` looks like the following:
```
let session_id = rpc_of_ref_session session_id in
let host = rpc_of_ref_host host in
let auto_enable = rpc_of_bool auto_enable in
let needed_args, _ = List.fold_right2
(fun param default (acc, skipped)->
(* Since arguments are positional, we can only skip specifying an
argument that's equal to its default value if all the arguments to
its right were also not specified *)
if skipped then
(match default with
| Some default_value when param = default_value -> (acc, true)
| _ -> (param::acc, false))
else
(param :: acc, false)
) [ session_id; host; auto_enable ] [ None; None; Some (Rpc.Bool true) ] ([], true)
in
rpc_wrapper rpc "host.disable" needed_args >>= fun x -> return (ignore x)
```
This fixes an issue with `client.ml` always specifying values for new
parameters
that older `server.ml` did not know about (which happens during an RPU).
This makes `test_compatibility_with_old_server_default` pass, so drop
the
`try with` for it. `test_compatibility_with_old_server_non_default`
still fails,
indicating that everything works as intended.
Fixes: cf5be62 ("host.disable: Add auto_enabled parameter for
persistency")
0 commit comments