@@ -1869,10 +1869,7 @@ let enable __context heartbeat_srs configuration =
18691869 with _ -> false
18701870 in
18711871 if not alive then
1872- raise
1873- (Api_errors. Server_error
1874- (Api_errors. host_offline, [Ref. string_of host])
1875- )
1872+ raise Api_errors. (Server_error (host_offline, [Ref. string_of host]))
18761873 )
18771874 (Db.Host. get_all ~__context) ;
18781875 let pool = Helpers. get_pool ~__context in
@@ -1897,20 +1894,23 @@ let enable __context heartbeat_srs configuration =
18971894 else
18981895 heartbeat_srs
18991896 in
1900- if possible_srs = [] then
1901- raise (Api_errors. Server_error (Api_errors. cannot_create_state_file, [] )) ;
1902- (* For the moment we'll create a state file in one compatible SR since the xHA component only handles one *)
1903- let srs = [List. hd possible_srs] in
1897+ (* For the moment we'll create a state file in one compatible SR since the
1898+ xHA component only handles one *)
1899+ let sr =
1900+ match possible_srs with
1901+ | [] ->
1902+ raise Api_errors. (Server_error (cannot_create_state_file, [] ))
1903+ | sr :: _ ->
1904+ sr
1905+ in
19041906 List. iter
19051907 (fun sr ->
19061908 let vdi = Xha_statefile. find_or_create ~__context ~sr ~cluster_stack in
19071909 statefile_vdis := vdi :: ! statefile_vdis
19081910 )
1909- srs ;
1911+ [sr] ;
19101912 (* For storing the database, assume there is only one SR *)
1911- let database_vdi =
1912- Xha_metadata_vdi. find_or_create ~__context ~sr: (List. hd srs)
1913- in
1913+ let database_vdi = Xha_metadata_vdi. find_or_create ~__context ~sr in
19141914 database_vdis := database_vdi :: ! database_vdis ;
19151915 (* Record the statefile UUIDs in the Pool.ha_statefile set *)
19161916 Db.Pool. set_ha_statefiles ~__context ~self: pool
@@ -1991,14 +1991,16 @@ let enable __context heartbeat_srs configuration =
19911991 (ExnHelper. string_of_exn e)
19921992 )
19931993 errors ;
1994- if errors <> [] then (
1995- (* Perform a disable since the pool HA state isn't consistent *)
1996- error " Attempting to disable HA pool-wide" ;
1997- Helpers. log_exn_continue
1998- " Disabling HA after a failure joining all hosts to the liveset"
1999- disable_internal __context ;
2000- raise (snd (List. hd errors))
2001- ) ;
1994+ List. iter
1995+ (fun (_ , exn ) ->
1996+ (* Perform a disable since the pool HA state isn't consistent *)
1997+ error " Attempting to disable HA pool-wide" ;
1998+ Helpers. log_exn_continue
1999+ " Disabling HA after a failure joining all hosts to the liveset"
2000+ disable_internal __context ;
2001+ raise exn
2002+ )
2003+ errors ;
20022004 (* We have to set the HA enabled flag before forcing a database resynchronisation *)
20032005 Db.Pool. set_ha_enabled ~__context ~self: pool ~value: true ;
20042006 debug " HA enabled" ;
@@ -2036,13 +2038,16 @@ let enable __context heartbeat_srs configuration =
20362038 (ExnHelper. string_of_exn e)
20372039 )
20382040 errors ;
2039- if errors <> [] then (
2040- (* Perform a disable since the pool HA state isn't consistent *)
2041- error " Attempting to disable HA pool-wide" ;
2042- Helpers. log_exn_continue " Disabling HA after a failure during enable"
2043- disable_internal __context ;
2044- raise (snd (List. hd errors))
2045- ) ;
2041+ List. iter
2042+ (fun (_ , exn ) ->
2043+ (* Perform a disable since the pool HA state isn't consistent *)
2044+ error " Attempting to disable HA pool-wide" ;
2045+ Helpers. log_exn_continue
2046+ " Disabling HA after a failure during enable" disable_internal
2047+ __context ;
2048+ raise exn
2049+ )
2050+ errors ;
20462051 (* Update the allowed_operations on the HA volumes to prevent people thinking they can mess with them *)
20472052 List. iter
20482053 (fun vdi -> Xapi_vdi. update_allowed_operations ~__context ~self: vdi)
0 commit comments