Skip to content

Commit

Permalink
CA-405971: avoid calling DB functions when in emergency mode (#6283)
Browse files Browse the repository at this point in the history
This breaks emergency mode commands.
  • Loading branch information
edwintorok authored Feb 7, 2025
2 parents 71f64c8 + 405bcb5 commit e67b9fc
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions ocaml/xapi/server_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,29 @@ let do_dispatch ?session_id ?forward_op ?self:_ supports_async called_fn_name
Context.of_http_req ?session_id ~internal_async_subtask ~generate_task_for
~supports_async ~label ~http_req ~fd ()
in
let identity =
try
Option.map
(fun session_id ->
let subject =
Db.Session.get_auth_user_sid ~__context ~self:session_id
in
Tgroup.Group.Identity.make ?user_agent:http_req.user_agent subject
)
session_id
with _ -> None
in
Tgroup.of_creator (Tgroup.Group.Creator.make ?identity ()) ;
( if !Xapi_globs.tgroups_enabled then
let identity =
try
Option.map
(fun session_id ->
let subject =
Db.Session.get_auth_user_sid ~__context ~self:session_id
in
Tgroup.Group.Identity.make ?user_agent:http_req.user_agent
subject
)
( if !Xapi_globs.slave_emergency_mode then
(* in emergency mode we cannot reach the coordinator,
and we must not attempt to make Db calls
*)
None
else
session_id
)
with _ -> None
in
Tgroup.of_creator (Tgroup.Group.Creator.make ?identity ())
) ;
let sync () =
let need_complete = not (Context.forwarded_task __context) in
exec_with_context ~__context ~need_complete ~called_async
Expand Down

0 comments on commit e67b9fc

Please sign in to comment.