Skip to content

Commit

Permalink
CP-48676: Don't check resuable pool session validity by default
Browse files Browse the repository at this point in the history
Add a new flag validate-reusable-pool-session to xapi globs which skips
the reusable pool session validity check if it is false. This saves time
as we are no longer calling pool.get_all for each session.

Signed-off-by: Steven Woods <[email protected]>
  • Loading branch information
snwoods committed Jan 28, 2025
1 parent bee1849 commit f17fb1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,8 @@ let disable_webserver = ref false

let reuse_pool_sessions = ref true

let validate_reusable_pool_session = ref false

let test_open = ref 0

let xapi_globs_spec =
Expand Down Expand Up @@ -1638,6 +1640,11 @@ let other_options =
, (fun () -> string_of_bool !reuse_pool_sessions)
, "Enable the reuse of pool sessions"
)
; ( "validate-reusable-pool-session"
, Arg.Set validate_reusable_pool_session
, (fun () -> string_of_bool !validate_reusable_pool_session)
, "Enable the reuse of pool sessions"
)
]

(* The options can be set with the variable xapiflags in /etc/sysconfig/xapi.
Expand Down
7 changes: 6 additions & 1 deletion ocaml/xapi/xapi_session.ml
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,12 @@ let login_no_password_common ~__context ~uname ~originator ~host ~pool
in
let rec get_session () =
let session = Atomic.get reusable_pool_session in
if session <> Ref.null && is_valid_session session then (
if
session <> Ref.null
&& ((not !Xapi_globs.validate_reusable_pool_session)
|| is_valid_session session
)
then (
(* Check if the session changed during validation.
Use our version regardless to avoid being stuck in a loop of session creation *)
if Atomic.get reusable_pool_session <> session then
Expand Down

0 comments on commit f17fb1b

Please sign in to comment.