Skip to content

Commit cd73bd9

Browse files
committed
Move gc_threshold configuration into a new recipe and add tests
Moved attributes and usage into aws-parallelcluster-install recipe Signed-off-by: Enrico Usai <[email protected]>
1 parent 289c3b6 commit cd73bd9

File tree

7 files changed

+67
-18
lines changed

7 files changed

+67
-18
lines changed

attributes/default.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,6 @@
421421
}
422422
)
423423

424-
# Default gc_thresh values for performance at scale
425-
default['cluster']['sysctl']['ipv4']['gc_thresh1'] = 0
426-
default['cluster']['sysctl']['ipv4']['gc_thresh2'] = 15_360
427-
default['cluster']['sysctl']['ipv4']['gc_thresh3'] = 16_384
428-
429424
# ParallelCluster internal variables (also in /etc/parallelcluster/cfnconfig)
430425
default['cluster']['region'] = 'us-east-1'
431426
default['cluster']['stack_name'] = nil
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
# aws-parallelcluster-install attributes
2+
3+
# Default gc_thresh values for performance at scale
4+
default['cluster']['sysctl']['ipv4']['gc_thresh1'] = 0
5+
default['cluster']['sysctl']['ipv4']['gc_thresh2'] = 15_360
6+
default['cluster']['sysctl']['ipv4']['gc_thresh3'] = 16_384

cookbooks/aws-parallelcluster-install/recipes/base.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
include_recipe "aws-parallelcluster-install::ephemeral_drives"
5353
ec2_udev_rules 'configure udev'
5454

55-
# Configure gc_thresh values to be consistent with alinux2 default values for performance at scale
56-
configure_gc_thresh_values
55+
include_recipe "aws-parallelcluster-install::gc_thresh_values"
5756

5857
include_recipe "aws-parallelcluster-install::supervisord"
5958

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Cookbook:: aws-parallelcluster-install
5+
# Recipe:: gc_thresh_values
6+
#
7+
# Copyright:: 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the
10+
# License. A copy of the License is located at
11+
#
12+
# http://aws.amazon.com/apache2.0/
13+
#
14+
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
15+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
# Configure gc_thresh values to be consistent with alinux2 default values for performance at scale
19+
20+
def configure_gc_thresh_values
21+
(1..3).each do |i|
22+
sysctl "net.ipv4.neigh.default.gc_thresh#{i}" do
23+
value node['cluster']['sysctl']['ipv4']["gc_thresh#{i}"]
24+
action :apply
25+
end unless virtualized?
26+
end
27+
end
28+
29+
configure_gc_thresh_values

kitchen.recipes.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,9 @@ suites:
135135
verifier:
136136
controls:
137137
- openssh_installed
138-
138+
- name: gc_thresh_values
139+
run_list:
140+
- recipe[aws-parallelcluster-install::gc_thresh_values]
141+
verifier:
142+
controls:
143+
- gc_thresh_values_configured

libraries/helpers.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,16 +477,6 @@ def get_metadata_with_token(token, uri)
477477
metadata
478478
end
479479

480-
def configure_gc_thresh_values
481-
(1..3).each do |i|
482-
# Configure gc_thresh values to be consistent with alinux2 default values
483-
sysctl "net.ipv4.neigh.default.gc_thresh#{i}" do
484-
value node['cluster']['sysctl']['ipv4']["gc_thresh#{i}"]
485-
action :apply
486-
end
487-
end
488-
end
489-
490480
def get_system_users
491481
cmd = Mixlib::ShellOut.new("cat /etc/passwd | cut -d: -f1")
492482
cmd.run_command
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright:: 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License").
4+
# You may not use this file except in compliance with the License. A copy of the License is located at
5+
#
6+
# http://aws.amazon.com/apache2.0/
7+
#
8+
# or in the "LICENSE.txt" file accompanying this file.
9+
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
10+
# See the License for the specific language governing permissions and limitations under the License.
11+
12+
control 'gc_thresh_values_configured' do
13+
title 'Verify gc_thresh values are configured in the kernel settings'
14+
15+
only_if { !os_properties.virtualized? }
16+
17+
# We cannot access node attributes in the inspec tests
18+
@thresh_numbers = [ 1, 2, 3 ]
19+
@thresh_values = [ 0, 15_360, 16_384 ]
20+
21+
@thresh_numbers.zip(@thresh_values).each do |thresh_number, thresh_value|
22+
describe kernel_parameter("net.ipv4.neigh.default.gc_thresh#{thresh_number}") do
23+
its('value') { should eq thresh_value }
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)