Skip to content

Commit abd6703

Browse files
committed
CP-53711: Apply SSH settings in joiner before update_non_vm_metadata
Signed-off-by: Gang Ji <[email protected]>
1 parent 31c2b3c commit abd6703

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

ocaml/xapi/xapi_pool.ml

+34-12
Original file line numberDiff line numberDiff line change
@@ -955,17 +955,6 @@ let rec create_or_get_host_on_master __context rpc session_id (host_ref, host) :
955955
Client.Host.get_console_idle_timeout ~rpc ~session_id
956956
~self:remote_coordinator
957957
in
958-
(* Configure SSH service on local host *)
959-
Xapi_host.set_console_idle_timeout ~__context ~self:host_ref
960-
~value:console_idle_timeout ;
961-
Xapi_host.set_ssh_enabled_timeout ~__context ~self:host_ref
962-
~value:ssh_enabled_timeout ;
963-
( match ssh_enabled with
964-
| true ->
965-
Xapi_host.enable_ssh ~__context ~self:host_ref
966-
| false ->
967-
Xapi_host.disable_ssh ~__context ~self:host_ref
968-
) ;
969958
(* As ssh_expiry will be updated by host.enable_ssh and host.disable_ssh,
970959
there is a corner case when the joiner's SSH state will not match SSH
971960
service state in its new coordinator exactly: if the joiner joins when
@@ -1588,6 +1577,7 @@ let join_common ~__context ~master_address ~master_username ~master_password
15881577
)
15891578
in
15901579

1580+
let remote_coordinator = get_master ~rpc ~session_id in
15911581
(* If management is on a VLAN, then get the Pool master
15921582
management network bridge before we logout the session *)
15931583
let pool_master_bridge, mgmt_pif =
@@ -1598,7 +1588,7 @@ let join_common ~__context ~master_address ~master_username ~master_password
15981588
if Db.PIF.get_VLAN_master_of ~__context ~self:my_pif <> Ref.null then
15991589
let pif =
16001590
Client.Host.get_management_interface ~rpc ~session_id
1601-
~host:(get_master ~rpc ~session_id)
1591+
~host:remote_coordinator
16021592
in
16031593
let network = Client.PIF.get_network ~rpc ~session_id ~self:pif in
16041594
(Some (Client.Network.get_bridge ~rpc ~session_id ~self:network), my_pif)
@@ -1688,6 +1678,38 @@ let join_common ~__context ~master_address ~master_username ~master_password
16881678
"Unable to set the write the new pool certificates to the disk : %s"
16891679
(ExnHelper.string_of_exn e)
16901680
) ;
1681+
( try
1682+
let ssh_enabled_timeout =
1683+
Client.Host.get_ssh_enabled_timeout ~rpc ~session_id
1684+
~self:remote_coordinator
1685+
in
1686+
let console_idle_timeout =
1687+
Client.Host.get_console_idle_timeout ~rpc ~session_id
1688+
~self:remote_coordinator
1689+
in
1690+
(* Configure SSH service on local host to apply the settings which
1691+
will persisit after it joins the new pool.
1692+
Please note that ssh_enabled_timeout needs be set before
1693+
update_non_vm_metadata(), inside which ssh_expiry is queried to
1694+
set to host obj in remote coordinator DB.
1695+
*)
1696+
Xapi_host.set_console_idle_timeout ~__context ~self:me
1697+
~value:console_idle_timeout ;
1698+
Xapi_host.set_ssh_enabled_timeout ~__context ~self:me
1699+
~value:ssh_enabled_timeout ;
1700+
let ssh_enabled =
1701+
Client.Host.get_ssh_enabled ~rpc ~session_id
1702+
~self:remote_coordinator
1703+
in
1704+
match ssh_enabled with
1705+
| true ->
1706+
Xapi_host.enable_ssh ~__context ~self:me
1707+
| false ->
1708+
Xapi_host.disable_ssh ~__context ~self:me
1709+
with e ->
1710+
error "Unable to configure SSH service on local host: %s"
1711+
(ExnHelper.string_of_exn e)
1712+
) ;
16911713
(* this is where we try and sync up as much state as we can
16921714
with the master. This is "best effort" rather than
16931715
critical; if we fail part way through this then we carry

0 commit comments

Comments
 (0)