13
13
*)
14
14
15
15
open Xapi_clustering
16
- open Xapi_cluster_helpers
17
16
open Ipaddr_rpc_type
18
17
19
18
module D = Debug. Make (struct let name = " xapi_cluster_host" end )
@@ -55,20 +54,6 @@ let call_api_function_with_alert ~__context ~msg ~cls ~obj_uuid ~body
55
54
raise err
56
55
)
57
56
58
- let alert_for_cluster_host ~__context ~cluster_host ~missing_hosts ~new_hosts =
59
- let num_hosts = Db.Cluster_host. get_all ~__context |> List. length in
60
- let cluster = Db.Cluster_host. get_cluster ~__context ~self: cluster_host in
61
- let quorum = Db.Cluster. get_quorum ~__context ~self: cluster |> Int64. to_int in
62
- maybe_generate_alert ~__context ~missing_hosts ~new_hosts ~num_hosts ~quorum
63
-
64
- let alert_for_cluster_host_leave ~__context ~cluster_host =
65
- alert_for_cluster_host ~__context ~cluster_host ~missing_hosts: [cluster_host]
66
- ~new_hosts: []
67
-
68
- let alert_for_cluster_host_join ~__context ~cluster_host =
69
- alert_for_cluster_host ~__context ~cluster_host ~missing_hosts: []
70
- ~new_hosts: [cluster_host]
71
-
72
57
(* Create xapi db object for cluster_host, resync_host calls clusterd *)
73
58
let create_internal ~__context ~cluster ~host ~pIF : API. ref_Cluster_host =
74
59
with_clustering_lock __LOC__ (fun () ->
@@ -81,7 +66,6 @@ let create_internal ~__context ~cluster ~host ~pIF : API.ref_Cluster_host =
81
66
~enabled: false ~current_operations: [] ~allowed_operations: []
82
67
~other_config: [] ~joined: false ~live: false
83
68
~last_update_live: API.Date. epoch ;
84
- alert_for_cluster_host_join ~__context ~cluster_host: ref ;
85
69
ref
86
70
)
87
71
@@ -232,7 +216,7 @@ let resync_host ~__context ~host =
232
216
(* If we have just joined, enable will prevent concurrent clustering ops *)
233
217
if not (Db.Cluster_host. get_joined ~__context ~self ) then (
234
218
join_internal ~__context ~self ;
235
- create_cluster_watcher_on_master ~__context ~host ;
219
+ Watcher. create_as_necessary ~__context ~host ;
236
220
Xapi_observer. initialise_observer ~__context
237
221
Xapi_observer_components. Xapi_clusterd
238
222
) else if Db.Cluster_host. get_enabled ~__context ~self then (
@@ -269,16 +253,21 @@ let destroy_op ~__context ~self ~force =
269
253
(Cluster_client.LocalClient. leave, " destroy" )
270
254
in
271
255
let result = local_fn (rpc ~__context) dbg in
256
+ let cluster = Db.Cluster_host. get_cluster ~__context ~self in
272
257
match Idl.IdM. run @@ Cluster_client.IDL.T. get result with
273
258
| Ok () ->
274
- alert_for_cluster_host_leave ~__context ~cluster_host: self ;
259
+ Helpers. call_api_functions ~__context (fun rpc session_id ->
260
+ Client.Client.Cluster. cstack_sync ~rpc ~session_id ~self: cluster
261
+ ) ;
275
262
Db.Cluster_host. destroy ~__context ~self ;
276
263
debug " Cluster_host.%s was successful" fn_str ;
277
264
Xapi_clustering.Daemon. disable ~__context
278
265
| Error error ->
279
266
warn " Error occurred during Cluster_host.%s" fn_str ;
280
267
if force then (
281
- alert_for_cluster_host_leave ~__context ~cluster_host: self ;
268
+ Helpers. call_api_functions ~__context (fun rpc session_id ->
269
+ Client.Client.Cluster. cstack_sync ~rpc ~session_id ~self: cluster
270
+ ) ;
282
271
let ref_str = Ref. string_of self in
283
272
Db.Cluster_host. destroy ~__context ~self ;
284
273
debug " Cluster_host %s force destroyed." ref_str
@@ -326,7 +315,9 @@ let forget ~__context ~self =
326
315
Db.Cluster. set_pending_forget ~__context ~self: cluster ~value: [] ;
327
316
(* must not disable the daemon here, because we declared another unreachable node dead,
328
317
* not the current one *)
329
- alert_for_cluster_host_leave ~__context ~cluster_host: self ;
318
+ Helpers. call_api_functions ~__context (fun rpc session_id ->
319
+ Client.Client.Cluster. cstack_sync ~rpc ~session_id ~self: cluster
320
+ ) ;
330
321
Db.Cluster_host. destroy ~__context ~self ;
331
322
debug " Cluster_host.forget was successful"
332
323
| Error error ->
@@ -375,7 +366,7 @@ let enable ~__context ~self =
375
366
" Cluster_host.enable: xapi-clusterd not running - attempting to start" ;
376
367
Xapi_clustering.Daemon. enable ~__context
377
368
) ;
378
- create_cluster_watcher_on_master ~__context ~host ;
369
+ Watcher. create_as_necessary ~__context ~host ;
379
370
Xapi_observer. initialise_observer ~__context
380
371
Xapi_observer_components. Xapi_clusterd ;
381
372
let verify = Stunnel_client. get_verify_by_default () in
0 commit comments