@@ -294,6 +294,14 @@ export class ProcessSpawner {
294294 // Ensure team-specific cache directory exists before mounting
295295 const cacheDir = await this . ensureCacheDirectory ( config . team_id , runtime ) ;
296296
297+ // Log cgroup version for diagnostics
298+ const cgroupVersion = existsSync ( '/sys/fs/cgroup/cgroup.controllers' ) ? 'v2' : 'v1' ;
299+ this . logger . info ( {
300+ operation : 'cgroup_version_detected' ,
301+ version : cgroupVersion ,
302+ team_id : config . team_id
303+ } , `Detected cgroup ${ cgroupVersion } ` ) ;
304+
297305 this . logger . info ( {
298306 operation : 'spawn_nsjail' ,
299307 installation_name : config . installation_name ,
@@ -330,7 +338,9 @@ export class ProcessSpawner {
330338 '--rlimit_nofile' , String ( nsjailConfig . maxOpenFiles ) , // Max file descriptors
331339 '--rlimit_fsize' , String ( nsjailConfig . maxFileSizeMB ) , // Max file size (MB)
332340 '--time_limit' , '0' , // No wall-clock time limit
333- // Cgroup limits for precise resource control
341+ // Cgroup v2 limits for precise resource control
342+ '--use_cgroupv2' ,
343+ '--cgroupv2_mount' , '/sys/fs/cgroup' ,
334344 '--cgroup_mem_max' , String ( nsjailConfig . cgroupMemMaxBytes ) , // Physical memory limit (512MB)
335345 '--cgroup_pids_max' , String ( nsjailConfig . cgroupPidsMax ) , // Process limit (1000)
336346 '-R' , '/usr' , // Read-only mount: /usr
@@ -474,7 +484,9 @@ export class ProcessSpawner {
474484 '--rlimit_nofile' , String ( nsjailConfig . maxOpenFiles ) ,
475485 '--rlimit_fsize' , String ( nsjailConfig . maxFileSizeMB ) ,
476486 '--time_limit' , String ( timeoutSeconds ) ,
477- // Cgroup limits
487+ // Cgroup v2 limits
488+ '--use_cgroupv2' ,
489+ '--cgroupv2_mount' , '/sys/fs/cgroup' ,
478490 '--cgroup_mem_max' , String ( nsjailConfig . cgroupMemMaxBytes ) ,
479491 '--cgroup_pids_max' , String ( nsjailConfig . cgroupPidsMax ) ,
480492 // Read-only system mounts
0 commit comments