Skip to content

Commit 6267957

Browse files
committed
Check if using cgroupsv2
1 parent 921f2d8 commit 6267957

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

cookbooks/aws-parallelcluster-slurm/test/controls/slurm_config_spec.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,21 @@
4646
end
4747

4848
describe 'check cgroup memory resource controller is enabled' do
49-
subject { bash("sleep 5 && grep memory /proc/cgroups | awk '{print $4}'") }
50-
its('exit_status') { should eq 0 }
51-
its('stdout.strip') { should cmp 1 }
49+
# Check if we're using cgroups v2
50+
cgroup_v2 = bash('test -f /sys/fs/cgroup/cgroup.controllers').exit_status == 0
51+
52+
if cgroup_v2
53+
# For cgroups v2, check if memory controller is in available controllers
54+
describe bash('cat /sys/fs/cgroup/cgroup.controllers') do
55+
its('stdout') { should include 'memory' }
56+
its('exit_status') { should eq 0 }
57+
end
58+
else
59+
# Original check for cgroups v1
60+
describe bash("grep memory /proc/cgroups | awk '{print $4}'") do
61+
its('stdout.strip') { should cmp '1' }
62+
its('exit_status') { should eq 0 }
63+
end
64+
end
5265
end
5366
end

0 commit comments

Comments
 (0)