@@ -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 ;
@@ -984,19 +986,18 @@ let ha_start_daemon () =
984986 ()
985987
986988let on_server_restart () =
987- let armed = bool_of_string (Localdb. get Constants. ha_armed) in
988- if armed then (
989+ let armed () =
990+ Localdb. get_bool Constants. ha_armed |> Option. value ~default: false
991+ in
992+ if armed () then (
989993 debug " HA is supposed to be armed" ;
990994 (* Make sure daemons are up *)
991995 let finished = ref false in
992996 (* Do not proceed any further until the situation is resolved.
993997 XXX we might need some kind of user-override *)
994998 while not ! finished do
995999 (* If someone has called Host.emergency_ha_disable in the background then we notice the change here *)
996- if
997- not
998- (try bool_of_string (Localdb. get Constants. ha_armed) with _ -> false )
999- then (
1000+ if not (armed () ) then (
10001001 warn
10011002 " ha_start_daemon aborted because someone has called \
10021003 Host.emergency_ha_disable" ;
@@ -1147,7 +1148,7 @@ let ha_stop_daemon __context _localhost =
11471148
11481149let emergency_ha_disable __context soft =
11491150 let ha_armed =
1150- try bool_of_string ( Localdb. get Constants. ha_armed) with _ -> false
1151+ Localdb. get_bool Constants. ha_armed |> Option. value ~default: false
11511152 in
11521153 if not ha_armed then
11531154 if soft then
0 commit comments