@@ -84,7 +84,9 @@ let create ~__context ~pIF ~cluster_stack ~pool_auto_join ~token_timeout
8484 set_ha_cluster_stack ~__context ;
8585 cluster_ref
8686 | Error error ->
87- D. warn " Error occurred during Cluster.create" ;
87+ D. warn
88+ " Error occurred during Cluster.create. Shutting down cluster daemon" ;
89+ Xapi_clustering.Daemon. disable ~__context ;
8890 handle_error error)
8991
9092let destroy ~__context ~self =
@@ -119,30 +121,6 @@ let get_network ~__context ~self = get_network_internal ~__context ~self
119121(* * Cluster.pool* functions are convenience wrappers for iterating low-level APIs over a pool.
120122 Concurrency checks are done in the implementation of these calls *)
121123
122- let pool_create ~__context ~network ~cluster_stack ~token_timeout
123- ~token_timeout_coefficient =
124- validate_params ~token_timeout ~token_timeout_coefficient ;
125- let master = Helpers. get_master ~__context in
126- let slave_hosts = Xapi_pool_helpers. get_slaves_list ~__context in
127- let pIF, _ = pif_of_host ~__context network master in
128- let cluster =
129- Helpers. call_api_functions ~__context (fun rpc session_id ->
130- Client.Client.Cluster. create ~rpc ~session_id ~p IF ~cluster_stack
131- ~pool_auto_join: true ~token_timeout ~token_timeout_coefficient )
132- in
133- List. iter
134- (fun host ->
135- (* Cluster.create already created cluster_host on master, so we only iterate through slaves *)
136- Helpers. call_api_functions ~__context (fun rpc session_id ->
137- let pif, _ = pif_of_host ~__context network host in
138- let cluster_host_ref =
139- Client.Client.Cluster_host. create ~rpc ~session_id ~cluster ~host
140- ~pif
141- in
142- D. debug " Created Cluster_host: %s" (Ref. string_of cluster_host_ref)))
143- slave_hosts ;
144- cluster
145-
146124let foreach_cluster_host ~__context ~self
147125 ~(fn :
148126 rpc:(Rpc.call -> Rpc.response)
@@ -212,6 +190,42 @@ let pool_destroy ~__context ~self =
212190 Helpers. call_api_functions ~__context (fun rpc session_id ->
213191 Client.Client.Cluster. destroy ~rpc ~session_id ~self )
214192
193+ let pool_create ~__context ~network ~cluster_stack ~token_timeout
194+ ~token_timeout_coefficient =
195+ validate_params ~token_timeout ~token_timeout_coefficient ;
196+ let master = Helpers. get_master ~__context in
197+ let slave_hosts = Xapi_pool_helpers. get_slaves_list ~__context in
198+ let pIF, _ = pif_of_host ~__context network master in
199+ let cluster =
200+ Helpers. call_api_functions ~__context (fun rpc session_id ->
201+ Client.Client.Cluster. create ~rpc ~session_id ~p IF ~cluster_stack
202+ ~pool_auto_join: true ~token_timeout ~token_timeout_coefficient )
203+ in
204+ try
205+ List. iter
206+ (fun host ->
207+ (* Cluster.create already created cluster_host on master, so we only iterate through slaves *)
208+ Helpers. call_api_functions ~__context (fun rpc session_id ->
209+ let pif, _ = pif_of_host ~__context network host in
210+ let cluster_host_ref =
211+ Client.Client.Cluster_host. create ~rpc ~session_id ~cluster ~host
212+ ~pif
213+ in
214+ D. debug " Created Cluster_host: %s" (Ref. string_of cluster_host_ref)))
215+ slave_hosts ;
216+ cluster
217+ with e ->
218+ error " pool_create failed. exception='%s'" (Printexc. to_string e) ;
219+ info " pool_create attempting cleanup of cluster=%s"
220+ (Ref. short_string_of cluster) ;
221+ ( try pool_force_destroy ~__context ~self: cluster
222+ with e ->
223+ error " pool_create attempt to clean up cluster=%s failed. ex='%s'"
224+ (Ref. short_string_of cluster)
225+ (Printexc. to_string e)
226+ ) ;
227+ raise e
228+
215229let pool_resync ~__context ~(self : API.ref_Cluster ) =
216230 List. iter
217231 (fun host ->
0 commit comments