Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA-386552 XSI-1534 Failed to disable pool HA after missing HA statefile #5941

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
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
29 changes: 20 additions & 9 deletions ocaml/xapi/xapi_ha.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,7 @@ let emergency_ha_disable __context soft =
)

let ha_release_resources __context localhost =
let __FUNCTION__ = "ha_release_resources" in
Monitor.stop () ;

(* Why aren't we calling Xha_statefile.detach_existing_statefiles?
Expand All @@ -1168,14 +1169,17 @@ let ha_release_resources __context localhost =
let statefile_vdis =
Db.Pool.get_ha_statefiles ~__context ~self:(Helpers.get_pool ~__context)
and deactivate_and_detach_vdi vdi_str =
let uuid = Db.VDI.get_uuid ~__context ~self:(Ref.of_string vdi_str) in
Helpers.log_exn_continue
(Printf.sprintf "detaching statefile VDI uuid: %s" uuid)
(fun () ->
Static_vdis.permanent_vdi_deactivate_by_uuid ~__context ~uuid ;
Static_vdis.permanent_vdi_detach_by_uuid ~__context ~uuid
)
()
match Db.VDI.get_uuid ~__context ~self:(Ref.of_string vdi_str) with
| uuid ->
Helpers.log_exn_continue
(Printf.sprintf "detaching statefile VDI uuid: %s" uuid)
(fun () ->
Static_vdis.permanent_vdi_deactivate_by_uuid ~__context ~uuid ;
Static_vdis.permanent_vdi_detach_by_uuid ~__context ~uuid
)
()
| exception _e ->
warn "%s: VDI %s not found in database" __FUNCTION__ vdi_str
in
List.iter deactivate_and_detach_vdi statefile_vdis ;
(* Deactivate and detach any metadata VDIs *)
Expand Down Expand Up @@ -1516,9 +1520,16 @@ let abort_new_master ~__context ~address =
let disable_internal __context =
debug "Disabling HA on the Pool" ;
let pool = Helpers.get_pool ~__context in
(* Avoid stale static VDIs *)
Static_vdis.gc () ;
(* Find the HA metadata and statefile VDIs for later *)
let statefile_vdis =
List.map Ref.of_string (Db.Pool.get_ha_statefiles ~__context ~self:pool)
let is_valid ref =
if Db.is_valid_ref __context ref then Some ref else None
in
Db.Pool.get_ha_statefiles ~__context ~self:pool
|> List.map Ref.of_string
|> List.filter_map is_valid
in
let metadata_vdis =
List.map
Expand Down