Skip to content

Commit

Permalink
Support mounting existing FSx for Ontap and OpenZFS
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
hanwen-cluster committed May 23, 2022
1 parent 82794e7 commit f8b836d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 23 deletions.
2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@
default['cluster']['fsx_fs_ids'] = ''
default['cluster']['fsx_dns_names'] = ''
default['cluster']['fsx_mount_names'] = ''
default['cluster']['fsx_fs_types'] = ''
default['cluster']['fsx_volume_junction_paths'] = ''
default['cluster']['custom_node_package'] = nil
default['cluster']['custom_awsbatchcli_package'] = nil
default['cluster']['raid_shared_dir'] = ''
Expand Down
79 changes: 56 additions & 23 deletions cookbooks/aws-parallelcluster-config/recipes/fsx_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@
# limitations under the License.

fsx_fs_id_array = node['cluster']['fsx_fs_ids'].split(',')
fsx_fs_type_array = node['cluster']['fsx_fs_types'].split(',')
fsx_shared_dir_array = node['cluster']['fsx_shared_dirs'].split(',')
fsx_dns_name_array = node['cluster']['fsx_dns_names'].split(',')
fsx_mount_name_array = node['cluster']['fsx_mount_names'].split(',')
fsx_volume_junction_path_array = node['cluster']['fsx_volume_junction_paths'].split(',')
# Check to see if FSx is created
fsx_fs_id_array.each_with_index do |fsx_fs_id, index|
fsx_shared_dir = fsx_shared_dir_array[index]
fsx_dns_name = fsx_dns_name_array[index]
fsx_fs_type = fsx_fs_type_array[index]
fsx_volume_junction_path = fsx_volume_junction_path_array[index]

# Path needs to be fully qualified, for example "shared/temp" becomes "/shared/temp"
fsx_shared_dir = "/#{fsx_shared_dir}" unless fsx_shared_dir.start_with?('/')
fsx_volume_junction_path = "/#{fsx_volume_junction_path}" unless fsx_volume_junction_path.nil? || fsx_volume_junction_path.start_with?('/')

# Create the shared directories
directory fsx_shared_dir do
Expand All @@ -36,34 +42,61 @@
end

dns_name = if fsx_dns_name && !fsx_dns_name.empty?
# DNS names of existing Lustre, Ontap, OpenZFS file systems are passed in from CLI
fsx_dns_name
else
# Hardcoded DNSname only valid for filesystem created after Mar-1 2021
# For older filesystems, DNSname needs to be retrieved from FSx API
# DNS names of newly created Lustre file systems are hardcoded here.
# Note the Hardcoding format is only valid for lustre file systems created after Mar-1 2021
"#{fsx_fs_id}.fsx.#{node['cluster']['region']}.amazonaws.com"
end
case fsx_fs_type
when 'LUSTRE'
mount_name = fsx_mount_name_array[index]
mount_options = %w(defaults _netdev flock user_xattr noatime noauto x-systemd.automount)

mount_name = fsx_mount_name_array[index]
mount_options = %w(defaults _netdev flock user_xattr noatime)

mount_options.concat(%w(noauto x-systemd.automount))

# Mount FSx over NFS
mount fsx_shared_dir do
device "#{dns_name}@tcp:/#{mount_name}"
fstype 'lustre'
dump 0
pass 0
options mount_options
action %i(mount enable)
retries 10
retry_delay 6
end
mount fsx_shared_dir do
device "#{dns_name}@tcp:/#{mount_name}"
fstype 'lustre'
dump 0
pass 0
options mount_options
action %i(mount enable)
retries 10
retry_delay 6
end

# Make sure permission is correct
directory fsx_shared_dir do
owner 'root'
group 'root'
mode '1777'
# Make sure permission is correct
directory fsx_shared_dir do
owner 'root'
group 'root'
mode '1777'
end
when 'OPENZFS'
mount fsx_shared_dir do
device "#{dns_name}:#{fsx_volume_junction_path}"
fstype 'nfs'
dump 0
pass 0
options 'nfsvers=4.2'
action %i(mount enable)
retries 10
retry_delay 6
end
when 'ONTAP'
mount fsx_shared_dir do
device "#{dns_name}:#{fsx_volume_junction_path}"
fstype 'nfs'
dump 0
pass 0
action %i(mount enable)
retries 10
retry_delay 6
end
# Make sure permission is correct
directory fsx_shared_dir do
owner 'root'
group 'root'
mode '1777'
end
end
end

0 comments on commit f8b836d

Please sign in to comment.