Skip to content

Commit 05738b2

Browse files
Support mounting existing FSx for Ontap and OpenZFS
Accept two more attributes to cookbook: fsx_volume_junction_paths: It is a comma separated list. There are strings between the comma if it is FSx for Ontap and OpenZFS. There is empty if it is FSx for Lustre. fsx_fs_types: It is a comma separated list. It tells the cookbook what mount method to use according to the file system (Lustre, Ontap, OpenZFS) Signed-off-by: Hanwen <[email protected]>
1 parent 82794e7 commit 05738b2

File tree

2 files changed

+58
-23
lines changed

2 files changed

+58
-23
lines changed

attributes/default.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@
518518
default['cluster']['fsx_fs_ids'] = ''
519519
default['cluster']['fsx_dns_names'] = ''
520520
default['cluster']['fsx_mount_names'] = ''
521+
default['cluster']['fsx_fs_types'] = ''
522+
default['cluster']['fsx_volume_junction_paths'] = ''
521523
default['cluster']['custom_node_package'] = nil
522524
default['cluster']['custom_awsbatchcli_package'] = nil
523525
default['cluster']['raid_shared_dir'] = ''

cookbooks/aws-parallelcluster-config/recipes/fsx_mount.rb

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,21 @@
1616
# limitations under the License.
1717

1818
fsx_fs_id_array = node['cluster']['fsx_fs_ids'].split(',')
19+
fsx_fs_type_array = node['cluster']['fsx_fs_types'].split(',')
1920
fsx_shared_dir_array = node['cluster']['fsx_shared_dirs'].split(',')
2021
fsx_dns_name_array = node['cluster']['fsx_dns_names'].split(',')
2122
fsx_mount_name_array = node['cluster']['fsx_mount_names'].split(',')
23+
fsx_volume_junction_path_array = node['cluster']['fsx_volume_junction_paths'].split(',')
2224
# Check to see if FSx is created
2325
fsx_fs_id_array.each_with_index do |fsx_fs_id, index|
2426
fsx_shared_dir = fsx_shared_dir_array[index]
2527
fsx_dns_name = fsx_dns_name_array[index]
28+
fsx_fs_type = fsx_fs_type_array[index]
29+
fsx_volume_junction_path = fsx_volume_junction_path_array[index]
30+
2631
# Path needs to be fully qualified, for example "shared/temp" becomes "/shared/temp"
2732
fsx_shared_dir = "/#{fsx_shared_dir}" unless fsx_shared_dir.start_with?('/')
33+
fsx_volume_junction_path = "/#{fsx_volume_junction_path}" unless fsx_volume_junction_path.nil? || fsx_volume_junction_path.start_with?('/')
2834

2935
# Create the shared directories
3036
directory fsx_shared_dir do
@@ -38,32 +44,59 @@
3844
dns_name = if fsx_dns_name && !fsx_dns_name.empty?
3945
fsx_dns_name
4046
else
41-
# Hardcoded DNSname only valid for filesystem created after Mar-1 2021
42-
# For older filesystems, DNSname needs to be retrieved from FSx API
47+
# Hardcoded DNS name only valid for lustre file systems created after Mar-1 2021
48+
# For older file systems, DNS names need to be retrieved from FSx API
49+
# For Ontap and OpenZFS file systems, the DNS name is always passed from CLI.
4350
"#{fsx_fs_id}.fsx.#{node['cluster']['region']}.amazonaws.com"
4451
end
52+
case fsx_fs_type
53+
when 'LUSTRE'
54+
mount_name = fsx_mount_name_array[index]
55+
mount_options = %w(defaults _netdev flock user_xattr noatime noauto x-systemd.automount)
4556

46-
mount_name = fsx_mount_name_array[index]
47-
mount_options = %w(defaults _netdev flock user_xattr noatime)
48-
49-
mount_options.concat(%w(noauto x-systemd.automount))
50-
51-
# Mount FSx over NFS
52-
mount fsx_shared_dir do
53-
device "#{dns_name}@tcp:/#{mount_name}"
54-
fstype 'lustre'
55-
dump 0
56-
pass 0
57-
options mount_options
58-
action %i(mount enable)
59-
retries 10
60-
retry_delay 6
61-
end
57+
mount fsx_shared_dir do
58+
device "#{dns_name}@tcp:/#{mount_name}"
59+
fstype 'lustre'
60+
dump 0
61+
pass 0
62+
options mount_options
63+
action %i(mount enable)
64+
retries 10
65+
retry_delay 6
66+
end
6267

63-
# Make sure permission is correct
64-
directory fsx_shared_dir do
65-
owner 'root'
66-
group 'root'
67-
mode '1777'
68+
# Make sure permission is correct
69+
directory fsx_shared_dir do
70+
owner 'root'
71+
group 'root'
72+
mode '1777'
73+
end
74+
when 'OPENZFS'
75+
mount fsx_shared_dir do
76+
device "#{dns_name}:#{fsx_volume_junction_path}"
77+
fstype 'nfs'
78+
dump 0
79+
pass 0
80+
options 'nfsvers=4.2'
81+
action %i(mount enable)
82+
retries 10
83+
retry_delay 6
84+
end
85+
when 'ONTAP'
86+
mount fsx_shared_dir do
87+
device "#{dns_name}:#{fsx_volume_junction_path}"
88+
fstype 'nfs'
89+
dump 0
90+
pass 0
91+
action %i(mount enable)
92+
retries 10
93+
retry_delay 6
94+
end
95+
# Make sure permission is correct
96+
directory fsx_shared_dir do
97+
owner 'root'
98+
group 'root'
99+
mode '1777'
100+
end
68101
end
69102
end

0 commit comments

Comments
 (0)