Skip to content

Commit f00c755

Browse files
Force update_shared_storages to pass the string true for _mount_unmount in the efs resource
Updates to a cluster result in boolean values for the iam_authorization and efs_encryption_in_transit variables when the mapping yaml file is loaded. Need to force strings to be consistent with the dna.json pattern.
1 parent 7d414fe commit f00c755

File tree

3 files changed

+109
-2
lines changed

3 files changed

+109
-2
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ aws-parallelcluster-cookbook CHANGELOG
33

44
This file is used to list changes made in each version of the AWS ParallelCluster cookbook.
55

6+
3.10.0
7+
------
8+
9+
**ENHANCEMENTS**
10+
11+
**CHANGES**
12+
13+
**BUG FIXES**
14+
- Fixed an issue that prevented cluster updates from including EFS filesystems with encryption in transit.
15+
616
3.9.0
717
------
818

cookbooks/aws-parallelcluster-environment/recipes/config/update_shared_storages.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,17 @@ def get_efs(action)
8383
next unless not_in_shared_storages_mapping["efs"].nil? || !not_in_shared_storages_mapping["efs"].include?(storage)
8484
shared_dir_array.push(storage["mount_dir"])
8585
efs_fs_id_array.push(storage["efs_fs_id"])
86-
efs_encryption_in_transit_array.push(storage["efs_encryption_in_transit"])
87-
efs_iam_authorization_array.push(storage["efs_iam_authorization"])
86+
# The EFS resource expects strings for these attributes, not booleans
87+
if storage["efs_encryption_in_transit"]
88+
efs_encryption_in_transit_array.push("true")
89+
else
90+
efs_encryption_in_transit_array.push("false")
91+
end
92+
if storage["efs_iam_authorization"]
93+
efs_iam_authorization_array.push("true")
94+
else
95+
efs_iam_authorization_array.push("false")
96+
end
8897
end
8998
end
9099
[shared_dir_array, efs_fs_id_array, efs_encryption_in_transit_array, efs_iam_authorization_array]

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

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,94 @@ def mock_already_installed(package, expected_version, installed)
335335
end
336336
end
337337

338+
describe 'efs:mount_bool' do
339+
for_all_oses do |platform, version|
340+
%w(HeadNode ComputeFleet).each do |node_type|
341+
context "on #{platform}#{version} and node type #{node_type}" do
342+
cached(:chef_run) do
343+
runner = runner(platform: platform, version: version, step_into: ['efs']) do |node|
344+
node.override['cluster']['region'] = "REGION"
345+
node.override['cluster']['aws_domain'] = "DOMAIN"
346+
node.override['cluster']['node_type'] = node_type
347+
end
348+
runner.converge_dsl do
349+
efs 'mount' do
350+
efs_fs_id_array %w(id_1 id_2 id_3)
351+
shared_dir_array %w(shared_dir_1 /shared_dir_2 /shared_dir_3)
352+
efs_encryption_in_transit_array [true, true, false]
353+
efs_iam_authorization_array [false, true, true]
354+
action :mount
355+
end
356+
end
357+
end
358+
359+
before do
360+
stub_command("mount | grep ' /shared_dir_1 '").and_return(false)
361+
stub_command("mount | grep ' /shared_dir_2 '").and_return(true)
362+
stub_command("mount | grep ' /shared_dir_3 '").and_return(true)
363+
end
364+
365+
it 'mounts efs' do
366+
is_expected.to mount_efs('mount')
367+
end
368+
369+
it 'creates shared directory' do
370+
%w(/shared_dir_1 /shared_dir_2 /shared_dir_3).each do |shared_dir|
371+
is_expected.to create_directory(shared_dir)
372+
.with(owner: 'root')
373+
.with(group: 'root')
374+
.with(mode: '1777')
375+
# .with(recursive: true) # even if we set recursive a true, the test fails
376+
end
377+
end
378+
379+
it 'mounts shared dir if not already mounted' do
380+
is_expected.to mount_mount('/shared_dir_1')
381+
.with(device: 'id_1:/')
382+
.with(fstype: 'efs')
383+
.with(dump: 0)
384+
.with(pass: 0)
385+
.with(options: %w(_netdev noresvport tls))
386+
.with(retries: 10)
387+
.with(retry_delay: 60)
388+
end
389+
390+
it 'enables shared dir mount if already mounted' do
391+
is_expected.to enable_mount('/shared_dir_2')
392+
.with(device: 'id_2:/')
393+
.with(fstype: 'efs')
394+
.with(dump: 0)
395+
.with(pass: 0)
396+
.with(options: %w(_netdev noresvport tls iam))
397+
.with(retries: 10)
398+
.with(retry_delay: 6)
399+
400+
is_expected.to enable_mount('/shared_dir_3')
401+
.with(device: 'id_3:/')
402+
.with(fstype: 'efs')
403+
.with(dump: 0)
404+
.with(pass: 0)
405+
.with(options: %w(_netdev noresvport))
406+
.with(retries: 10)
407+
.with(retry_delay: 6)
408+
end
409+
410+
if node_type == "HeadNode"
411+
it 'changes permissions' do
412+
%w(/shared_dir_1 /shared_dir_2 /shared_dir_3).each do |shared_dir|
413+
is_expected.to create_directory("change permissions for #{shared_dir}")
414+
.with(path: shared_dir)
415+
.with(owner: 'root')
416+
.with(group: 'root')
417+
.with(mode: '1777')
418+
end
419+
end
420+
end
421+
end
422+
end
423+
end
424+
end
425+
338426
describe 'efs:unmount' do
339427
for_all_oses do |platform, version|
340428
context "on #{platform}#{version}" do

0 commit comments

Comments
 (0)