Skip to content

Commit a07cb45

Browse files
author
Lin Liu
committed
CA-422713: XSI-2105: Pool.join failed due to AD status corrupt
The target pool has leaved AD, the joining host leave AD as well. However, the AD status is somehow corrupt - external_auth_type is empty, this is expected - external_auth_service_name is a valid domain This confused pool.join as it thinks AD is not enabled, but somehow joined to a domain. - Normal domain leave does not resolve the issue, and it does not join domain - Join domain again(failed) does not resolve it neither, as xapi will restore to the current value before join on failed. This commit introduce force option to host.disable_external_auth API to force clean up to recover host BTW, current code try to keep them consistent already, but not atomic. Signed-off-by: Lin Liu <lin.liu01@citrix.com>
1 parent c87bde9 commit a07cb45

File tree

6 files changed

+41
-30
lines changed

6 files changed

+41
-30
lines changed

ocaml/idl/datamodel_host.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,13 @@ let disable_external_auth =
20332033
; param_release= george_release
20342034
; param_default= Some (VMap [])
20352035
}
2036+
; {
2037+
param_type= Bool
2038+
; param_name= "force"
2039+
; param_doc= "Disable external auth even not enabled"
2040+
; param_release= numbered_release "26.1.0-next"
2041+
; param_default= Some (VBool false)
2042+
}
20362043
]
20372044
~doc:"This call disables external authentication on the local host"
20382045
~allowed_roles:_R_POOL_ADMIN ()

ocaml/xapi-cli-server/cli_operations.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7089,7 +7089,7 @@ let host_disable_external_auth _printer rpc session_id params =
70897089
let host_uuid = List.assoc "host-uuid" params in
70907090
let host = Client.Host.get_by_uuid ~rpc ~session_id ~uuid:host_uuid in
70917091
let config = read_map_params "config" params in
7092-
Client.Host.disable_external_auth ~rpc ~session_id ~host ~config
7092+
Client.Host.disable_external_auth ~rpc ~session_id ~host ~config ~force:true
70937093

70947094
let host_refresh_pack_info _printer rpc session_id params =
70957095
let host_uuid = List.assoc "host-uuid" params in

ocaml/xapi/message_forwarding.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,11 +3730,13 @@ functor
37303730
in
37313731
do_op_on ~local_fn ~__context ~host ~remote_fn
37323732

3733-
let disable_external_auth ~__context ~host ~config =
3733+
let disable_external_auth ~__context ~host ~config ~force =
37343734
info "Host.disable_external_auth: host = '%s'"
37353735
(host_uuid ~__context host) ;
3736-
let local_fn = Local.Host.disable_external_auth ~host ~config in
3737-
let remote_fn = Client.Host.disable_external_auth ~host ~config in
3736+
let local_fn = Local.Host.disable_external_auth ~host ~config ~force in
3737+
let remote_fn =
3738+
Client.Host.disable_external_auth ~host ~config ~force
3739+
in
37383740
do_op_on ~local_fn ~__context ~host ~remote_fn
37393741

37403742
let install_ca_certificate ~__context ~host ~name ~cert =

ocaml/xapi/xapi_host.ml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,13 +1889,13 @@ let enable_external_auth ~__context ~host ~config ~service_name ~auth_type =
18891889

18901890
(* CP-718: Disables external auth/directory service for host *)
18911891
let disable_external_auth_common ?(during_pool_eject = false) ~__context ~host
1892-
~config () =
1892+
~config ~force () =
18931893
(* CP-825: Serialize execution of host-enable-extauth and host-disable-extauth *)
18941894
(* we need to protect against concurrent access to the host.external_auth_type variable *)
18951895
with_lock serialize_host_enable_disable_extauth (fun () ->
18961896
let host_name_label = Db.Host.get_name_label ~__context ~self:host in
18971897
let auth_type = Db.Host.get_external_auth_type ~__context ~self:host in
1898-
if auth_type = "" then
1898+
if auth_type = "" && not force then
18991899
(* nothing to do, external authentication is already disabled *)
19001900
let msg = "external authentication service is already disabled" in
19011901
debug "Failed to disable external authentication in host %s: %s"
@@ -1936,6 +1936,8 @@ let disable_external_auth_common ?(during_pool_eject = false) ~__context ~host
19361936
, [msg]
19371937
)
19381938
)
1939+
| Extauth_is_disabled ->
1940+
Some Extauth_is_disabled
19391941
| e ->
19401942
(*absorb any exception*)
19411943
debug
@@ -1957,19 +1959,6 @@ let disable_external_auth_common ?(during_pool_eject = false) ~__context ~host
19571959
Xapi_globs.event_hook_auth_on_xapi_initialize_succeeded := true ;
19581960

19591961
(* succeeds because there's no need to initialize anymore *)
1960-
1961-
(* If any cache is present, clear it in order to ensure cached
1962-
logins don't persist after disabling external
1963-
authentication. *)
1964-
Xapi_session.clear_external_auth_cache () ;
1965-
1966-
(* 3. CP-703: we always revalidate all sessions after the external authentication has been disabled *)
1967-
(* so that all sessions that were externally authenticated will be destroyed *)
1968-
debug
1969-
"calling revalidate_all_sessions after disabling external auth for \
1970-
host %s"
1971-
host_name_label ;
1972-
Xapi_session.revalidate_all_sessions ~__context ;
19731962
if not during_pool_eject then
19741963
(* CA-28168 *)
19751964
(* CA-24856: detect non-homogeneous external-authentication config in this host *)
@@ -1978,19 +1967,18 @@ let disable_external_auth_common ?(during_pool_eject = false) ~__context ~host
19781967
if auth_type = Xapi_globs.auth_type_AD then
19791968
Extauth_ad.stop_backend_daemon ~wait_until_success:false ;
19801969
match plugin_disable_failure with
1981-
| None ->
1970+
(* we do not want to stop pool_eject and permit Extauth_is_disabled during force *)
1971+
| Some e when during_pool_eject || (e = Extauth_is_disabled && force) ->
19821972
()
19831973
| Some e ->
1984-
if not during_pool_eject then
1985-
raise e (* bubble up plugin's on_disable exception *)
1986-
else
1987-
()
1988-
(* we do not want to stop pool_eject *)
1974+
raise e
1975+
| None ->
1976+
()
19891977
)
19901978

1991-
let disable_external_auth ~__context ~host ~config =
1979+
let disable_external_auth ~__context ~host ~config ~force =
19921980
disable_external_auth_common ~during_pool_eject:false ~__context ~host ~config
1993-
()
1981+
~force ()
19941982

19951983
module Static_vdis_list = Xapi_database.Static_vdis_list
19961984

ocaml/xapi/xapi_host.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,15 @@ val disable_external_auth_common :
361361
-> __context:Context.t
362362
-> host:API.ref_host
363363
-> config:(string * string) list
364+
-> force:bool
364365
-> unit
365366
-> unit
366367

367368
val disable_external_auth :
368369
__context:Context.t
369370
-> host:API.ref_host
370371
-> config:(string * string) list
372+
-> force:bool
371373
-> unit
372374

373375
(** {2 Static VDIs} *)

ocaml/xapi/xapi_pool.ml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,7 @@ let eject_self ~__context ~host =
20372037
(* disable the external authentication of this slave being ejected *)
20382038
(* this call will return an exception if something goes wrong *)
20392039
Xapi_host.disable_external_auth_common ~during_pool_eject:true ~__context
2040-
~host ~config:[] () ;
2040+
~host ~config:[] ~force:false () ;
20412041

20422042
(* FIXME: in the future, we should send the windows AD admin/pass here *)
20432043
(* in order to remove the slave from the AD database during pool-eject *)
@@ -2973,7 +2973,7 @@ let enable_external_auth ~__context ~pool:_ ~config ~service_name ~auth_type =
29732973
(* best-effort attempt to disable all enabled hosts, swallowing any exceptions *)
29742974
try
29752975
call_fn_on_host ~__context
2976-
(Client.Host.disable_external_auth ~config)
2976+
(Client.Host.disable_external_auth ~config ~force:false)
29772977
host
29782978
with e ->
29792979
debug
@@ -3041,7 +3041,7 @@ let disable_external_auth ~__context ~pool:_ ~config =
30413041
(* forward the call to the host in the pool *)
30423042
try
30433043
call_fn_on_host ~__context
3044-
(Client.Host.disable_external_auth ~config)
3044+
(Client.Host.disable_external_auth ~config ~force:false)
30453045
host ;
30463046
(* no failed host to add to the filtered list, just visit next host *)
30473047
(host, "", "")
@@ -3100,9 +3100,21 @@ let disable_external_auth ~__context ~pool:_ ~config =
31003100
)
31013101
)
31023102
) else (* OK *)
3103+
(
3104+
(* If any cache is present, clear it in order to ensure cached
3105+
logins don't persist after disabling external
3106+
authentication. *)
3107+
Xapi_session.clear_external_auth_cache () ;
3108+
3109+
(* CP-703: we always revalidate all sessions after the external authentication has been disabled *)
3110+
(* so that all sessions that were externally authenticated will be destroyed *)
3111+
debug "calling revalidate_all_sessions after disabling external auth" ;
3112+
Xapi_session.revalidate_all_sessions ~__context ;
3113+
31033114
debug
31043115
"The external authentication of all hosts in the pool was disabled \
31053116
successfully"
3117+
)
31063118
)
31073119

31083120
(* CA-24856: detect non-homogeneous external-authentication config in pool *)

0 commit comments

Comments
 (0)