Skip to content

Commit b81ff9d

Browse files
authored
CA-405628: unmount/detach PVS cache VDI before destroying (#6266)
The pvsproxy daemon normally unmounts and removes the locally attached VBD for the cache VDI when needed. We do it as well in `PVS_cache_storage.destroy`, just in case pvsproxy did not manage to, for whatever reason. This should avoid any VDI_IN_USE errors.
2 parents 3183abf + ca18a52 commit b81ff9d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ocaml/xapi/pvs_cache_vdi.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,24 @@ let get_or_recreate_vdi ~__context ~self =
7979
vdi
8080
)
8181

82+
let ensure_vdi_is_closed ~__context vdi =
83+
(* The pvsproxy daemon normally unmounts and removes the locally attached VBD
84+
for the cache VDI. Here we do it as well, just in case pvsproxy did not
85+
manage to, for whatever reason. *)
86+
try
87+
let uuid = Db.VDI.get_uuid ~__context ~self:vdi in
88+
let _ : string =
89+
Helpers.call_script !Xapi_globs.pvsproxy_close_cache_vdi [uuid]
90+
in
91+
()
92+
with _ -> () (* call_script will log anything interesting already *)
93+
8294
let destroy_vdi ~__context ~self =
8395
match get_vdi ~__context ~self with
8496
| None ->
8597
() (* The VDI doesn't exist anymore; nothing to do. *)
8698
| Some vdi ->
99+
ensure_vdi_is_closed ~__context vdi ;
87100
Helpers.call_api_functions ~__context (fun rpc session_id ->
88101
Client.Client.VDI.destroy ~rpc ~session_id ~self:vdi
89102
)

ocaml/xapi/xapi_globs.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,8 @@ let dracut = ref "/usr/bin/dracut"
939939

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

942+
let pvsproxy_close_cache_vdi = ref "/opt/citrix/pvsproxy/close-cache-vdi.sh"
943+
942944
let yum_repos_config_dir = ref "/etc/yum.repos.d"
943945

944946
let remote_repository_prefix = ref "remote"
@@ -1892,6 +1894,10 @@ module Resources = struct
18921894
, "Execute during PIF unplug to get the lun devices related with the \
18931895
ether interface of the PIF"
18941896
)
1897+
; ( "pvsproxy_close_cache_vdi"
1898+
, pvsproxy_close_cache_vdi
1899+
, "Path to close-cache-vdi.sh"
1900+
)
18951901
]
18961902

18971903
let essential_files =

0 commit comments

Comments
 (0)