From f8b836dbc067b3b961a83ba568206cb485479035 Mon Sep 17 00:00:00 2001 From: Hanwen Date: Fri, 22 Apr 2022 14:13:59 -0700 Subject: [PATCH] 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 --- attributes/default.rb | 2 + .../recipes/fsx_mount.rb | 79 +++++++++++++------ 2 files changed, 58 insertions(+), 23 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 5c1bb3365d..c0f4ac4530 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -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'] = '' diff --git a/cookbooks/aws-parallelcluster-config/recipes/fsx_mount.rb b/cookbooks/aws-parallelcluster-config/recipes/fsx_mount.rb index 5b6c228d39..d34a6edc81 100644 --- a/cookbooks/aws-parallelcluster-config/recipes/fsx_mount.rb +++ b/cookbooks/aws-parallelcluster-config/recipes/fsx_mount.rb @@ -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 @@ -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