Skip to content

Commit 8714b64

Browse files
author
Jon Ludlam
authored
Merge pull request xapi-project#235 from robhoes/ca225070-ely
CA-225070: Refined order of xapi/xhad/attach-static-vdis start/stop
2 parents c148c2b + 9b40250 commit 8714b64

File tree

9 files changed

+41
-30
lines changed

9 files changed

+41
-30
lines changed

ocaml/idl/datamodel.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4476,7 +4476,9 @@ let host_emergency_ha_disable = call ~flags:[`Session]
44764476
~name:"emergency_ha_disable"
44774477
~in_oss_since:None
44784478
~in_product_since:rel_orlando
4479-
~params:[]
4479+
~versioned_params:
4480+
[{param_type=Bool; param_name="soft"; param_doc="Disable HA temporarily, revert upon host reboot or further changes, idempotent"; param_release=dundee_plus_release; param_default=Some(VBool false)};
4481+
]
44804482
~doc:"This call disables HA on the local host. This should only be used with extreme care."
44814483
~allowed_roles:_R_POOL_OP
44824484
()

ocaml/xapi/cli_operations.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4393,8 +4393,9 @@ let host_emergency_management_reconfigure printer rpc session_id params =
43934393

43944394
let host_emergency_ha_disable printer rpc session_id params =
43954395
let force = get_bool_param params "force" in
4396+
let soft = get_bool_param params "soft" in
43964397
if not force then failwith "This operation is extremely dangerous and may cause data loss. This operation must be forced (use --force).";
4397-
Client.Host.emergency_ha_disable rpc session_id
4398+
Client.Host.emergency_ha_disable rpc session_id soft
43984399

43994400
let host_management_reconfigure printer rpc session_id params =
44004401
let pif = Client.PIF.get_by_uuid rpc session_id (List.assoc "pif-uuid" params) in

ocaml/xapi/message_forwarding.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,9 +2154,9 @@ module Forward = functor(Local: Custom_actions.CUSTOM_ACTIONS) -> struct
21542154
info "Host.local_management_reconfigure: interface = '%s'" interface;
21552155
Local.Host.local_management_reconfigure ~__context ~interface
21562156

2157-
let emergency_ha_disable ~__context =
2158-
info "Host.emergency_ha_disable";
2159-
Local.Host.emergency_ha_disable ~__context
2157+
let emergency_ha_disable ~__context ~soft =
2158+
info "Host.emergency_ha_disable: soft = '%b'" soft;
2159+
Local.Host.emergency_ha_disable ~__context ~soft
21602160

21612161
(* Dummy implementation for a deprecated API method. *)
21622162
let get_uncooperative_resident_VMs ~__context ~self =

ocaml/xapi/xapi_ha.ml

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -834,27 +834,33 @@ let ha_stop_daemon __context localhost =
834834
let (_ : string) = call_script ha_stop_daemon [] in ()
835835

836836
(** Emergency-mode API call to disarm localhost *)
837-
let emergency_ha_disable __context =
838-
if Localdb.get Constants.ha_armed = "false"
839-
then raise (Api_errors.Server_error(Api_errors.ha_not_enabled, []));
840-
841-
warn "Host.emergency_ha_disable: Disabling the HA subsystem on the local host only.";
842-
Localdb.put Constants.ha_armed "false";
843-
844-
begin
845-
try
846-
ha_disarm_fencing __context ();
847-
with Xha_error e ->
848-
error "Host.emergency_ha_disable: ha_disarm_fencing failed with %s; continuing" (Xha_errno.to_string e)
849-
end;
850-
begin
851-
try
852-
ha_stop_daemon __context ();
853-
with Xha_error e ->
854-
error "Host.emergency_ha_disable: ha_stop_daemon failed with %s; continuing" (Xha_errno.to_string e)
855-
end;
856-
(* Might not be able to access the database to detach statefiles; however this isn't critical *)
857-
()
837+
let emergency_ha_disable __context soft =
838+
let ha_armed = try bool_of_string (Localdb.get Constants.ha_armed) with _ -> false in
839+
if not ha_armed then
840+
if soft then () else raise (Api_errors.Server_error(Api_errors.ha_not_enabled, []))
841+
else begin
842+
warn "Host.emergency_ha_disable: Disabling the HA subsystem on the local host only.";
843+
begin
844+
try
845+
ha_disarm_fencing __context ();
846+
with Xha_error e ->
847+
error "Host.emergency_ha_disable: ha_disarm_fencing failed with %s; continuing" (Xha_errno.to_string e)
848+
end;
849+
begin
850+
try
851+
ha_stop_daemon __context ();
852+
with Xha_error e ->
853+
error "Host.emergency_ha_disable: ha_stop_daemon failed with %s; continuing" (Xha_errno.to_string e)
854+
end;
855+
(* Might not be able to access the database to detach statefiles; however this isn't critical *)
856+
begin
857+
try
858+
ha_set_excluded __context ();
859+
with Xha_error e ->
860+
error "Host.emergency_ha_disable: ha_set_excluded failed with %s; continuing" (Xha_errno.to_string e)
861+
end;
862+
if not soft then Localdb.put Constants.ha_armed "false";
863+
end
858864

859865
(** Internal API call to release any HA resources after the system has
860866
been shutdown. This call is idempotent. Modified for CA-48539 to

ocaml/xapi/xapi_host.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ let abort_new_master ~__context ~address = Xapi_ha.abort_new_master __context ad
728728

729729
let update_master ~__context ~host ~master_address = assert false
730730

731-
let emergency_ha_disable ~__context = Xapi_ha.emergency_ha_disable __context
731+
let emergency_ha_disable ~__context ~soft = Xapi_ha.emergency_ha_disable __context soft
732732

733733
(* This call can be used to _instruct_ a slave that it has to take a persistent backup (force=true).
734734
If force=false then this is a hint from the master that the client may want to take a backup; in this

ocaml/xapi/xapi_host.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ val propose_new_master : __context:'a -> address:string -> manual:'b -> unit
110110
val commit_new_master : __context:Context.t -> address:string -> unit
111111
val abort_new_master : __context:'a -> address:string -> unit
112112
val update_master : __context:'a -> host:'b -> master_address:'c -> 'd
113-
val emergency_ha_disable : __context:'a -> unit
113+
val emergency_ha_disable : __context:'a -> soft:bool -> unit
114114
val request_backup :
115115
__context:Context.t -> host:API.ref_host -> generation:int64 -> force:bool -> unit
116116
val request_config_file_sync : __context:'a -> host:'b -> hash:string -> unit

scripts/attach-static-vdis.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[Unit]
22
Description=Attach statically-configured VDIs to dom0
33
Before=xapi.service
4+
After=network.target nfs-client.target xcp-networkd.service
45

56
[Service]
67
Type=oneshot

scripts/examples/python/shutdown.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def main(session, host_uuid, force):
240240
rc += parallel_clean_shutdown(session, get_running_domains(session, host))
241241
else:
242242
rc += serial_hard_shutdown(session, get_running_domains(session, host))
243+
243244
return rc
244245

245246
if __name__ == "__main__":

scripts/xapi-domains.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Type=oneshot
88
RemainAfterExit=yes
99
EnvironmentFile=@INVENTORY@
1010
ExecStart=@BINDIR@/xapi-autostart-vms
11-
ExecStop=@LIBEXECDIR@/shutdown $INSTALLATION_UUID
12-
ExecStop=@LIBEXECDIR@/shutdown --force $INSTALLATION_UUID
11+
ExecStop=/bin/sh -c "/opt/xensource/libexec/shutdown $INSTALLATION_UUID || /opt/xensource/libexec/shutdown --force $INSTALLATION_UUID"
12+
ExecStop=/opt/xensource/bin/xe host-emergency-ha-disable force=true soft=true
1313

1414
# Generous 24hr timeout that corresponding to the max evacuation time of a host
1515
# with memory close to our support limit. Finer grained timeout control depends

0 commit comments

Comments
 (0)