Skip to content

Commit bb63de6

Browse files
authored
CA-409949 CA-408048 XSI-1912 remove unavailable SM plugin by ref (#6490)
When we have multiple SM plugins in XAPI for the same type (which happens only because of past problems) and want to remove the obsolete one, do this iby reference. The code so far was assuming only one per type and looked up the reference by name which was not unique and hence could end up removing the wrong SM entry.
2 parents d27a118 + 760fb26 commit bb63de6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ocaml/xapi/storage_access.ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,14 @@ let on_xapi_start ~__context =
183183
let self, _ = List.assoc ty existing in
184184
try Db.SM.destroy ~__context ~self with _ -> ()
185185
)
186-
(List.concat
187-
[
188-
Listext.List.set_difference (List.map fst existing) to_keep
189-
; List.map fst unavailable
190-
]
191-
) ;
186+
(Listext.List.set_difference (List.map fst existing) to_keep) ;
187+
List.iter
188+
(fun (name, (self, rc)) ->
189+
info "%s: unregistering SM plugin %s (%s) since it is unavailable"
190+
__FUNCTION__ name rc.API.sM_uuid ;
191+
try Db.SM.destroy ~__context ~self with _ -> ()
192+
)
193+
unavailable ;
192194

193195
(* Synchronize SMAPIv1 plugins *)
194196

0 commit comments

Comments
 (0)