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-405628: unmount/detach PVS cache VDI before destroying #6266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions ocaml/xapi/pvs_cache_vdi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,22 @@ let get_or_recreate_vdi ~__context ~self =
vdi
)

let ensure_vdi_is_closed ~__context vdi =
(* The pvsproxy daemon normally unmounts and removes the locally attached VBD
for the cache VDI. Here we do it as well, just in case pvsproxy did not
manage to, for whatever reason. *)
try
let uuid = Db.VDI.get_uuid ~__context ~self:vdi in
let _ = Helpers.call_script !Xapi_globs.pvsproxy_close_cache_vdi [uuid] in
()
with _ -> () (* call_script will log anything interesting already *)

let destroy_vdi ~__context ~self =
match get_vdi ~__context ~self with
| None ->
() (* The VDI doesn't exist anymore; nothing to do. *)
| Some vdi ->
ensure_vdi_is_closed ~__context vdi ;
Helpers.call_api_functions ~__context (fun rpc session_id ->
Client.Client.VDI.destroy ~rpc ~session_id ~self:vdi
)
6 changes: 6 additions & 0 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,8 @@ let dracut = ref "/usr/bin/dracut"

let udevadm = ref "/usr/sbin/udevadm"

let pvsproxy_close_cache_vdi = ref "/opt/citrix/pvsproxy/close-cache-vdi.sh"

let yum_repos_config_dir = ref "/etc/yum.repos.d"

let remote_repository_prefix = ref "remote"
Expand Down Expand Up @@ -1805,6 +1807,10 @@ module Resources = struct
; ("depmod", depmod, "Path to depmod command")
; ("dracut", dracut, "Path to dracut command")
; ("udevadm", udevadm, "Path to udevadm command")
; ( "pvsproxy_close_cache_vdi"
, pvsproxy_close_cache_vdi
, "Path to close-cache-vdi.sh"
)
]

let nonessential_executables =
Expand Down
Loading