Skip to content

Commit 90e4d8d

Browse files
committed
CA-260262: Only allow VDI operations supported by older releases during RPU
Signed-off-by: Gabor Igloi <[email protected]>
1 parent 78aeafe commit 90e4d8d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ocaml/xapi/test_vdi_allowed_operations.ml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,26 @@ let test_cbt =
272272
; "test_vdi_cbt_enabled_check" >:: test_vdi_cbt_enabled_check
273273
]
274274

275+
(** The set of allowed operations must be restricted during rolling pool
276+
upgrade to the enums known by older releases. *)
277+
let test_operations_restricted_during_rpu () =
278+
let __context = Mock.make_context_with_new_db "Mock context" in
279+
let master = Test_common.make_host __context () in
280+
let pool = Test_common.make_pool ~__context ~master () in
281+
Db.Pool.add_to_other_config ~__context ~self:pool ~key:Xapi_globs.rolling_upgrade_in_progress ~value:"x";
282+
run_assert_equal_with_vdi
283+
~__context
284+
~sm_fun:(fun sm -> Db.SM.set_features ~__context ~self:sm ~value:["VDI_MIRROR",1L])
285+
`mirror
286+
(Some(Api_errors.not_supported_during_upgrade, []));
287+
Db.Pool.remove_from_other_config ~__context ~self:pool ~key:Xapi_globs.rolling_upgrade_in_progress;
288+
run_assert_equal_with_vdi
289+
~__context
290+
~sm_fun:(fun sm -> Db.SM.set_features ~__context ~self:sm ~value:["VDI_MIRROR",1L])
291+
`mirror
292+
None
293+
294+
275295
let test =
276296
"test_vdi_allowed_operations" >:::
277297
[
@@ -280,4 +300,5 @@ let test =
280300
"test_ca125187" >:: test_ca125187;
281301
"test_ca126097" >:: test_ca126097;
282302
test_cbt;
303+
"test_operations_restricted_during_rpu" >:: test_operations_restricted_during_rpu;
283304
]

ocaml/xapi/xapi_vdi.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ let check_operation_error ~__context ?(sr_records=[]) ?(pbd_records=[]) ?(vbd_re
7070
4. for other operations, fail if any VBD has currently-attached=true or any VBD
7171
has a current_operation itself
7272
5. HA prevents you from deleting statefiles or metadata volumes
73+
6. During rolling pool upgrade, only operations known by older releases are allowed
7374
*)
75+
if Helpers.rolling_upgrade_in_progress ~__context &&
76+
not (List.mem op Xapi_globs.rpu_allowed_vdi_operations)
77+
then Some (Api_errors.not_supported_during_upgrade, [])
78+
else
7479
(* Don't fail with other_operation_in_progress if VDI mirroring is in progress
7580
* and destroy is called as part of VDI mirroring *)
7681
let is_vdi_mirroring_in_progress = (List.exists (fun (_, op) -> op = `mirror) current_ops) && (op = `destroy) in

0 commit comments

Comments
 (0)