@@ -76,8 +76,11 @@ let propose_master () =
7676
7777(* * Returns true if local failover decisions have not been disabled on this node *)
7878let local_failover_decisions_are_ok () =
79- try not (bool_of_string (Localdb. get Constants. ha_disable_failover_decisions))
80- with _ -> true
79+ let disabled =
80+ Localdb. get_bool Constants. ha_disable_failover_decisions
81+ |> Option. value ~default: false
82+ in
83+ not disabled
8184
8285(* * Since the liveset info doesn't include the host IP address, we persist these ourselves *)
8386let write_uuid_to_ip_mapping ~__context =
@@ -91,8 +94,11 @@ let write_uuid_to_ip_mapping ~__context =
9194
9295(* * Since the liveset info doesn't include the host IP address, we persist these ourselves *)
9396let get_uuid_to_ip_mapping () =
94- let v = Localdb. get Constants. ha_peers in
95- String_unmarshall_helper. map (fun x -> x) (fun x -> x) v
97+ match Localdb. get Constants. ha_peers with
98+ | Some peers ->
99+ String_unmarshall_helper. map (fun k -> k) (fun v -> v) peers
100+ | None ->
101+ []
96102
97103(* * Without using the Pool's database, returns the IP address of a particular host
98104 named by UUID. *)
@@ -303,7 +309,7 @@ module Monitor = struct
303309 let statefiles = Xha_statefile. list_existing_statefiles () in
304310 debug " HA background thread starting" ;
305311 (* Grab the base timeout value so we can cook the reported latencies *)
306- let base_t = int_of_string (Localdb. get Constants. ha_base_t) in
312+ let base_t = int_of_string (Localdb. get_exn Constants. ha_base_t) in
307313 let timeouts = Timeouts. derive base_t in
308314 (* Set up our per-host alert triggers *)
309315 let localhost_uuid = Helpers. get_localhost_uuid () in
@@ -501,8 +507,6 @@ module Monitor = struct
501507 )
502508 in
503509
504- (* let planned_for = Int64.to_int (Db.Pool.get_ha_plan_exists_for ~__context ~self:pool) in *)
505-
506510 (* First consider whether VM failover actions need to happen.
507511 Convert the liveset into a list of Host references used by the VM failover code *)
508512 let liveset_uuids =
@@ -629,11 +633,9 @@ module Monitor = struct
629633 (* and yet has no statefile access *)
630634 in
631635 let all_live_nodes_lost_statefile =
632- List. fold_left ( && ) true
633- (List. map
634- (fun (_ , xha_host ) -> relying_on_rule_2 xha_host)
635- host_host_table
636- )
636+ List. for_all
637+ (fun (_ , xha_host ) -> relying_on_rule_2 xha_host)
638+ host_host_table
637639 in
638640 warning_all_live_nodes_lost_statefile
639641 all_live_nodes_lost_statefile ;
@@ -971,6 +973,7 @@ let update_ha_firewalld_service status =
971973 need. *)
972974 if
973975 Localdb. get Constants. ha_cluster_stack
976+ |> Option. value ~default: ! Xapi_globs. cluster_stack_default
974977 = Constants.Ha_cluster_stack. (to_string Xhad )
975978 then
976979 let module Fw =
@@ -986,19 +989,18 @@ let ha_start_daemon () =
986989 ()
987990
988991let on_server_restart () =
989- let armed = bool_of_string (Localdb. get Constants. ha_armed) in
990- if armed then (
992+ let armed () =
993+ Localdb. get_bool Constants. ha_armed |> Option. value ~default: false
994+ in
995+ if armed () then (
991996 debug " HA is supposed to be armed" ;
992997 (* Make sure daemons are up *)
993998 let finished = ref false in
994999 (* Do not proceed any further until the situation is resolved.
9951000 XXX we might need some kind of user-override *)
9961001 while not ! finished do
9971002 (* If someone has called Host.emergency_ha_disable in the background then we notice the change here *)
998- if
999- not
1000- (try bool_of_string (Localdb. get Constants. ha_armed) with _ -> false )
1001- then (
1003+ if not (armed () ) then (
10021004 warn
10031005 " ha_start_daemon aborted because someone has called \
10041006 Host.emergency_ha_disable" ;
@@ -1149,7 +1151,7 @@ let ha_stop_daemon __context _localhost =
11491151
11501152let emergency_ha_disable __context soft =
11511153 let ha_armed =
1152- try bool_of_string ( Localdb. get Constants. ha_armed) with _ -> false
1154+ Localdb. get_bool Constants. ha_armed |> Option. value ~default: false
11531155 in
11541156 if not ha_armed then
11551157 if soft then
0 commit comments