Skip to content

Commit a831ee4

Browse files
committed
CP-50537: Add a guard in xapi_globs, Xapi_globs.tgroups_enabled.
Adds a configurable variable in `xapi_globs`, `tgroups_enabled` that is meant to ask a guard for tgroup classification of the threads. If the guard is `false` all Tgroups functionality should act as a no op. For instance, adding the line: tgroups-enabled = false will result in the thread classification being skipped. Signed-off-by: Gabriel Buica <[email protected]>
1 parent 869838d commit a831ee4

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

ocaml/libs/http-lib/http_svr.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,9 @@ let handle_connection ~header_read_timeout ~header_total_timeout
560560
read_request ?proxy_seen ~read_timeout ~total_timeout
561561
~max_length:max_header_length ss
562562
in
563+
563564
Http.Request.with_originator_of req Tgroup.of_req_originator ;
565+
564566
(* 2. now we attempt to process the request *)
565567
let finished =
566568
Option.fold ~none:true

ocaml/libs/tgroup/tgroup.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,13 @@ let of_originator originator =
174174
originator |> Group.Creator.make |> Cgroup.set_cgroup
175175

176176
let of_req_originator originator =
177-
try
178-
originator
179-
|> Option.value ~default:Group.Originator.(to_string EXTERNAL)
180-
|> Group.Originator.of_string
181-
|> of_originator
182-
with _ -> ()
177+
Option.iter
178+
(fun _ ->
179+
try
180+
originator
181+
|> Option.value ~default:Group.Originator.(to_string EXTERNAL)
182+
|> Group.Originator.of_string
183+
|> of_originator
184+
with _ -> ()
185+
)
186+
(Atomic.get Cgroup.cgroup_dir)

ocaml/xapi/xapi.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,9 @@ let server_init () =
10601060
; ("Running startup check", [], startup_check)
10611061
; ( "Initialize cgroups via tgroup"
10621062
, []
1063-
, fun () -> Tgroup.Cgroup.init Xapi_globs.xapi_requests_cgroup
1063+
, fun () ->
1064+
if !Xapi_globs.tgroups_enabled then
1065+
Tgroup.Cgroup.init Xapi_globs.xapi_requests_cgroup
10641066
)
10651067
; ( "Registering SMAPIv1 plugins"
10661068
, [Startup.OnlyMaster]

ocaml/xapi/xapi_globs.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,8 @@ let disable_webserver = ref false
10551055

10561056
let test_open = ref 0
10571057

1058+
let tgroups_enabled = ref false
1059+
10581060
let xapi_requests_cgroup =
10591061
"/sys/fs/cgroup/cpu/control.slice/xapi.service/request"
10601062

@@ -1621,6 +1623,11 @@ let other_options =
16211623
, (fun () -> !Uuidx.make_default == Uuidx.make_uuid_fast |> string_of_bool)
16221624
, "Use PRNG based UUID generator instead of CSPRNG"
16231625
)
1626+
; ( "tgroups-enabled"
1627+
, Arg.Set tgroups_enabled
1628+
, (fun () -> string_of_bool !tgroups_enabled)
1629+
, "Turn on tgroups classification"
1630+
)
16241631
]
16251632

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

0 commit comments

Comments
 (0)