Skip to content

Commit 97687a3

Browse files
committed
CA-418227: Catch exceptions from host.update_allowed_operations
Spurious errors may occur doing rolling pool upgrades due to change enum, which we should suppress and ignore. Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
1 parent b98371c commit 97687a3

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

ocaml/xapi/xapi_host_helpers.ml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,24 @@ let assert_operation_valid ~__context ~self ~(op : API.host_allowed_operations)
181181
throw_error table op
182182

183183
let update_allowed_operations ~__context ~self : unit =
184-
let all = Db.Host.get_record_internal ~__context ~self in
185-
let valid = valid_operations ~__context all self in
186-
let keys =
187-
Hashtbl.fold (fun k v acc -> if v = None then k :: acc else acc) valid []
188-
in
189-
(* CA-18377: If there's a rolling upgrade in progress, only send Miami keys across the wire. *)
190-
let keys =
191-
if Helpers.rolling_upgrade_in_progress ~__context then
192-
Xapi_stdext_std.Listext.List.intersect keys
193-
Xapi_globs.host_operations_miami
194-
else
195-
keys
196-
in
197-
Db.Host.set_allowed_operations ~__context ~self ~value:keys
184+
try
185+
(* This might fail if the coordinator has been updated *)
186+
let all = Db.Host.get_record_internal ~__context ~self in
187+
let valid = valid_operations ~__context all self in
188+
let keys =
189+
Hashtbl.fold (fun k v acc -> if v = None then k :: acc else acc) valid []
190+
in
191+
(* CA-18377: If there's a rolling upgrade in progress, only send Miami keys across the wire. *)
192+
let keys =
193+
if Helpers.rolling_upgrade_in_progress ~__context then
194+
Xapi_stdext_std.Listext.List.intersect keys
195+
Xapi_globs.host_operations_miami
196+
else
197+
keys
198+
in
199+
Db.Host.set_allowed_operations ~__context ~self ~value:keys
200+
with e ->
201+
error "Failed to update host.allowed_operations: %s" (Printexc.to_string e)
198202

199203
let update_allowed_operations_all_hosts ~__context : unit =
200204
let hosts = Db.Host.get_all ~__context in

0 commit comments

Comments
 (0)