From 098546a8d36ec4956ae3877d68847d079ab26729 Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Thu, 5 Dec 2024 15:06:36 +0000 Subject: [PATCH] CA-390025: do not override SR's client-set metadata on update Some plugins may not store the client-set metadata, and return a static value when replying to the update. This would override the values that a client used when the SR was created, or set afterwards, which is unexpected. Now name_label and name_description fields returned by the plugins are ignored on update. Current set_name_label and set_name_description rely on the update mechanism to work. Instead add database call at the end of the methods to ensure both xapi and the SR backend are synchronized, even when the latter fails to update the values. Signed-off-by: Pau Ruiz Safont --- ocaml/xapi/xapi_sr.ml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ocaml/xapi/xapi_sr.ml b/ocaml/xapi/xapi_sr.ml index 0c4c88aa5d..12ab2bef92 100644 --- a/ocaml/xapi/xapi_sr.ml +++ b/ocaml/xapi/xapi_sr.ml @@ -575,9 +575,6 @@ let update ~__context ~sr = Db.SR.get_uuid ~__context ~self:sr |> Storage_interface.Sr.of_string in let sr_info = C.SR.stat (Ref.string_of task) sr' in - Db.SR.set_name_label ~__context ~self:sr ~value:sr_info.name_label ; - Db.SR.set_name_description ~__context ~self:sr - ~value:sr_info.name_description ; Db.SR.set_physical_size ~__context ~self:sr ~value:sr_info.total_space ; Db.SR.set_physical_utilisation ~__context ~self:sr ~value:(Int64.sub sr_info.total_space sr_info.free_space) ; @@ -846,7 +843,7 @@ let set_name_label ~__context ~sr ~value = (Storage_interface.Sr.of_string sr') value ) ; - update ~__context ~sr + Db.SR.set_name_label ~__context ~self:sr ~value let set_name_description ~__context ~sr ~value = let open Storage_access in @@ -860,7 +857,7 @@ let set_name_description ~__context ~sr ~value = (Storage_interface.Sr.of_string sr') value ) ; - update ~__context ~sr + Db.SR.set_name_description ~__context ~self:sr ~value let set_virtual_allocation ~__context ~self ~value = Db.SR.set_virtual_allocation ~__context ~self ~value