@@ -1611,6 +1611,12 @@ let crl_list ~__context = Certificates.(local_list CRL)
16111611
16121612let certificate_sync = Certificates. pool_sync
16131613
1614+ let ignore_error ~msg ~warn f =
1615+ try f ()
1616+ with e ->
1617+ debug " %s: %s" msg (Printexc. to_string e) ;
1618+ D. warn " %s" warn
1619+
16141620let join_common ~__context ~master_address ~master_username ~master_password
16151621 ~force =
16161622 assert_pooling_licensed ~__context ;
@@ -1808,23 +1814,46 @@ let join_common ~__context ~master_address ~master_username ~master_password
18081814 error " Unable to configure SSH service on local host: %s"
18091815 (ExnHelper. string_of_exn e)
18101816 ) ;
1817+ (* Sync ldaps status before update_non_vm_metadata so that the corrected
1818+ value gets pushed to the coordinator as part of that sync, preventing
1819+ it from being overwritten when the host restarts as a slave. *)
1820+ ignore_error ~msg: " Failed to sync ldaps status with pool coordinator"
1821+ ~warn:
1822+ " Error whilst syncing ldaps status with pool coordinator. The \
1823+ pool-join operation will continue as only pool coordinator is used \
1824+ for ldap query. Use pool-external-auth-set-ldaps --force to fixup"
1825+ @@ fun () ->
1826+ let coordinator_ldaps =
1827+ Client.Host. get_external_auth_configuration ~rpc ~session_id
1828+ ~self: remote_coordinator
1829+ |> fun config -> Helpers. ldaps_enabled_in_config ~config
1830+ in
1831+ let local_ldaps =
1832+ Db.Host. get_external_auth_configuration ~__context ~self: me
1833+ |> fun config -> Helpers. ldaps_enabled_in_config ~config
1834+ in
1835+ ( match coordinator_ldaps = local_ldaps with
1836+ | true ->
1837+ ()
1838+ | false ->
1839+ Xapi_host. external_auth_set_ldaps ~__context ~host: me
1840+ ~ldaps: coordinator_ldaps ~force: true
1841+ ) ;
18111842 (* this is where we try and sync up as much state as we can
18121843 with the master. This is "best effort" rather than
18131844 critical; if we fail part way through this then we carry
18141845 on with the join *)
1815- try
1816- update_non_vm_metadata ~__context ~rpc ~session_id ;
1817- ignore
1818- (Importexport. remote_metadata_export_import ~__context ~rpc
1819- ~session_id ~remote_address: master_address ~restore: true `All
1820- )
1821- with e ->
1822- debug " Error whilst importing db objects into master; aborted: %s"
1823- (Printexc. to_string e) ;
1824- warn
1846+ ignore_error ~msg: " Error whilst importing db objects into master; aborted"
1847+ ~warn:
18251848 " Error whilst importing db objects to master. The pool-join \
18261849 operation will continue, but some of the slave's VMs may not be \
18271850 available on the master."
1851+ @@ fun () ->
1852+ update_non_vm_metadata ~__context ~rpc ~session_id ;
1853+ ignore
1854+ (Importexport. remote_metadata_export_import ~__context ~rpc ~session_id
1855+ ~remote_address: master_address ~restore: true `All
1856+ )
18281857 )
18291858 (fun () -> Client.Session. logout ~rpc ~session_id ) ;
18301859
0 commit comments