Skip to content

Commit efaf3f0

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 13cff9f commit efaf3f0

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
@@ -172,9 +172,13 @@ let of_originator originator =
172172
originator |> Group.Creator.make |> Cgroup.set_cgroup
173173

174174
let of_req_originator originator =
175-
try
176-
originator
177-
|> Option.value ~default:Group.Originator.(to_string EXTERNAL)
178-
|> Group.Originator.of_string
179-
|> of_originator
180-
with _ -> ()
175+
Option.iter
176+
(fun _ ->
177+
try
178+
originator
179+
|> Option.value ~default:Group.Originator.(to_string EXTERNAL)
180+
|> Group.Originator.of_string
181+
|> of_originator
182+
with _ -> ()
183+
)
184+
(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
@@ -1059,6 +1059,8 @@ let disable_webserver = ref false
10591059

10601060
let test_open = ref 0
10611061

1062+
let tgroups_enabled = ref false
1063+
10621064
let xapi_requests_cgroup =
10631065
"/sys/fs/cgroup/cpu/control.slice/xapi.service/request"
10641066

@@ -1624,6 +1626,11 @@ let other_options =
16241626
, (fun () -> string_of_bool !disable_webserver)
16251627
, "Disable the host webserver"
16261628
)
1629+
; ( "tgroups-enabled"
1630+
, Arg.Set tgroups_enabled
1631+
, (fun () -> string_of_bool !tgroups_enabled)
1632+
, "Turn on tgroups classification"
1633+
)
16271634
]
16281635

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

0 commit comments

Comments
 (0)