Skip to content

Commit e4fee1f

Browse files
himani2411Himani Deshpande
andauthored
[Disable Sudo] Invoking sudo_access from platform cookbook when we update the Nodes. (#2646)
Co-authored-by: Himani Deshpande <[email protected]>
1 parent 7a37905 commit e4fee1f

File tree

3 files changed

+78
-5
lines changed

3 files changed

+78
-5
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
fetch_config 'Fetch and load cluster configs' do
16-
update true
17-
end
15+
# Fetch and load cluster configs
16+
include_recipe 'aws-parallelcluster-platform::update'
1817

1918
# generate the updated shared storages mapping file
2019
include_recipe 'aws-parallelcluster-environment::update_fs_mapping'
@@ -26,5 +25,3 @@
2625
if is_custom_node?
2726
include_recipe 'aws-parallelcluster-computefleet::update_parallelcluster_node'
2827
end
29-
30-
sudo_access "Update Sudo Access" if node['cluster']['scheduler'] == 'slurm'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Cookbook:: aws-parallelcluster-platform
5+
# Recipe:: update
6+
#
7+
# Copyright:: 2013-2024 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+
fetch_config 'Fetch and load cluster configs' do
19+
update true
20+
end
21+
22+
sudo_access "Update Sudo Access" if node['cluster']['scheduler'] == 'slurm'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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-platform::update' do
17+
for_all_oses do |platform, version|
18+
context "on #{platform}#{version}" do
19+
context "when scheduler is slurm" do
20+
cached(:chef_run) do
21+
runner = runner(platform: platform, version: version) do |node|
22+
node.override['cluster']['scheduler'] = 'slurm'
23+
end
24+
runner.converge(described_recipe)
25+
end
26+
cached(:node) { chef_run.node }
27+
28+
it 'it fetches and updates cluster configs' do
29+
is_expected.to run_fetch_config('Fetch and load cluster configs')
30+
end
31+
it 'it updates sudo access' do
32+
is_expected.to setup_sudo_access('Update Sudo Access')
33+
end
34+
end
35+
36+
context "when scheduler is awsbatch" do
37+
cached(:chef_run) do
38+
runner = runner(platform: platform, version: version) do |node|
39+
node.override['cluster']['scheduler'] = 'awsbatch'
40+
end
41+
runner.converge(described_recipe)
42+
end
43+
cached(:node) { chef_run.node }
44+
45+
it 'it fetches and updates cluster configs' do
46+
is_expected.to run_fetch_config('Fetch and load cluster configs')
47+
end
48+
it 'it doesnt update sudo access' do
49+
is_expected.not_to setup_sudo_access('Update Sudo Access')
50+
end
51+
end
52+
end
53+
end
54+
end

0 commit comments

Comments
 (0)