Skip to content

Commit 4cfb012

Browse files
Rexrexcsn
authored andcommitted
Add validator to prevent using data_compression_type with fsx_backup_id
* DataCompressionType is not supported when creating filesystem from backup. The designed behavior is to use the existing compression setting from the backup. Add validator for this case * DataCompressionType option cannot be specified in CFN when creating from backup, added logic to use `AWS:NoValue` if using backup Signed-off-by: Rex <[email protected]>
1 parent 83f3fd1 commit 4cfb012

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

cli/src/pcluster/config/validators.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ def fsx_validator(section_key, section_label, pcluster_config):
232232
fsx_copy_tags_to_backups = fsx_section.get_param_value("copy_tags_to_backups")
233233
fsx_storage_type = fsx_section.get_param_value("storage_type")
234234
fsx_drive_cache_type = fsx_section.get_param_value("drive_cache_type")
235+
fsx_backup_id = fsx_section.get_param_value("fsx_backup_id")
236+
fsx_data_compression_type = fsx_section.get_param_value("data_compression_type")
235237

236238
validate_s3_options(errors, fsx_import_path, fsx_imported_file_chunk_size, fsx_export_path, fsx_auto_import_policy)
237239
validate_persistent_options(errors, fsx_deployment_type, fsx_kms_key_id, fsx_per_unit_storage_throughput)
@@ -249,10 +251,22 @@ def fsx_validator(section_key, section_label, pcluster_config):
249251
validate_storage_type_options(
250252
errors, fsx_storage_type, fsx_deployment_type, fsx_per_unit_storage_throughput, fsx_drive_cache_type
251253
)
254+
_validate_fsx_compression_type_option(errors, fsx_backup_id, fsx_data_compression_type)
252255

253256
return errors, warnings
254257

255258

259+
def _validate_fsx_compression_type_option(errors, fsx_backup_id, fsx_data_compression_type):
260+
# DataCompressionType is not supported when creating filesystem from backup.
261+
# The designed behavior is to use the existing compression setting from the backup.
262+
if fsx_backup_id and fsx_data_compression_type and fsx_data_compression_type != "NONE":
263+
errors.append(
264+
f"FSx data compression option ({fsx_data_compression_type}) cannot be specified "
265+
f"when creating a filesystem from backup ({fsx_backup_id}). "
266+
"To fix, please unspecify 'fsx_backup_id' or 'data_compression_type'."
267+
)
268+
269+
256270
def fsx_architecture_os_validator(section_key, section_label, pcluster_config):
257271
errors = []
258272
warnings = []

cli/tests/pcluster/config/test_validators.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,33 @@ def _kms_key_stubber(mocker, boto3_stubber, kms_key_id, expected_message, num_ca
11211121
"'drive_cache_type' features can be used only with HDD filesystems",
11221122
0,
11231123
),
1124+
(
1125+
{
1126+
"data_compression_type": "LZ4",
1127+
"fsx_backup_id": "backup-12345678",
1128+
},
1129+
None,
1130+
"FSx data compression option (LZ4) cannot be specified when creating a filesystem from backup",
1131+
0,
1132+
),
1133+
(
1134+
{
1135+
"data_compression_type": "NONE",
1136+
"fsx_backup_id": "backup-12345678",
1137+
},
1138+
None,
1139+
"The configuration parameter 'data_compression_type' has an invalid value 'NONE'",
1140+
0,
1141+
),
1142+
(
1143+
{
1144+
"data_compression_type": "LZ4",
1145+
"storage_capacity": 1200,
1146+
},
1147+
None,
1148+
None,
1149+
0,
1150+
),
11241151
],
11251152
)
11261153
def test_fsx_validator(mocker, boto3_stubber, section_dict, bucket, expected_error, num_calls):

cloudformation/fsx-substack.cfn.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,18 @@
605605
]
606606
},
607607
"DataCompressionType": {
608-
"Fn::Select": [
609-
"19",
608+
"Fn::If": [
609+
"UseBackupId",
610610
{
611-
"Ref": "FSXOptions"
611+
"Ref": "AWS::NoValue"
612+
},
613+
{
614+
"Fn::Select": [
615+
"19",
616+
{
617+
"Ref": "FSXOptions"
618+
}
619+
]
612620
}
613621
]
614622
}

0 commit comments

Comments
 (0)