From 3dd0932599a87ec975ab4130c2282be8ad4adbe2 Mon Sep 17 00:00:00 2001 From: Vincent Liu Date: Tue, 6 Feb 2024 14:02:16 +0000 Subject: [PATCH] Refactor cluster_health flag checking This makes it more convenient to feature flag any future cluster_health features (A number of them on the way, such as sending alerts). Signed-off-by: Vincent Liu --- ocaml/xapi/xapi_cluster_helpers.ml | 5 +++++ ocaml/xapi/xapi_clustering.ml | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ocaml/xapi/xapi_cluster_helpers.ml b/ocaml/xapi/xapi_cluster_helpers.ml index bbb51278ada..bbfd5a7ce73 100644 --- a/ocaml/xapi/xapi_cluster_helpers.ml +++ b/ocaml/xapi/xapi_cluster_helpers.ml @@ -103,3 +103,8 @@ let with_cluster_operation ~__context ~(self : [`Cluster] API.Ref.t) ~doc ~op (Datamodel_common._cluster, Ref.string_of self) with _ -> () ) + +let cluster_health_enabled ~__context = + let pool = Helpers.get_pool ~__context in + let restrictions = Db.Pool.get_restrictions ~__context ~self:pool in + List.assoc_opt "restrict_cluster_health" restrictions = Some "false" diff --git a/ocaml/xapi/xapi_clustering.ml b/ocaml/xapi/xapi_clustering.ml index 7bb881b0291..82a27959e1a 100644 --- a/ocaml/xapi/xapi_clustering.ml +++ b/ocaml/xapi/xapi_clustering.ml @@ -515,12 +515,7 @@ let create_cluster_watcher_on_master ~__context ~host = Thread.delay 3. done in - let feature_enabled = - let pool = Helpers.get_pool ~__context in - let restrictions = Db.Pool.get_restrictions ~__context ~self:pool in - List.assoc_opt "restrict_cluster_health" restrictions = Some "false" - in - if feature_enabled then ( + if Xapi_cluster_helpers.cluster_health_enabled ~__context then ( debug "%s: create watcher for corosync-notifyd on master" __FUNCTION__ ; ignore @@ Thread.create watch () ) else