From 6267957422cf1ea8268d24609cdc716e77edf958 Mon Sep 17 00:00:00 2001 From: Helena Greebe Date: Tue, 9 Sep 2025 09:55:42 -0400 Subject: [PATCH] Check if using cgroupsv2 --- .../test/controls/slurm_config_spec.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cookbooks/aws-parallelcluster-slurm/test/controls/slurm_config_spec.rb b/cookbooks/aws-parallelcluster-slurm/test/controls/slurm_config_spec.rb index 963151277..43ed30203 100644 --- a/cookbooks/aws-parallelcluster-slurm/test/controls/slurm_config_spec.rb +++ b/cookbooks/aws-parallelcluster-slurm/test/controls/slurm_config_spec.rb @@ -46,8 +46,21 @@ end describe 'check cgroup memory resource controller is enabled' do - subject { bash("sleep 5 && grep memory /proc/cgroups | awk '{print $4}'") } - its('exit_status') { should eq 0 } - its('stdout.strip') { should cmp 1 } + # Check if we're using cgroups v2 + cgroup_v2 = bash('test -f /sys/fs/cgroup/cgroup.controllers').exit_status == 0 + + if cgroup_v2 + # For cgroups v2, check if memory controller is in available controllers + describe bash('cat /sys/fs/cgroup/cgroup.controllers') do + its('stdout') { should include 'memory' } + its('exit_status') { should eq 0 } + end + else + # Original check for cgroups v1 + describe bash("grep memory /proc/cgroups | awk '{print $4}'") do + its('stdout.strip') { should cmp '1' } + its('exit_status') { should eq 0 } + end + end end end