Skip to content

Commit c8387b0

Browse files
committed
[AD] Execute the directory service config recipe during the update only on the head node.
Signed-off-by: Giacomo Marciani <[email protected]>
1 parent 214d623 commit c8387b0

File tree

4 files changed

+142
-3
lines changed

4 files changed

+142
-3
lines changed

cookbooks/aws-parallelcluster-entrypoints/recipes/update.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
# Fetch and load cluster configs
1616
include_recipe 'aws-parallelcluster-platform::update'
1717

18-
# generate the updated shared storages mapping file
19-
include_recipe 'aws-parallelcluster-environment::update_fs_mapping'
18+
include_recipe 'aws-parallelcluster-environment::update'
2019

21-
include_recipe 'aws-parallelcluster-environment::directory_service'
2220
include_recipe 'aws-parallelcluster-slurm::update' if node['cluster']['scheduler'] == 'slurm'
2321

2422
# Update node package - useful for development purposes only
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright:: 2024 Amazon.com, Inc. and its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the
6+
# License. A copy of the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0/
9+
#
10+
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
11+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
require 'spec_helper'
15+
16+
describe 'aws-parallelcluster-entrypoints::update' do
17+
before do
18+
@included_recipes = []
19+
%w(
20+
aws-parallelcluster-platform::update
21+
aws-parallelcluster-environment::update
22+
aws-parallelcluster-slurm::update
23+
aws-parallelcluster-computefleet::update_parallelcluster_node
24+
).each do |recipe_name|
25+
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).with(recipe_name) do
26+
@included_recipes << recipe_name
27+
end
28+
end
29+
end
30+
31+
for_all_oses do |platform, version|
32+
context "on #{platform}#{version}" do
33+
for_all_node_types do |node_type|
34+
context "when #{node_type}" do
35+
[true, false].each do |is_custom_node|
36+
context "and does #{'not ' unless is_custom_node}use a custom node package" do
37+
cached(:chef_run) do
38+
runner = runner(platform: platform, version: version) do |node|
39+
allow_any_instance_of(Object).to receive(:fetch_config).and_return(OpenStruct.new)
40+
41+
node.override['cluster']['node_type'] = node_type
42+
node.override['cluster']['scheduler'] = 'slurm'
43+
node.override['cluster']['custom_node_package'] = "CUSTOM_NODE_PACKAGE" if is_custom_node
44+
end
45+
runner.converge(described_recipe)
46+
end
47+
cached(:node) { chef_run.node }
48+
49+
expected_recipes = %w(
50+
aws-parallelcluster-platform::update
51+
aws-parallelcluster-environment::update
52+
aws-parallelcluster-slurm::update
53+
)
54+
55+
if is_custom_node
56+
expected_recipes = expected_recipes.append("aws-parallelcluster-computefleet::update_parallelcluster_node")
57+
end
58+
59+
it "includes the recipes in the right order" do
60+
chef_run
61+
expect(@included_recipes).to eq(expected_recipes)
62+
end
63+
end
64+
end
65+
end
66+
end
67+
end
68+
end
69+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright:: 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the
6+
# License. A copy of the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0/
9+
#
10+
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
11+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# generate the updated shared storages mapping file
15+
include_recipe "aws-parallelcluster-environment::update_fs_mapping"
16+
17+
include_recipe "aws-parallelcluster-environment::directory_service" if node["cluster"]["node_type"] == "HeadNode"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright:: 2024 Amazon.com, Inc. and its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the
6+
# License. A copy of the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0/
9+
#
10+
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
11+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
require 'spec_helper'
15+
16+
describe 'aws-parallelcluster-environment::update' do
17+
before do
18+
@included_recipes = []
19+
%w(
20+
aws-parallelcluster-environment::update_fs_mapping
21+
aws-parallelcluster-environment::directory_service
22+
).each do |recipe_name|
23+
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).with(recipe_name) do
24+
@included_recipes << recipe_name
25+
end
26+
end
27+
end
28+
29+
for_all_oses do |platform, version|
30+
context "on #{platform}#{version}" do
31+
for_all_node_types do |node_type|
32+
context "when #{node_type}" do
33+
cached(:chef_run) do
34+
runner = runner(platform: platform, version: version) do |node|
35+
node.override['cluster']['node_type'] = node_type
36+
end
37+
runner.converge(described_recipe)
38+
end
39+
cached(:node) { chef_run.node }
40+
41+
expected_recipes = %w(aws-parallelcluster-environment::update_fs_mapping)
42+
43+
if node_type == "HeadNode"
44+
expected_recipes = expected_recipes.append("aws-parallelcluster-environment::directory_service")
45+
end
46+
47+
it "includes the recipes in the right order" do
48+
chef_run
49+
expect(@included_recipes).to eq(expected_recipes)
50+
end
51+
end
52+
end
53+
end
54+
end
55+
end

0 commit comments

Comments
 (0)