Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
CA-102761: To check if RPU is actually in progress before enabling HA
Signed-off-by: Siddharth Vinothkumar <[email protected]>
  • Loading branch information
siddharthv committed May 24, 2013
commit 10c5091a63cb50cd74f8642beaacc18b2f27825e
20 changes: 19 additions & 1 deletion ocaml/xapi/xapi_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1134,11 +1134,29 @@ let slave_network_report ~__context ~phydevs ~dev_to_mac ~dev_to_mtu ~slave_host
Dbsync_slave.create_physical_networks ~__context phydevs dev_to_mac dev_to_mtu slave_host
*)

let is_rolling_upgrade_actually_in_progress ~__context =
let all_hosts = Db.Host.get_all ~__context in
let platform_versions = List.map (fun host -> Helpers.version_string_of ~__context host) all_hosts in

let is_different_to_me platform_version = platform_version <> Version.platform_version in
let actually_in_progress = List.fold_left (||) false (List.map is_different_to_me platform_versions) in

let pool = List.hd (Db.Pool.get_all ~__context) in
if not actually_in_progress
then begin
if (List.mem_assoc Xapi_globs.rolling_upgrade_in_progress (Db.Pool.get_other_config ~__context ~self:pool))
then
Db.Pool.remove_from_other_config ~__context ~self:pool ~key:Xapi_globs.rolling_upgrade_in_progress;
List.iter (fun vm -> Xapi_vm_lifecycle.update_allowed_operations ~__context ~self:vm) (Db.VM.get_all ~__context)
end
else
raise (Api_errors.Server_error (Api_errors.not_supported_during_upgrade, []))

(* Let's only process one enable/disable at a time. I would have used an allowed_operation for this but
it would involve a datamodel change and it's too late for Orlando. *)
let enable_disable_m = Mutex.create ()
let enable_ha ~__context ~heartbeat_srs ~configuration =
Helpers.assert_rolling_upgrade_not_in_progress ~__context;
is_rolling_upgrade_actually_in_progress ~__context;
Mutex.execute enable_disable_m (fun () -> Xapi_ha.enable __context heartbeat_srs configuration)
let disable_ha ~__context = Mutex.execute enable_disable_m (fun () -> Xapi_ha.disable __context)

Expand Down