Skip to content

Commit

Permalink
fixup! CP-48027: Corosync upgrade add cluster_stack_version datamod…
Browse files Browse the repository at this point in the history
…el change
  • Loading branch information
Vincent-lau committed May 9, 2024
1 parent cbbc21c commit d402f1c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions ocaml/xapi-idl/cluster/cluster_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ module LocalAPI (R : RPC) = struct
)

let switch_cluster_stack =
let cluster_stack_p = Param.mk ~name:"cluster_stack" my_string in
declare "switch_cluster_stack_version"
let cluster_stack_p = Param.mk ~name:"cluster_stack" Cluster_stack.t in
declare "switch-cluster-stack"
["Switch cluster stack version to the target"]
(debug_info_p @-> cluster_stack_p @-> returning unit_p err)

Expand Down
3 changes: 2 additions & 1 deletion ocaml/xapi/xapi_cluster.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ let create ~__context ~pIF ~cluster_stack ~pool_auto_join ~token_timeout
in
Xapi_clustering.Daemon.enable ~__context ;
maybe_switch_cluster_stack_version ~__context ~self:cluster_host_ref
~cluster_stack:(cluster_stack ^ Int64.to_string cluster_stack_version) ;
~cluster_stack:
(Cluster_stack.of_version (cluster_stack, cluster_stack_version)) ;
let result =
Cluster_client.LocalClient.create (rpc ~__context) dbg init_config
in
Expand Down
32 changes: 17 additions & 15 deletions ocaml/xapi/xapi_cluster_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ let set_tls_config ~__context ~self ~verify =

(* Helper function atomically enables clusterd and joins the cluster_host *)
let join_internal ~__context ~self =
let open Cluster_interface in
with_clustering_lock __LOC__ (fun () ->
let pIF = Db.Cluster_host.get_PIF ~__context ~self in
fix_pif_prerequisites ~__context pIF ;
Expand All @@ -131,26 +132,25 @@ let join_internal ~__context ~self =
Db.Cluster.get_cluster_token ~__context ~self:cluster
in
let cluster_stack =
Db.Cluster.get_cluster_stack ~__context ~self:cluster
^ Int64.to_string
(Db.Cluster.get_cluster_stack_version ~__context ~self:cluster)
Cluster_stack.of_version
( Db.Cluster.get_cluster_stack ~__context ~self:cluster
, Db.Cluster.get_cluster_stack_version ~__context ~self:cluster
)
in
let ip_addr = ip_of_pif (pIF, Db.PIF.get_record ~__context ~self:pIF) in
let hostuuid = Inventory.lookup Inventory._installation_uuid in
let host = Db.Cluster_host.get_host ~__context ~self in
let hostname = Db.Host.get_hostname ~__context ~self:host in
let member =
if Xapi_cluster_helpers.cluster_health_enabled ~__context then
Cluster_interface.(
Extended
{
ip= Ipaddr.of_string_exn (ipstr_of_address ip_addr)
; hostuuid
; hostname
}
)
Extended
{
ip= Ipaddr.of_string_exn (ipstr_of_address ip_addr)
; hostuuid
; hostname
}
else
Cluster_interface.(IPv4 (ipstr_of_address ip_addr))
IPv4 (ipstr_of_address ip_addr)
in
let ip_list =
List.filter_map
Expand Down Expand Up @@ -220,10 +220,12 @@ let resync_host ~__context ~host =
let obj_uuid = Db.Host.get_uuid ~__context ~self:host in
let cluster = Db.Cluster_host.get_cluster ~__context ~self in
let cluster_stack =
Db.Cluster.get_cluster_stack ~__context ~self:cluster
^ Int64.to_string
(Db.Cluster.get_cluster_stack_version ~__context ~self:cluster)
Cluster_interface.Cluster_stack.of_version
( Db.Cluster.get_cluster_stack ~__context ~self:cluster
, Db.Cluster.get_cluster_stack_version ~__context ~self:cluster
)
in

call_api_function_with_alert ~__context
~msg:Api_messages.cluster_host_enable_failed ~cls:`Host ~obj_uuid ~body
~api_func:(fun rpc session_id ->
Expand Down
5 changes: 3 additions & 2 deletions ocaml/xapi/xapi_clustering.ml
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,10 @@ let rpc ~__context =

let maybe_switch_cluster_stack_version ~__context ~self ~cluster_stack =
if Xapi_cluster_helpers.corosync3_enabled ~__context then
let dbg = Context.string_of_task_and_tracing __context in
let result =
Cluster_client.LocalClient.switch_cluster_stack (rpc ~__context)
"maybe_switch_cluster_stack_version" cluster_stack
Cluster_client.LocalClient.switch_cluster_stack (rpc ~__context) dbg
cluster_stack
in
match Idl.IdM.run @@ Cluster_client.IDL.T.get result with
| Ok () ->
Expand Down

0 comments on commit d402f1c

Please sign in to comment.