Skip to content

Commit a106fae

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 a106fae

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

ocaml/xapi/xapi_pool.ml

Lines changed: 29 additions & 12 deletions
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,33 @@ 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+
let ssh_enabled_timeout =
1682+
Client.Host.get_ssh_enabled_timeout ~rpc ~session_id
1683+
~self:remote_coordinator
1684+
in
1685+
let console_idle_timeout =
1686+
Client.Host.get_console_idle_timeout ~rpc ~session_id
1687+
~self:remote_coordinator
1688+
in
1689+
(* Configure SSH service on local host to apply the settings which will
1690+
persisit after it joins the new pool.
1691+
Please note that ssh_enabled_timeout needs be set before
1692+
update_non_vm_metadata(), inside which ssh_expiry is queried to set to
1693+
host obj in remote coordinator DB.
1694+
*)
1695+
Xapi_host.set_console_idle_timeout ~__context ~self:me
1696+
~value:console_idle_timeout ;
1697+
Xapi_host.set_ssh_enabled_timeout ~__context ~self:me
1698+
~value:ssh_enabled_timeout ;
1699+
let ssh_enabled =
1700+
Client.Host.get_ssh_enabled ~rpc ~session_id ~self:remote_coordinator
1701+
in
1702+
( match ssh_enabled with
1703+
| true ->
1704+
Xapi_host.enable_ssh ~__context ~self:me
1705+
| false ->
1706+
Xapi_host.disable_ssh ~__context ~self:me
1707+
) ;
16911708
(* this is where we try and sync up as much state as we can
16921709
with the master. This is "best effort" rather than
16931710
critical; if we fail part way through this then we carry

0 commit comments

Comments
 (0)