Skip to content

Commit

Permalink
CP-51352: Configurable threshold for updating last_active
Browse files Browse the repository at this point in the history
Follow up to the previous commit, this makes the hardcoded threshold of
10 mins configurable from `xapi.conf`.

This enables flexibilty in case  different values are needed for updating
the `last_active` field of a session more or less often.

Signed-off-by: Gabriel Buica <[email protected]>
  • Loading branch information
GabrielBuica committed Sep 10, 2024
1 parent 3ba6e6d commit 67df157
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ocaml/xapi/session_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ let check ~intra_pool_only ~session_id ~action =
Xapi_stdext_date.Date.to_ptime last_active
in
match
Ptime.add_span last_active_ptime (Ptime.Span.of_int_s 600)
Ptime.add_span last_active_ptime
!Xapi_globs.threshold_last_active
with
| None ->
let err_msg =
Expand Down
9 changes: 9 additions & 0 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,10 @@ let host_assumed_dead_interval = ref Mtime.Span.(10 * min)
(* If a session has a last_active older than this we delete it *)
let inactive_session_timeout = ref 86400. (* 24 hrs in seconds *)

(* If a session was refreshed more recently than threshold_last_active do not refresh it again. *)
let threshold_last_active = ref (Ptime.Span.of_int_s 600)
(* 10 min in seconds *)

let pending_task_timeout = ref 86400. (* 24 hrs in seconds *)

let completed_task_timeout = ref 3900. (* 65 mins *)
Expand Down Expand Up @@ -1631,6 +1635,11 @@ let other_options =
, (fun () -> string_of_int !external_authentication_cache_size)
, "Specify the maximum capacity of the external authentication cache"
)
; ( "threshold_last_active"
, Arg.Int (fun t -> threshold_last_active := Ptime.Span.of_int_s t)
, (fun () -> Format.asprintf "%a" Ptime.Span.pp !threshold_last_active)
, "Specify the threshold below which we do not refresh the session"
)
]

(* The options can be set with the variable xapiflags in /etc/sysconfig/xapi.
Expand Down

0 comments on commit 67df157

Please sign in to comment.