Skip to content

Commit c148c2b

Browse files
authored
Merge pull request xapi-project#234 from Frezzle/ely-bugfix-CA-228780
CA-228780: Clear error message when PVS Proxy starts with no PVS servers
2 parents e85c5dd + a0a0b94 commit c148c2b

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

ocaml/idl/api_messages.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ let v6_license_server_version_obsolete = addMessage "LICENSE_SERVER_VERSION_OBSO
9595
(* PVS alerts *)
9696
let pvs_proxy_no_cache_sr_available = addMessage "PVS_PROXY_NO_CACHE_SR_AVAILABLE" 3L (* No cache storage available for pvs site on the host *)
9797
let pvs_proxy_setup_failed = addMessage "PVS_PROXY_SETUP_FAILED" 3L (* Setting up pvs proxy rules or pvs proxy daemon initialisation failed internally *)
98+
let pvs_proxy_no_server_available = addMessage "PVS_PROXY_NO_SERVER_AVAILABLE" 3L (* No pvs server available for pvs site on host *)
9899

99100
(* VMPP message types *)
100101
let vmpp_snapshot_lock_failed = addMessage "VMPP_SNAPSHOT_LOCK_FAILED" 3L (*'The snapshot phase is already executing for this protection policy. Please try again later'*)

ocaml/xapi/helpers.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,12 @@ let assert_using_vswitch ~__context =
10821082
in
10831083
if not using_vswitch then raise Api_errors.(Server_error (openvswitch_not_active, []))
10841084

1085+
exception No_pvs_server_available
1086+
1087+
let assert_pvs_servers_available ~__context ~pvs_site =
1088+
let pvs_servers = Db.PVS_site.get_servers ~__context ~self:pvs_site in
1089+
if pvs_servers = [] then raise No_pvs_server_available
1090+
10851091
let assert_is_valid_ref ~__context ~name ~ref =
10861092
if not (Db.is_valid_ref __context ref)
10871093
then raise Api_errors.(Server_error (invalid_value, [

ocaml/xapi/pvs_proxy_control.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ let start_proxy ~__context vif proxy =
194194
try
195195
Pool_features.assert_enabled ~__context ~f:Features.PVS_proxy;
196196
Helpers.assert_using_vswitch ~__context;
197+
Helpers.assert_pvs_servers_available ~__context ~pvs_site:site;
197198

198199
(* Create an interface and OVS port for the proxy *)
199200
let vifr = Db.VIF.get_record ~__context ~self:vif in
@@ -230,6 +231,17 @@ let start_proxy ~__context vif proxy =
230231
Helpers.call_api_functions ~__context (fun rpc session_id ->
231232
ignore(Client.Client.Message.create ~rpc ~session_id ~name ~priority ~cls:`PVS_proxy ~obj_uuid:proxy_uuid ~body));
232233
"unable to connect to PVS proxy daemon"
234+
| Helpers.No_pvs_server_available ->
235+
let proxy_uuid = Db.PVS_proxy.get_uuid ~__context ~self:proxy in
236+
let vif_uuid = Db.VIF.get_uuid ~__context ~self:vif in
237+
let site_name_label = Db.PVS_site.get_name_label ~__context ~self:(Db.PVS_proxy.get_site ~__context ~self:proxy) in
238+
let host_name_label = Db.Host.get_name_label ~__context ~self:(Helpers.get_localhost ~__context) in
239+
let body = Printf.sprintf "Unable to setup PVS-proxy %s for VIF %s: no PVS-server found on PVS-site %s for host %s."
240+
proxy_uuid vif_uuid site_name_label host_name_label in
241+
let (name, priority) = Api_messages.pvs_proxy_no_server_available in
242+
Helpers.call_api_functions ~__context (fun rpc session_id ->
243+
ignore(Client.Client.Message.create ~rpc ~session_id ~name ~priority ~cls:`PVS_proxy ~obj_uuid:proxy_uuid ~body));
244+
"no PVS server available"
233245
| Api_errors.Server_error (code, args) when
234246
code = Api_errors.license_restriction
235247
&& args = [Features.(name_of_feature PVS_proxy)] ->

0 commit comments

Comments
 (0)