Skip to content

Commit

Permalink
CP-48027: Add feature flag for corosync3
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Liu <shuntian.liu2@cloud.com>
  • Loading branch information
Vincent-lau committed Apr 18, 2024
1 parent fa6ed91 commit 135a225
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
2 changes: 2 additions & 0 deletions ocaml/xapi/xapi_cluster.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ let create ~__context ~pIF ~cluster_stack ~pool_auto_join ~token_timeout
let cluster_stack_version =
if Xapi_fist.allow_corosync2 () then
2L
else if not (Xapi_cluster_helpers.corosync3_enabled ~__context) then
2L
else
3L
in
Expand Down
5 changes: 5 additions & 0 deletions ocaml/xapi/xapi_cluster_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ let cluster_health_enabled ~__context =
let restrictions = Db.Pool.get_restrictions ~__context ~self:pool in
List.assoc_opt "restrict_cluster_health" restrictions = Some "false"

let corosync3_enabled ~__context =
let pool = Helpers.get_pool ~__context in
let restrictions = Db.Pool.get_restrictions ~__context ~self:pool in
List.assoc_opt "restrict_corosync3" restrictions = Some "false"

let maybe_generate_alert ~__context ~num_hosts ~missing_hosts ~new_hosts ~quorum
=
let generate_alert join cluster_host =
Expand Down
47 changes: 24 additions & 23 deletions ocaml/xapi/xapi_clustering.ml
Original file line number Diff line number Diff line change
Expand Up @@ -181,29 +181,30 @@ let get_corosync_version () =
|> handle_error

let maybe_switch_cluster_stack_version ~__context ~cluster_stack_version =
match Context.get_test_clusterd_rpc __context with
| Some _ ->
debug "in unit test, not switching cluster stack verion"
| None -> (
if cluster_stack_version = 3L then
match get_corosync_version () with
| Cluster_stack.Corosync2 -> (
try
let out, _err =
Forkhelpers.execute_command_get_output
"/usr/libexec/set-system-corosync-version" ["3"]
in
debug "%s: switched to corosync3 %s" __FUNCTION__ out
with Forkhelpers.Spawn_internal_error (out, err, _status) ->
Unix_error
(Printf.sprintf
"failed to switch corosync version out: %s, err :%s" out err
)
|> handle_error
)
| _ ->
debug "already running corosync3, no need to switch"
)
if Xapi_cluster_helpers.corosync3_enabled ~__context then
match Context.get_test_clusterd_rpc __context with
| Some _ ->
debug "in unit test, not switching cluster stack verion"
| None -> (
if cluster_stack_version = 3L then
match get_corosync_version () with
| Cluster_stack.Corosync2 -> (
try
let out, _err =
Forkhelpers.execute_command_get_output
"/usr/libexec/set-system-corosync-version" ["3"]
in
debug "%s: switched to corosync3 %s" __FUNCTION__ out
with Forkhelpers.Spawn_internal_error (out, err, _status) ->
Unix_error
(Printf.sprintf
"failed to switch corosync version out: %s, err :%s" out err
)
|> handle_error
)
| _ ->
debug "already running corosync3, no need to switch"
)

let assert_cluster_stack_valid ~cluster_stack =
if not (List.mem cluster_stack Constants.supported_smapiv3_cluster_stacks)
Expand Down

0 comments on commit 135a225

Please sign in to comment.