Skip to content

Commit e1b1a4e

Browse files
committed
[Storage][IsolatedRegions] Adapt FSxLustre DNS domain for US isolated regions.
Signed-off-by: Giacomo Marciani <[email protected]>
1 parent debe75b commit e1b1a4e

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def aws_domain_for_fsx(region)
2+
# DNS names have the default AWS domain (amazonaws.com) also in China and GovCloud.
3+
region.start_with?("us-iso") ? aws_domain : CLASSIC_AWS_DOMAIN
4+
end

cookbooks/aws-parallelcluster-environment/resources/lustre/partial/_mount_unmount.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ def initialize(node, resource, index)
109109
@volume_junction_path = self.class.make_absolute(resource.fsx_volume_junction_path_array[index])
110110

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

116116
@mount_name = resource.fsx_mount_name_array[index]

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
before do
3030
stub_command("mount | grep ' /lustre_shared_dir_with_no_mount '").and_return(false)
3131
stub_command("mount | grep ' /lustre_shared_dir_with_mount '").and_return(true)
32+
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
3233
end
3334

3435
it 'creates_shared_dir' do
@@ -58,7 +59,7 @@
5859

5960
it 'enables shared dir mount if already mounted' do
6061
is_expected.to enable_mount('/lustre_shared_dir_with_mount')
61-
.with(device: 'lustre_id_2.fsx.REGION.amazonaws.com@tcp:/lustre_mount_name_2')
62+
.with(device: 'lustre_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX@tcp:/lustre_mount_name_2')
6263
.with(fstype: 'lustre')
6364
.with(dump: 0)
6465
.with(pass: 0)
@@ -113,6 +114,7 @@
113114
before do
114115
stub_command("mount | grep ' /filecache_shared_dir_1 '").and_return(false)
115116
stub_command("mount | grep ' /filecache_shared_dir_2 '").and_return(true)
117+
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
116118
end
117119

118120
it 'creates_shared_dir' do
@@ -196,6 +198,7 @@
196198
before do
197199
stub_command("mount | grep ' /openzfs_shared_dir_1 '").and_return(false)
198200
stub_command("mount | grep ' /openzfs_shared_dir_2 '").and_return(true)
201+
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
199202
end
200203

201204
it 'creates_shared_dir' do
@@ -225,7 +228,7 @@
225228

226229
it 'enables shared dir mount if already mounted' do
227230
is_expected.to enable_mount('/openzfs_shared_dir_2')
228-
.with(device: 'openzfs_id_2.fsx.REGION.amazonaws.com:/junction_path_2')
231+
.with(device: 'openzfs_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX:/junction_path_2')
229232
.with(fstype: 'nfs')
230233
.with(dump: 0)
231234
.with(pass: 0)
@@ -272,6 +275,7 @@
272275
before do
273276
stub_command("mount | grep ' /ontap_shared_dir_1 '").and_return(false)
274277
stub_command("mount | grep ' /ontap_shared_dir_2 '").and_return(true)
278+
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
275279
end
276280

277281
it 'creates_shared_dir' do
@@ -301,7 +305,7 @@
301305

302306
it 'enables shared dir mount if already mounted' do
303307
is_expected.to enable_mount('/ontap_shared_dir_2')
304-
.with(device: 'ontap_id_2.fsx.REGION.amazonaws.com:/junction_path_2')
308+
.with(device: 'ontap_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX:/junction_path_2')
305309
.with(fstype: 'nfs')
306310
.with(dump: 0)
307311
.with(pass: 0)
@@ -366,6 +370,7 @@
366370
allow(Dir).to receive(:empty?).with("/shared_dir_1").and_return(true)
367371
allow(Dir).to receive(:exist?).with("/shared_dir_2").and_return(true)
368372
allow(Dir).to receive(:empty?).with("/shared_dir_2").and_return(false)
373+
allow_any_instance_of(Object).to receive(:aws_domain_for_fsx).and_return("AWS_DOMAIN_FOR_FSX")
369374
end
370375

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

386-
is_expected.to edit_delete_lines('remove volume lustre_id_2.fsx.REGION.amazonaws.com@tcp:/mount_name_2 from /etc/fstab')
391+
is_expected.to edit_delete_lines('remove volume lustre_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX@tcp:/mount_name_2 from /etc/fstab')
387392
.with(path: "/etc/fstab")
388-
.with(pattern: "lustre_id_2.fsx.REGION.amazonaws.com@tcp:/mount_name_2 *")
393+
.with(pattern: "lustre_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX@tcp:/mount_name_2 *")
389394
end
390395

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

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

443-
is_expected.to edit_delete_lines('remove volume ontap_id_2.fsx.REGION.amazonaws.com:/junction_path_2 from /etc/fstab')
449+
is_expected.to edit_delete_lines('remove volume ontap_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX:/junction_path_2 from /etc/fstab')
444450
.with(path: "/etc/fstab")
445-
.with(pattern: "ontap_id_2.fsx.REGION.amazonaws.com:/junction_path_2 *")
451+
.with(pattern: "ontap_id_2.fsx.REGION.AWS_DOMAIN_FOR_FSX:/junction_path_2 *")
446452
end
447453

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

485492
it 'unmounts fsx only if mounted' do

0 commit comments

Comments
 (0)