Skip to content

Commit

Permalink
[Storage][IsolatedRegions] Adapt FSxLustre DNS domain for US isolated…
Browse files Browse the repository at this point in the history
… regions.

Signed-off-by: Giacomo Marciani <mgiacomo@amazon.com>
  • Loading branch information
gmarciani committed Jun 12, 2024
1 parent debe75b commit e1b1a4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
4 changes: 4 additions & 0 deletions cookbooks/aws-parallelcluster-environment/libraries/fsx.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def aws_domain_for_fsx(region)
# DNS names have the default AWS domain (amazonaws.com) also in China and GovCloud.
region.start_with?("us-iso") ? aws_domain : CLASSIC_AWS_DOMAIN
end
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def initialize(node, resource, index)
@volume_junction_path = self.class.make_absolute(resource.fsx_volume_junction_path_array[index])

if @dns_name.blank?
# Region Building Note: DNS names have the default AWS domain (amazonaws.com) also in China and GovCloud.
@dns_name = "#{@id}.fsx.#{node['cluster']['region']}.amazonaws.com"
region = node['cluster']['region']
@dns_name = "#{@id}.fsx.#{region}.#{aws_domain_for_fsx(region)}"
end

@mount_name = resource.fsx_mount_name_array[index]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
before do
stub_command("mount | grep ' /lustre_shared_dir_with_no_mount '").and_return(false)
stub_command("mount | grep ' /lustre_shared_dir_with_mount '").and_return(true)
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
end

it 'creates_shared_dir' do
Expand Down Expand Up @@ -58,7 +59,7 @@

it 'enables shared dir mount if already mounted' do
is_expected.to enable_mount('/lustre_shared_dir_with_mount')
.with(device: 'lustre_id_2.fsx.REGION.amazonaws.com@tcp:/lustre_mount_name_2')
.with(device: 'lustre_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX@tcp:/lustre_mount_name_2')
.with(fstype: 'lustre')
.with(dump: 0)
.with(pass: 0)
Expand Down Expand Up @@ -113,6 +114,7 @@
before do
stub_command("mount | grep ' /filecache_shared_dir_1 '").and_return(false)
stub_command("mount | grep ' /filecache_shared_dir_2 '").and_return(true)
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
end

it 'creates_shared_dir' do
Expand Down Expand Up @@ -196,6 +198,7 @@
before do
stub_command("mount | grep ' /openzfs_shared_dir_1 '").and_return(false)
stub_command("mount | grep ' /openzfs_shared_dir_2 '").and_return(true)
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
end

it 'creates_shared_dir' do
Expand Down Expand Up @@ -225,7 +228,7 @@

it 'enables shared dir mount if already mounted' do
is_expected.to enable_mount('/openzfs_shared_dir_2')
.with(device: 'openzfs_id_2.fsx.REGION.amazonaws.com:/junction_path_2')
.with(device: 'openzfs_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX:/junction_path_2')
.with(fstype: 'nfs')
.with(dump: 0)
.with(pass: 0)
Expand Down Expand Up @@ -272,6 +275,7 @@
before do
stub_command("mount | grep ' /ontap_shared_dir_1 '").and_return(false)
stub_command("mount | grep ' /ontap_shared_dir_2 '").and_return(true)
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
end

it 'creates_shared_dir' do
Expand Down Expand Up @@ -301,7 +305,7 @@

it 'enables shared dir mount if already mounted' do
is_expected.to enable_mount('/ontap_shared_dir_2')
.with(device: 'ontap_id_2.fsx.REGION.amazonaws.com:/junction_path_2')
.with(device: 'ontap_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX:/junction_path_2')
.with(fstype: 'nfs')
.with(dump: 0)
.with(pass: 0)
Expand Down Expand Up @@ -366,6 +370,7 @@
allow(Dir).to receive(:empty?).with("/shared_dir_1").and_return(true)
allow(Dir).to receive(:exist?).with("/shared_dir_2").and_return(true)
allow(Dir).to receive(:empty?).with("/shared_dir_2").and_return(false)
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
end

it 'unmounts fsx only if mounted' do
Expand All @@ -383,9 +388,9 @@
.with(path: "/etc/fstab")
.with(pattern: "dns_name@tcp:/mount_name_1 *")

is_expected.to edit_delete_lines('remove volume lustre_id_2.fsx.REGION.amazonaws.com@tcp:/mount_name_2 from /etc/fstab')
is_expected.to edit_delete_lines('remove volume lustre_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX@tcp:/mount_name_2 from /etc/fstab')
.with(path: "/etc/fstab")
.with(pattern: "lustre_id_2.fsx.REGION.amazonaws.com@tcp:/mount_name_2 *")
.with(pattern: "lustre_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX@tcp:/mount_name_2 *")
end

it 'deletes shared dir only if it exists and it is empty' do
Expand Down Expand Up @@ -423,6 +428,7 @@
allow(Dir).to receive(:empty?).with("/shared_dir_1").and_return(true)
allow(Dir).to receive(:exist?).with("/shared_dir_2").and_return(true)
allow(Dir).to receive(:empty?).with("/shared_dir_2").and_return(false)
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
end

it 'unmounts fsx only if mounted' do
Expand All @@ -440,9 +446,9 @@
.with(path: "/etc/fstab")
.with(pattern: "dns_name:/junction_path_1 *")

is_expected.to edit_delete_lines('remove volume ontap_id_2.fsx.REGION.amazonaws.com:/junction_path_2 from /etc/fstab')
is_expected.to edit_delete_lines('remove volume ontap_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX:/junction_path_2 from /etc/fstab')
.with(path: "/etc/fstab")
.with(pattern: "ontap_id_2.fsx.REGION.amazonaws.com:/junction_path_2 *")
.with(pattern: "ontap_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX:/junction_path_2 *")
end

it 'deletes shared dir only if it exists and it is empty' do
Expand Down Expand Up @@ -480,6 +486,7 @@
allow(Dir).to receive(:empty?).with("/filecache_dir_1").and_return(true)
allow(Dir).to receive(:exist?).with("/filecache_dir_2").and_return(true)
allow(Dir).to receive(:empty?).with("/filecache_dir_2").and_return(false)
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
end

it 'unmounts fsx only if mounted' do
Expand Down

0 comments on commit e1b1a4e

Please sign in to comment.