Skip to content

Commit 2eb768f

Browse files
Avoid change permission of shared FS on Compute nodes
Signed-off-by: Francesco Giordano <[email protected]>
1 parent 7db2af0 commit 2eb768f

File tree

5 files changed

+290
-262
lines changed

5 files changed

+290
-262
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This file is used to list changes made in each version of the AWS ParallelCluste
4646
- xdcv: `2023.0.547-1`
4747
- gl: `2023.0.1027-1`
4848
- web_viewer: `2023.0.15022-1`
49+
- Avoid to reset FSx and EFS shared folders permissions when mounting them in the compute nodes.
4950

5051
**BUG FIXES**
5152
- Fix an issue that was causing misalignment of compute nodes IP on instances with multiple network interfaces.

cookbooks/aws-parallelcluster-common/resources/efs/partial/_mount_umount.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
owner 'root'
8282
group 'root'
8383
mode '1777'
84+
only_if { node['cluster']['node_type'] == "HeadNode" }
8485
end
8586
end
8687
end

cookbooks/aws-parallelcluster-common/resources/lustre/partial/_mount_unmount.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
owner 'root'
6262
group 'root'
6363
mode '1777'
64-
only_if { fsx.can_change_shared_dir_permissions }
64+
only_if { fsx.can_change_shared_dir_permissions && node['cluster']['node_type'] == "HeadNode" }
6565
end
6666
end
6767
end

cookbooks/aws-parallelcluster-common/spec/unit/resources/efs_spec.rb

Lines changed: 71 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -253,80 +253,85 @@ def mock_already_installed(package, expected_version, installed)
253253

254254
describe 'efs:mount' do
255255
for_all_oses do |platform, version|
256-
context "on #{platform}#{version}" do
257-
cached(:chef_run) do
258-
runner = ChefSpec::Runner.new(
259-
platform: platform, version: version,
260-
step_into: ['efs']
261-
) do |node|
262-
node.override['cluster']['region'] = "REGION"
263-
node.override['cluster']['aws_domain'] = "DOMAIN"
264-
end
265-
runner.converge_dsl do
266-
efs 'mount' do
267-
efs_fs_id_array %w(id_1 id_2 id_3)
268-
shared_dir_array %w(shared_dir_1 /shared_dir_2 /shared_dir_3)
269-
efs_encryption_in_transit_array %w(true true not_true)
270-
efs_iam_authorization_array %w(not_true true true)
271-
action :mount
256+
%w(HeadNode ComputeFleet).each do |node_type|
257+
context "on #{platform}#{version} and node type #{node_type}" do
258+
cached(:chef_run) do
259+
runner = ChefSpec::Runner.new(
260+
platform: platform, version: version,
261+
step_into: ['efs']
262+
) do |node|
263+
node.override['cluster']['region'] = "REGION"
264+
node.override['cluster']['aws_domain'] = "DOMAIN"
265+
node.override['cluster']['node_type'] = node_type
266+
end
267+
runner.converge_dsl do
268+
efs 'mount' do
269+
efs_fs_id_array %w(id_1 id_2 id_3)
270+
shared_dir_array %w(shared_dir_1 /shared_dir_2 /shared_dir_3)
271+
efs_encryption_in_transit_array %w(true true not_true)
272+
efs_iam_authorization_array %w(not_true true true)
273+
action :mount
274+
end
272275
end
273276
end
274-
end
275277

276-
before do
277-
stub_command("mount | grep ' /shared_dir_1 '").and_return(false)
278-
stub_command("mount | grep ' /shared_dir_2 '").and_return(true)
279-
stub_command("mount | grep ' /shared_dir_3 '").and_return(true)
280-
end
281-
282-
it 'creates shared directory' do
283-
%w(/shared_dir_1 /shared_dir_2 /shared_dir_3).each do |shared_dir|
284-
is_expected.to create_directory(shared_dir)
285-
.with(owner: 'root')
286-
.with(group: 'root')
287-
.with(mode: '1777')
288-
# .with(recursive: true) # even if we set recursive a true, the test fails
278+
before do
279+
stub_command("mount | grep ' /shared_dir_1 '").and_return(false)
280+
stub_command("mount | grep ' /shared_dir_2 '").and_return(true)
281+
stub_command("mount | grep ' /shared_dir_3 '").and_return(true)
289282
end
290-
end
291283

292-
it 'mounts shared dir if not already mounted' do
293-
is_expected.to mount_mount('/shared_dir_1')
294-
.with(device: 'id_1:/')
295-
.with(fstype: 'efs')
296-
.with(dump: 0)
297-
.with(pass: 0)
298-
.with(options: %w(_netdev noresvport tls))
299-
.with(retries: 10)
300-
.with(retry_delay: 60)
301-
end
284+
it 'creates shared directory' do
285+
%w(/shared_dir_1 /shared_dir_2 /shared_dir_3).each do |shared_dir|
286+
is_expected.to create_directory(shared_dir)
287+
.with(owner: 'root')
288+
.with(group: 'root')
289+
.with(mode: '1777')
290+
# .with(recursive: true) # even if we set recursive a true, the test fails
291+
end
292+
end
302293

303-
it 'enables shared dir mount if already mounted' do
304-
is_expected.to enable_mount('/shared_dir_2')
305-
.with(device: 'id_2.efs.REGION.DOMAIN:/')
306-
.with(fstype: 'efs')
307-
.with(dump: 0)
308-
.with(pass: 0)
309-
.with(options: %w(_netdev noresvport tls iam))
310-
.with(retries: 10)
311-
.with(retry_delay: 6)
294+
it 'mounts shared dir if not already mounted' do
295+
is_expected.to mount_mount('/shared_dir_1')
296+
.with(device: 'id_1:/')
297+
.with(fstype: 'efs')
298+
.with(dump: 0)
299+
.with(pass: 0)
300+
.with(options: %w(_netdev noresvport tls))
301+
.with(retries: 10)
302+
.with(retry_delay: 60)
303+
end
312304

313-
is_expected.to enable_mount('/shared_dir_3')
314-
.with(device: 'id_3.efs.REGION.DOMAIN:/')
315-
.with(fstype: 'efs')
316-
.with(dump: 0)
317-
.with(pass: 0)
318-
.with(options: %w(_netdev noresvport))
319-
.with(retries: 10)
320-
.with(retry_delay: 6)
321-
end
305+
it 'enables shared dir mount if already mounted' do
306+
is_expected.to enable_mount('/shared_dir_2')
307+
.with(device: 'id_2.efs.REGION.DOMAIN:/')
308+
.with(fstype: 'efs')
309+
.with(dump: 0)
310+
.with(pass: 0)
311+
.with(options: %w(_netdev noresvport tls iam))
312+
.with(retries: 10)
313+
.with(retry_delay: 6)
314+
315+
is_expected.to enable_mount('/shared_dir_3')
316+
.with(device: 'id_3.efs.REGION.DOMAIN:/')
317+
.with(fstype: 'efs')
318+
.with(dump: 0)
319+
.with(pass: 0)
320+
.with(options: %w(_netdev noresvport))
321+
.with(retries: 10)
322+
.with(retry_delay: 6)
323+
end
322324

323-
it 'changes permissions' do
324-
%w(/shared_dir_1 /shared_dir_2 /shared_dir_3).each do |shared_dir|
325-
is_expected.to create_directory("change permissions for #{shared_dir}")
326-
.with(path: shared_dir)
327-
.with(owner: 'root')
328-
.with(group: 'root')
329-
.with(mode: '1777')
325+
if node_type == "HeadNode"
326+
it 'changes permissions' do
327+
%w(/shared_dir_1 /shared_dir_2 /shared_dir_3).each do |shared_dir|
328+
is_expected.to create_directory("change permissions for #{shared_dir}")
329+
.with(path: shared_dir)
330+
.with(owner: 'root')
331+
.with(group: 'root')
332+
.with(mode: '1777')
333+
end
334+
end
330335
end
331336
end
332337
end

0 commit comments

Comments
 (0)