Skip to content

Commit d8baca7

Browse files
authored
CA-390025: do not override SR's client-set metadata on update (#6165)
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. Tested on GFS2 tests (JR 4175192), as well as ring3 bvt + bst (209177), and storage validation tests (SR 209180)
2 parents 2c9c9e7 + 098546a commit d8baca7

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

ocaml/xapi/xapi_sr.ml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -360,23 +360,6 @@ let create ~__context ~host ~device_config ~(physical_size : int64) ~name_label
360360
Helpers.assert_rolling_upgrade_not_in_progress ~__context ;
361361
debug "SR.create name_label=%s sm_config=[ %s ]" name_label
362362
(String.concat "; " (List.map (fun (k, v) -> k ^ " = " ^ v) sm_config)) ;
363-
(* This breaks the udev SR which doesn't support sr_probe *)
364-
(*
365-
let probe_result = probe ~__context ~host ~device_config ~_type ~sm_config in
366-
begin
367-
match Xml.parse_string probe_result with
368-
| Xml.Element("SRlist", _, children) -> ()
369-
| _ ->
370-
(* Figure out what was missing, then throw the appropriate error *)
371-
match String.lowercase_ascii _type with
372-
| "lvmoiscsi" ->
373-
if not (List.exists (fun (s,_) -> "targetiqn" = String.lowercase_ascii s) device_config)
374-
then raise (Api_errors.Server_error ("SR_BACKEND_FAILURE_96",["";"";probe_result]))
375-
else if not (List.exists (fun (s,_) -> "scsiid" = String.lowercase_ascii s) device_config)
376-
then raise (Api_errors.Server_error ("SR_BACKEND_FAILURE_107",["";"";probe_result]))
377-
| _ -> ()
378-
end;
379-
*)
380363
let sr_uuid = Uuidx.make () in
381364
let sr_uuid_str = Uuidx.to_string sr_uuid in
382365
(* Create the SR in the database before creating on disk, so the backends can read the sm_config field. If an error happens here
@@ -592,9 +575,6 @@ let update ~__context ~sr =
592575
Db.SR.get_uuid ~__context ~self:sr |> Storage_interface.Sr.of_string
593576
in
594577
let sr_info = C.SR.stat (Ref.string_of task) sr' in
595-
Db.SR.set_name_label ~__context ~self:sr ~value:sr_info.name_label ;
596-
Db.SR.set_name_description ~__context ~self:sr
597-
~value:sr_info.name_description ;
598578
Db.SR.set_physical_size ~__context ~self:sr ~value:sr_info.total_space ;
599579
Db.SR.set_physical_utilisation ~__context ~self:sr
600580
~value:(Int64.sub sr_info.total_space sr_info.free_space) ;
@@ -863,7 +843,7 @@ let set_name_label ~__context ~sr ~value =
863843
(Storage_interface.Sr.of_string sr')
864844
value
865845
) ;
866-
update ~__context ~sr
846+
Db.SR.set_name_label ~__context ~self:sr ~value
867847

868848
let set_name_description ~__context ~sr ~value =
869849
let open Storage_access in
@@ -877,7 +857,7 @@ let set_name_description ~__context ~sr ~value =
877857
(Storage_interface.Sr.of_string sr')
878858
value
879859
) ;
880-
update ~__context ~sr
860+
Db.SR.set_name_description ~__context ~self:sr ~value
881861

882862
let set_virtual_allocation ~__context ~self ~value =
883863
Db.SR.set_virtual_allocation ~__context ~self ~value

0 commit comments

Comments
 (0)