Skip to content

Commit 9c95c32

Browse files
authored
Merge pull request #44456 from tabito-hara/b-aws_fsx_lustre_file_system-fix_update_order
aws_fsx_lustre_file_system: Fixed to update `metadata_configuration` first to allow simultaneous increase of `metadata_configuration.iops` and `storage_capacity`
2 parents 04134fc + bca1b11 commit 9c95c32

File tree

3 files changed

+78
-12
lines changed

3 files changed

+78
-12
lines changed

.changelog/44456.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/aws_fsx_lustre_file_system: Fixed to update `metadata_configuration` first to allow simultaneous increase of `metadata_configuration.iops` and `storage_capacity`
3+
```

internal/service/fsx/lustre_file_system.go

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,35 @@ func resourceLustreFileSystemUpdate(ctx context.Context, d *schema.ResourceData,
660660
var diags diag.Diagnostics
661661
conn := meta.(*conns.AWSClient).FSxClient(ctx)
662662

663+
updated := false
664+
// First, update the metadata configuration if it has changed.
665+
// Sometimes it is necessary to increase IOPS before increasing storage_capacity.
666+
if d.HasChange("metadata_configuration") {
667+
input := &fsx.UpdateFileSystemInput{
668+
ClientRequestToken: aws.String(id.UniqueId()),
669+
FileSystemId: aws.String(d.Id()),
670+
LustreConfiguration: &awstypes.UpdateFileSystemLustreConfiguration{
671+
MetadataConfiguration: expandLustreMetadataUpdateConfiguration(d.Get("metadata_configuration").([]any)),
672+
},
673+
}
674+
675+
startTime := time.Now()
676+
_, err := conn.UpdateFileSystem(ctx, input)
677+
678+
if err != nil {
679+
return sdkdiag.AppendErrorf(diags, "updating FSX for Lustre File System (%s) metadata_configuration: %s", d.Id(), err)
680+
}
681+
682+
if _, err := waitFileSystemUpdated(ctx, conn, d.Id(), startTime, d.Timeout(schema.TimeoutUpdate)); err != nil {
683+
return sdkdiag.AppendErrorf(diags, "waiting for FSx for Lustre File System (%s) metadata_configuration update: %s", d.Id(), err)
684+
}
685+
updated = true
686+
}
687+
663688
if d.HasChangesExcept(
664689
"final_backup_tags",
665690
"skip_final_backup",
691+
"metadata_configuration",
666692
names.AttrTags,
667693
names.AttrTagsAll,
668694
) {
@@ -696,10 +722,6 @@ func resourceLustreFileSystemUpdate(ctx context.Context, d *schema.ResourceData,
696722
input.LustreConfiguration.LogConfiguration = expandLustreLogCreateConfiguration(d.Get("log_configuration").([]any))
697723
}
698724

699-
if d.HasChange("metadata_configuration") {
700-
input.LustreConfiguration.MetadataConfiguration = expandLustreMetadataUpdateConfiguration(d.Get("metadata_configuration").([]any))
701-
}
702-
703725
if d.HasChange("per_unit_storage_throughput") {
704726
input.LustreConfiguration.PerUnitStorageThroughput = aws.Int32(int32(d.Get("per_unit_storage_throughput").(int)))
705727
}
@@ -730,7 +752,10 @@ func resourceLustreFileSystemUpdate(ctx context.Context, d *schema.ResourceData,
730752
if _, err := waitFileSystemUpdated(ctx, conn, d.Id(), startTime, d.Timeout(schema.TimeoutUpdate)); err != nil {
731753
return sdkdiag.AppendErrorf(diags, "waiting for FSx for Lustre File System (%s) update: %s", d.Id(), err)
732754
}
755+
updated = true
756+
}
733757

758+
if updated {
734759
if _, err := waitFileSystemAdministrativeActionCompleted(ctx, conn, d.Id(), awstypes.AdministrativeActionTypeFileSystemUpdate, d.Timeout(schema.TimeoutUpdate)); err != nil {
735760
return sdkdiag.AppendErrorf(diags, "waiting for FSx for Lustre File System (%s) administrative action (%s) complete: %s", d.Id(), awstypes.AdministrativeActionTypeFileSystemUpdate, err)
736761
}

internal/service/fsx/lustre_file_system_test.go

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ func TestAccFSxLustreFileSystem_metadataConfig(t *testing.T) {
10101010
ImportStateVerifyIgnore: []string{names.AttrSecurityGroupIDs},
10111011
},
10121012
{
1013-
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 1500),
1013+
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 1500, 1200),
10141014
Check: resource.ComposeTestCheckFunc(
10151015
testAccCheckLustreFileSystemExists(ctx, resourceName, &filesystem2),
10161016
testAccCheckLustreFileSystemNotRecreated(&filesystem1, &filesystem2),
@@ -1036,7 +1036,7 @@ func TestAccFSxLustreFileSystem_metadataConfig_increase(t *testing.T) {
10361036
CheckDestroy: testAccCheckLustreFileSystemDestroy(ctx),
10371037
Steps: []resource.TestStep{
10381038
{
1039-
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 1500),
1039+
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 1500, 1200),
10401040
Check: resource.ComposeTestCheckFunc(
10411041
testAccCheckLustreFileSystemExists(ctx, resourceName, &filesystem1),
10421042
resource.TestCheckResourceAttr(resourceName, "metadata_configuration.#", "1"),
@@ -1051,7 +1051,7 @@ func TestAccFSxLustreFileSystem_metadataConfig_increase(t *testing.T) {
10511051
ImportStateVerifyIgnore: []string{names.AttrSecurityGroupIDs},
10521052
},
10531053
{
1054-
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 3000),
1054+
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 3000, 1200),
10551055
Check: resource.ComposeTestCheckFunc(
10561056
testAccCheckLustreFileSystemExists(ctx, resourceName, &filesystem2),
10571057
testAccCheckLustreFileSystemNotRecreated(&filesystem1, &filesystem2),
@@ -1077,7 +1077,7 @@ func TestAccFSxLustreFileSystem_metadataConfig_decrease(t *testing.T) {
10771077
CheckDestroy: testAccCheckLustreFileSystemDestroy(ctx),
10781078
Steps: []resource.TestStep{
10791079
{
1080-
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 3000),
1080+
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 3000, 1200),
10811081
Check: resource.ComposeTestCheckFunc(
10821082
testAccCheckLustreFileSystemExists(ctx, resourceName, &filesystem1),
10831083
resource.TestCheckResourceAttr(resourceName, "metadata_configuration.#", "1"),
@@ -1092,7 +1092,7 @@ func TestAccFSxLustreFileSystem_metadataConfig_decrease(t *testing.T) {
10921092
ImportStateVerifyIgnore: []string{names.AttrSecurityGroupIDs},
10931093
},
10941094
{
1095-
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 1500),
1095+
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 1500, 1200),
10961096
Check: resource.ComposeTestCheckFunc(
10971097
testAccCheckLustreFileSystemExists(ctx, resourceName, &filesystem2),
10981098
testAccCheckLustreFileSystemRecreated(&filesystem1, &filesystem2),
@@ -1105,6 +1105,44 @@ func TestAccFSxLustreFileSystem_metadataConfig_decrease(t *testing.T) {
11051105
})
11061106
}
11071107

1108+
func TestAccFSxLustreFileSystem_metadataConfig_increaseWithStorageCapacity(t *testing.T) {
1109+
ctx := acctest.Context(t)
1110+
var filesystem1, filesystem2 awstypes.FileSystem
1111+
resourceName := "aws_fsx_lustre_file_system.test"
1112+
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
1113+
1114+
resource.ParallelTest(t, resource.TestCase{
1115+
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) },
1116+
ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID),
1117+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
1118+
CheckDestroy: testAccCheckLustreFileSystemDestroy(ctx),
1119+
Steps: []resource.TestStep{
1120+
{
1121+
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 1500, 1200),
1122+
Check: resource.ComposeTestCheckFunc(
1123+
testAccCheckLustreFileSystemExists(ctx, resourceName, &filesystem1),
1124+
resource.TestCheckResourceAttr(resourceName, "metadata_configuration.#", "1"),
1125+
resource.TestCheckResourceAttr(resourceName, "metadata_configuration.0.mode", "USER_PROVISIONED"),
1126+
resource.TestCheckResourceAttr(resourceName, "metadata_configuration.0.iops", "1500"),
1127+
resource.TestCheckResourceAttr(resourceName, "storage_capacity", "1200"),
1128+
),
1129+
},
1130+
{
1131+
// When storage_capacity is increased to 2400, IOPS must be increased to at least 3000.
1132+
Config: testAccLustreFileSystemConfig_metadata_iops(rName, "USER_PROVISIONED", 3000, 2400),
1133+
Check: resource.ComposeTestCheckFunc(
1134+
testAccCheckLustreFileSystemExists(ctx, resourceName, &filesystem2),
1135+
testAccCheckLustreFileSystemNotRecreated(&filesystem1, &filesystem2),
1136+
resource.TestCheckResourceAttr(resourceName, "metadata_configuration.#", "1"),
1137+
resource.TestCheckResourceAttr(resourceName, "metadata_configuration.0.mode", "USER_PROVISIONED"),
1138+
resource.TestCheckResourceAttr(resourceName, "metadata_configuration.0.iops", "3000"),
1139+
resource.TestCheckResourceAttr(resourceName, "storage_capacity", "2400"),
1140+
),
1141+
},
1142+
},
1143+
})
1144+
}
1145+
11081146
func TestAccFSxLustreFileSystem_rootSquashConfig(t *testing.T) {
11091147
ctx := acctest.Context(t)
11101148
var filesystem awstypes.FileSystem
@@ -2015,10 +2053,10 @@ resource "aws_fsx_lustre_file_system" "test" {
20152053
`, rName, mode))
20162054
}
20172055

2018-
func testAccLustreFileSystemConfig_metadata_iops(rName, mode string, iops int) string {
2056+
func testAccLustreFileSystemConfig_metadata_iops(rName, mode string, iops, storageCapacity int) string {
20192057
return acctest.ConfigCompose(testAccLustreFileSystemConfig_base(rName), fmt.Sprintf(`
20202058
resource "aws_fsx_lustre_file_system" "test" {
2021-
storage_capacity = 1200
2059+
storage_capacity = %[4]d
20222060
subnet_ids = aws_subnet.test[*].id
20232061
deployment_type = "PERSISTENT_2"
20242062
per_unit_storage_throughput = 125
@@ -2032,7 +2070,7 @@ resource "aws_fsx_lustre_file_system" "test" {
20322070
Name = %[1]q
20332071
}
20342072
}
2035-
`, rName, mode, iops))
2073+
`, rName, mode, iops, storageCapacity))
20362074
}
20372075

20382076
func testAccLustreFileSystemConfig_rootSquash(rName, uid string) string {

0 commit comments

Comments
 (0)