Skip to content

Commit

Permalink
CA-390025: do not override SR's client-set metadata on update
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
psafont committed Dec 9, 2024
1 parent 21b56b4 commit 098546a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ocaml/xapi/xapi_sr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 098546a

Please sign in to comment.