Skip to content

Commit 098546a

Browse files
committed
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 <pau.ruizsafont@cloud.com>
1 parent 21b56b4 commit 098546a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

ocaml/xapi/xapi_sr.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,6 @@ let update ~__context ~sr =
575575
Db.SR.get_uuid ~__context ~self:sr |> Storage_interface.Sr.of_string
576576
in
577577
let sr_info = C.SR.stat (Ref.string_of task) sr' in
578-
Db.SR.set_name_label ~__context ~self:sr ~value:sr_info.name_label ;
579-
Db.SR.set_name_description ~__context ~self:sr
580-
~value:sr_info.name_description ;
581578
Db.SR.set_physical_size ~__context ~self:sr ~value:sr_info.total_space ;
582579
Db.SR.set_physical_utilisation ~__context ~self:sr
583580
~value:(Int64.sub sr_info.total_space sr_info.free_space) ;
@@ -846,7 +843,7 @@ let set_name_label ~__context ~sr ~value =
846843
(Storage_interface.Sr.of_string sr')
847844
value
848845
) ;
849-
update ~__context ~sr
846+
Db.SR.set_name_label ~__context ~self:sr ~value
850847

851848
let set_name_description ~__context ~sr ~value =
852849
let open Storage_access in
@@ -860,7 +857,7 @@ let set_name_description ~__context ~sr ~value =
860857
(Storage_interface.Sr.of_string sr')
861858
value
862859
) ;
863-
update ~__context ~sr
860+
Db.SR.set_name_description ~__context ~self:sr ~value
864861

865862
let set_virtual_allocation ~__context ~self ~value =
866863
Db.SR.set_virtual_allocation ~__context ~self ~value

0 commit comments

Comments
 (0)