Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ocaml/idl/datamodel_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ let _ =
"The license-server connection details (address or port) were missing or \
incomplete."
() ;
error Api_errors.license_checkout_error ["reason"]
error Api_errors.license_checkout_error ["code"; "message"]
~doc:"The license for the edition you requested is not available." () ;
error Api_errors.license_file_deprecated []
~doc:
Expand Down
27 changes: 3 additions & 24 deletions ocaml/xapi-cli-server/cli_operations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5338,9 +5338,8 @@ let with_license_server_changes printer rpc session_id params hosts f =
)
hosts
) ;
let now = Unix.gettimeofday () in
try f rpc session_id with
| Api_errors.Server_error (name, _) as e
| Api_errors.Server_error (name, [_; msg])
when name = Api_errors.license_checkout_error ->
(* Put back original license_server_details *)
List.iter
Expand All @@ -5349,28 +5348,8 @@ let with_license_server_changes printer rpc session_id params hosts f =
~value:license_server
)
current_license_servers ;
let alerts =
Client.Message.get_since ~rpc ~session_id
~since:(Date.of_unix_time (now -. 1.))
in
let print_if_checkout_error (ref, msg) =
if
false
|| msg.API.message_name = fst Api_messages.v6_rejected
|| msg.API.message_name = fst Api_messages.v6_comm_error
|| msg.API.message_name
= fst Api_messages.v6_license_server_version_obsolete
Comment on lines -5359 to -5362
Copy link
Member

Choose a reason for hiding this comment

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

If I understood this right, xe now doesn't need to know about these messages, but they still need to be exposed so clients can still react to them, is this correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean the definitions in api_messages? I'd like to remove them as well, but I was worried about breaking the SDK.

then (
Client.Message.destroy ~rpc ~session_id ~self:ref ;
printer (Cli_printer.PStderr (msg.API.message_body ^ "\n"))
)
in
if alerts = [] then
raise e
else (
List.iter print_if_checkout_error alerts ;
raise (ExitWithError 1)
)
printer (Cli_printer.PStderr (msg ^ "\n")) ;
raise (ExitWithError 1)
| Api_errors.Server_error (name, _) as e
when name = Api_errors.invalid_edition ->
let host = get_host_from_session rpc session_id in
Expand Down
3 changes: 2 additions & 1 deletion ocaml/xapi-idl/v6/v6_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ 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 *)
| License_checkout_error of string * string
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a breaking change anyway you could also completely rename the variant to something else?
(Then you could also keep the old one for backwards compatibility if needed)

Copy link
Member Author

Choose a reason for hiding this comment

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

As this is an host-internal interface, I don't think it is worth worrying about. In practice we update xapi+v6d at the same time.

(** License could not be checked out *)
| Missing_connection_details
(** Thrown if connection port or address parameter not supplied to
check_license *)
Expand Down
4 changes: 2 additions & 2 deletions ocaml/xapi/xapi_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2079,8 +2079,8 @@ let apply_edition_internal ~__context ~host ~edition ~additional =
raise Api_errors.(Server_error (license_processing_error, []))
| V6_interface.(V6_error Missing_connection_details) ->
raise Api_errors.(Server_error (missing_connection_details, []))
| V6_interface.(V6_error (License_checkout_error s)) ->
raise Api_errors.(Server_error (license_checkout_error, [s]))
| V6_interface.(V6_error (License_checkout_error (code, msg))) ->
raise Api_errors.(Server_error (license_checkout_error, [code; msg]))
| V6_interface.(V6_error (Internal_error e)) ->
Helpers.internal_error "%s" e
in
Expand Down
Loading