Skip to content

Commit 834d11d

Browse files
authored
Merge pull request xapi-project#3179 from thomassa/ban-cbt-allowed-ops
CA-260245: Fix SXM: old host choking on new op
2 parents bda7437 + d94fe48 commit 834d11d

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

ocaml/xapi/test_vdi_allowed_operations.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,10 @@ let test_operations_restricted_during_rpu =
302302
Xapi_vdi.update_allowed_operations ~__context ~self;
303303
OUnit.assert_bool "update_allowed_operations should exclude `enable_cbt during RPU" (not @@ List.mem `enable_cbt (Db.VDI.get_allowed_operations ~__context ~self));
304304
Db.Pool.remove_from_other_config ~__context ~self:pool ~key:Xapi_globs.rolling_upgrade_in_progress;
305-
Xapi_vdi.update_allowed_operations ~__context ~self;
305+
Xapi_vdi.update_allowed_operations ~__context ~self
306+
(* CA-260245: at present update_allowed_operations excludes the cbt operations unconditionally.
306307
OUnit.assert_bool "update_allowed_operations should consider `enable_cbt when RPU is not running" (List.mem `enable_cbt (Db.VDI.get_allowed_operations ~__context ~self))
308+
*)
307309
in
308310

309311
"test_operations_restricted_during_rpu" >:::

ocaml/xapi/xapi_vdi.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,17 @@ let update_allowed_operations_internal ~__context ~self ~sr_records ~pbd_records
253253
let pool = Helpers.get_pool ~__context in
254254
let ha_enabled = Db.Pool.get_ha_enabled ~__context ~self:pool in
255255

256+
let all_ops = Listext.List.set_difference
257+
(* Older XenServers choke on ops they don't recognise during SXM, so
258+
* filter out the recently added ones: CA-260245 *)
259+
Xapi_vdi_helpers.all_ops
260+
(`blocked :: Xapi_vdi_helpers.recently_added_ops)
261+
in
256262
let all = Db.VDI.get_record_internal ~__context ~self in
257263
let allowed =
258264
let check x = match check_operation_error ~__context ~sr_records ~pbd_records ~vbd_records ha_enabled all self x with None -> [ x ] | _ -> [] in
259-
List.fold_left (fun accu op -> check op @ accu) []
260-
(Listext.List.set_difference Xapi_vdi_helpers.all_ops [`blocked]) in
265+
List.fold_left (fun accu op -> check op @ accu) [] all_ops
266+
in
261267
let allowed =
262268
if Helpers.rolling_upgrade_in_progress ~__context
263269
then Listext.List.intersect allowed Xapi_globs.rpu_allowed_vdi_operations

ocaml/xapi/xapi_vdi_helpers.ml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ let all_ops: API.vdi_operations list =
4242
; `update
4343
]
4444

45+
(* CA-260245: older XenServer versions do not know about these operations,
46+
* and therefore cannot do storage migration to a XenServer that lists them
47+
* in a VDI's allowed_operations field.
48+
* As a temporary measure, we are fixing the symptom by excluding these ops
49+
* from the allowed_operations list. This is a hack: TECHNICAL DEBT.
50+
* If we were to continue with this mechanism then any additional new ops would
51+
* have to be added to this recently_added_ops list, and we would be able to
52+
* remove items when old-but-supported XenServer versions know about them.
53+
* We would prefer to do a more general fix for this class of problems; we have
54+
* one or two approaches in mind. *)
55+
let recently_added_ops: API.vdi_operations list =
56+
(* If/when items are removed from this list, update
57+
* test_vdi_allowed_operations.ml to re-enable (and maybe alter)
58+
* the relevant part of test_update_allowed_operations. *)
59+
[ `enable_cbt
60+
; `disable_cbt
61+
]
62+
4563
(* CA-26514: Block operations on 'unmanaged' VDIs *)
4664
let assert_managed ~__context ~vdi =
4765
if not (Db.VDI.get_managed ~__context ~self:vdi)

0 commit comments

Comments
 (0)