Skip to content

Commit 351f29c

Browse files
authored
CA-417520: Fix firewalld issues for HA (#6688)
1. Modify startup order in `server_init`. Checking HA configuration depends on the firewalld service, so move the updating firewalld service before checking HA configuration. 2. HA supports 2 cluster stacks: xha and corosync. Only xha needs to control firewalld service dynamically. For corosync HA, the firewalld service dlm has been already controlled by the xapi-clusterd, so it doesn't need to control dynamically. 3. Slave's HA is shutdown in `ha_wait_for_shutdown_via_statefile`. Add disabling firewalld service here.
2 parents 040e5bc + f573e26 commit 351f29c

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

ocaml/xapi/xapi_ha.ml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -966,13 +966,20 @@ let redo_log_ha_enabled_at_startup () =
966966

967967
(* ----------------------------- *)
968968

969+
let update_ha_firewalld_service status =
970+
(* Only xha needs to enable firewalld service. Other HA cluster stacks don't
971+
need. *)
972+
if Localdb.get Constants.ha_cluster_stack = !Xapi_globs.cluster_stack_default
973+
then
974+
let module Fw =
975+
( val Firewall.firewall_provider !Xapi_globs.firewall_backend
976+
: Firewall.FIREWALL
977+
)
978+
in
979+
Fw.update_firewall_status Firewall.Xenha status
980+
969981
let ha_start_daemon () =
970-
let module Fw =
971-
( val Firewall.firewall_provider !Xapi_globs.firewall_backend
972-
: Firewall.FIREWALL
973-
)
974-
in
975-
Fw.update_firewall_status Firewall.Xenha Firewall.Enabled ;
982+
update_ha_firewalld_service Firewall.Enabled ;
976983
let (_ : string) = call_script ha_start_daemon [] in
977984
()
978985

@@ -1133,15 +1140,9 @@ let ha_set_excluded __context _localhost =
11331140
()
11341141

11351142
let ha_stop_daemon __context _localhost =
1136-
let module Fw =
1137-
( val Firewall.firewall_provider !Xapi_globs.firewall_backend
1138-
: Firewall.FIREWALL
1139-
)
1140-
in
11411143
Monitor.stop () ;
1142-
Fw.update_firewall_status Firewall.Xenha Firewall.Disabled ;
1143-
11441144
let (_ : string) = call_script ha_stop_daemon [] in
1145+
update_ha_firewalld_service Firewall.Disabled ;
11451146
()
11461147

11471148
let emergency_ha_disable __context soft =
@@ -1235,7 +1236,8 @@ let ha_wait_for_shutdown_via_statefile __context _localhost =
12351236
with Xha_error Xha_errno.Mtc_exit_daemon_is_not_present ->
12361237
info
12371238
"ha_wait_for_shutdown_via_statefile: daemon has exited so returning \
1238-
success"
1239+
success" ;
1240+
update_ha_firewalld_service Firewall.Disabled
12391241

12401242
(** Attach the statefile VDIs and return the resulting list of paths in dom0 *)
12411243
let attach_statefiles ~__context statevdis =

ocaml/xapi/xapi_host.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,7 +3404,11 @@ let update_firewalld_service_status ~__context =
34043404
)
34053405
(Db.Tunnel.get_all ~__context)
34063406
| Xenha ->
3407+
(* Only xha needs to enable firewalld service. Other HA cluster
3408+
stacks don't need. *)
34073409
bool_of_string (Localdb.get Constants.ha_armed)
3410+
&& Localdb.get Constants.ha_cluster_stack
3411+
= !Xapi_globs.cluster_stack_default
34083412
in
34093413
List.iter
34103414
(fun s -> if is_enabled s then enable_firewalld_service s)

0 commit comments

Comments
 (0)