Skip to content

Commit

Permalink
Validate FSx Params
Browse files Browse the repository at this point in the history
* `import_path` needs to be specified when using `imported_file_chunk_size` or `export_path`
* Only Supported OS is `centos7`

Signed-off-by: Sean Smith <[email protected]>
  • Loading branch information
sean-smith committed Mar 5, 2019
1 parent 7a1263c commit 2f8d41f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
28 changes: 20 additions & 8 deletions cli/pcluster/cfnconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,12 @@ def __check_option_absent_awsbatch(self, option):
if self.__config.has_option(self.__cluster_section, option):
self.__fail("option %s cannot be used with awsbatch" % option)

def __validate_awsbatch_os(self, baseos):
supported_batch_oses = ["alinux"]
if baseos not in supported_batch_oses:
self.__fail("awsbatch scheduler supports following OSes: %s" % supported_batch_oses)
def __get_os(self):
return self.__config.get(self.__cluster_section, "base_os") or "alinux"

def __validate_os(self, service, baseos, supported_oses):
if baseos not in supported_oses:
self.__fail("%s supports following OSes: %s" % (service, supported_oses))

def __init_batch_parameters(self): # noqa: C901 FIXME!!!
"""
Expand All @@ -599,7 +601,7 @@ def __init_batch_parameters(self): # noqa: C901 FIXME!!!
self.__check_option_absent_awsbatch("spot_price")

if self.__config.has_option(self.__cluster_section, "base_os"):
self.__validate_awsbatch_os(self.__config.get(self.__cluster_section, "base_os"))
self.__validate_os("awsbatch", self.__get_os(self), ["alinux"])

if self.__config.has_option(self.__cluster_section, "compute_instance_type"):
compute_instance_type = self.__config.get(self.__cluster_section, "compute_instance_type")
Expand Down Expand Up @@ -801,6 +803,10 @@ def __init_fsx_parameters(self):
if not fsx_section:
return

# Check that the base_os is supported
if self.__config.has_option(self.__cluster_section, "base_os"):
self.__validate_os("FSx", self.__get_os(), ["centos7"])

# Dictionary list of all FSx options
fsx_options = OrderedDict(
[
Expand All @@ -809,7 +815,7 @@ def __init_fsx_parameters(self):
("storage_capacity", ("FSXCapacity", "FSx_storage_capacity")),
("fsx_kms_key_id", ("FSXKMSKeyId", None)),
("imported_file_chunk_size", ("ImportedFileChunkSize", "FSx_imported_file_chunk_size")),
("export_path", ("ExportPath", None)),
("export_path", ("ExportPath", "FSx_export_path")),
("import_path", ("ImportPath", None)),
("weekly_maintenance_start_time", ("WeeklyMaintenanceStartTime", None)),
]
Expand All @@ -821,10 +827,16 @@ def __init_fsx_parameters(self):
if not value:
temp_fsx_options.append("NONE")
else:
if not self.__sanity_check:
pass
# Separate sanity_check for fs_id, need to pass in fs_id and subnet_id
if self.__sanity_check and fsx_options.get(key)[1] == "fsx_fs_id":
elif fsx_options.get(key)[1] == "fsx_fs_id":
self.__validate_resource("fsx_fs_id", (value, self.__master_subnet))
elif self.__sanity_check and fsx_options.get(key)[1] is not None:
elif fsx_options.get(key)[1] in ["FSx_imported_file_chunk_size", "FSx_export_path"]:
self.__validate_resource(
fsx_options.get(key)[1], (value, self.__get_option_in_section(fsx_section, "import_path"))
)
elif fsx_options.get(key)[1] is not None:
self.__validate_resource(fsx_options.get(key)[1], value)
temp_fsx_options.append(value)
self.parameters["FSXOptions"] = ",".join(temp_fsx_options)
Expand Down
8 changes: 6 additions & 2 deletions cli/pcluster/config_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ def __validate_fsx_parameters(self, resource_type, resource_value):
self.__fail(
resource_type, "Capacity for FSx lustre filesystem, minimum of 3,600 GB, increments of 3,600 GB"
)
# Check to see if import_path is specified with imported_file_chunk_size and export_path
elif resource_type in ["FSx_imported_file_chunk_size", "FSx_export_path"]:
if resource_value[1] is None:
self.__fail(resource_type, "import_path must be specified.")
# FSX file chunk size check
elif resource_type == "FSx_imported_file_chunk_size":
# 1,024 MiB (1 GiB) and can go as high as 512,000 MiB
if not (1 <= int(resource_value) <= 512000):
if not (1 <= int(resource_value[0]) <= 512000):
self.__fail(resource_type, "has a minimum size of 1 MiB, and max size of 512,000 MiB")

def validate(self, resource_type, resource_value): # noqa: C901 FIXME
Expand Down Expand Up @@ -513,7 +517,7 @@ def validate(self, resource_type, resource_value): # noqa: C901 FIXME
"Needs min of 2 volumes for RAID and max of 5 EBS volumes are currently supported.",
)
# FSX FS Id check
elif resource_type in ["fsx_fs_id", "FSx_storage_capacity", "FSx_imported_file_chunk_size"]:
elif resource_type in ["fsx_fs_id", "FSx_storage_capacity", "FSx_imported_file_chunk_size", "FSx_export_path"]:
self.__validate_fsx_parameters(resource_type, resource_value)
# Batch Parameters
elif resource_type == "AWSBatch_Parameters":
Expand Down
6 changes: 6 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,12 @@ FSx
Configuration for an attached FSx Lustre file system. See `FSx CreateFileSystem
<https://docs.aws.amazon.com/fsx/latest/APIReference/API_CreateFileSystem.html>`_ for more information.

FSx Lustre is only supported when ``base_os = centos7``.

If using an existing file system, it must be associated to a security group that allows inbound and outbound
TCP traffic from ``0.0.0.0/0`` through port ``988``. This is done by automatically when not using
``vpc_security_group_id``.

Use an existing FSx file system by specifying ``fsx_fs_id``. ::

[fsx fs]
Expand Down

0 comments on commit 2f8d41f

Please sign in to comment.