Skip to content

Commit

Permalink
used black formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
mapk-amazon committed Aug 13, 2024
1 parent 80a3555 commit 715596e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cli/src/pcluster/aws/efs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ def describe_access_point(self, access_point_id):
:param efaccess_point_ids_ap_id: EFS access point Id
:return: the access_point details
"""
return self._client.describe_access_points(AccessPointId=access_point_id)
return self._client.describe_access_points(AccessPointId=access_point_id)
3 changes: 2 additions & 1 deletion cli/src/pcluster/config/cluster_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,10 @@ def _register_validators(self, context: ValidatorContext = None): # noqa: D102
EfsAccessPointOptionsValidator,
access_point_id=self.access_point_id,
file_system_id=self.file_system_id,
encryption_in_transit=self.encryption_in_transit
encryption_in_transit=self.encryption_in_transit,
)


class BaseSharedFsx(Resource):
"""Represent the shared FSX resource."""

Expand Down
2 changes: 1 addition & 1 deletion cli/src/pcluster/schemas/cluster_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def validate_file_system_id_ignored_parameters(self, data, **kwargs):
"encryption_in_transit",
"iam_authorization",
"file_system_id",
"access_point_id"
"access_point_id",
]:
messages.append(EFS_MESSAGES["errors"]["ignored_param_with_efs_fs_id"].format(efs_param=key))
if messages:
Expand Down
3 changes: 2 additions & 1 deletion cli/src/pcluster/validators/efs_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ def _validate(self, encryption_in_transit: bool, iam_authorization: bool, name:
FailureLevel.ERROR,
)


class EfsAccessPointOptionsValidator(Validator):
"""
EFS Mount Options validator.
IAM Authorization requires Encryption in Transit.
"""

def _validate(self, access_point_id: str, file_system_id: str, encryption_in_transit: bool):
def _validate(self, access_point_id: str, file_system_id: str, encryption_in_transit: bool):

if access_point_id and not file_system_id:
self._add_failure(
Expand Down
11 changes: 6 additions & 5 deletions cli/tests/pcluster/validators/test_efs_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
),
],
)
def test_efs_mount_options_validator(
encryption_in_transit, iam_authorization, expected_message
):
def test_efs_mount_options_validator(encryption_in_transit, iam_authorization, expected_message):
actual_failures = EfsMountOptionsValidator().execute(
encryption_in_transit, iam_authorization, "<name-of-the-file-system>"
)
Expand Down Expand Up @@ -82,6 +80,7 @@ def test_efs_access_point_with_filesystem_validator(access_point_id, file_system
actual_failures = EfsAccessPointOptionsValidator().execute(access_point_id, file_system_id, True)
assert_failure_messages(actual_failures, expected_message)


@pytest.mark.parametrize(
"access_point_id, encryption_in_transit, expected_message",
[
Expand Down Expand Up @@ -109,5 +108,7 @@ def test_efs_access_point_with_filesystem_validator(access_point_id, file_system
],
)
def test_efs_access_point_with_filesystem_validator(access_point_id, encryption_in_transit, expected_message):
actual_failures = EfsAccessPointOptionsValidator().execute(access_point_id, "<file-system-id>", encryption_in_transit)
assert_failure_messages(actual_failures, expected_message)
actual_failures = EfsAccessPointOptionsValidator().execute(
access_point_id, "<file-system-id>", encryption_in_transit
)
assert_failure_messages(actual_failures, expected_message)
1 change: 1 addition & 0 deletions tests/integration-tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,7 @@ def create_efs(num=1):
for stack in created_stacks:
cfn_stacks_factory.delete_stack(stack.name, region)


@pytest.fixture(scope="class")
def efs_access_point_stack_factory(cfn_stacks_factory, request, region, vpc_stack):
"""EFS stack contains a single efs and a single access point resource."""
Expand Down
9 changes: 8 additions & 1 deletion tests/integration-tests/tests/storage/storage_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,14 @@ def test_raid_correctly_mounted(remote_command_executor, mount_dir, volume_size)


def write_file_into_efs(
region, vpc_stack: CfnVpcStack, efs_ids, request, key_name, cfn_stacks_factory, efs_mount_target_stack_factory, access_point_id=None
region,
vpc_stack: CfnVpcStack,
efs_ids,
request,
key_name,
cfn_stacks_factory,
efs_mount_target_stack_factory,
access_point_id=None,
):
"""Write file stack contains an instance to write an empty file with random name into each of the efs in efs_ids."""
write_file_template = Template()
Expand Down
16 changes: 9 additions & 7 deletions tests/integration-tests/tests/storage/test_efs.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def test_multiple_efs(
encryption_in_transits,
)


@pytest.mark.usefixtures("instance")
def test_efs_access_point(
os,
Expand Down Expand Up @@ -251,8 +252,8 @@ def test_efs_access_point(
"Resource": f"arn:{get_arn_partition(region)}:elasticfilesystem:{region}:{account_id}:"
f"file-system/{efs_filesystem_id}",
"Condition": {
"StringNotLike": {"elasticfilesystem:AccessPointArn":
f"arn:{get_arn_partition(region)}:elasticfilesystem:{region}:{account_id}:access-point/{access_point_id}"
"StringNotLike": {
"elasticfilesystem:AccessPointArn": f"arn:{get_arn_partition(region)}:elasticfilesystem:{region}:{account_id}:access-point/{access_point_id}"
}
},
},
Expand All @@ -266,14 +267,16 @@ def test_efs_access_point(
"elasticfilesystem:ClientWrite",
],
"Resource": f"arn:{get_arn_partition(region)}:elasticfilesystem:{region}:{account_id}:"
f"file-system/{efs_filesystem_id}"
}
]
f"file-system/{efs_filesystem_id}",
},
],
}
boto3.client("efs").put_file_system_policy(FileSystemId=efs_filesystem_id, Policy=json.dumps(policy))

mount_dir = "efs_mount_dir"
cluster_config = pcluster_config_reader(mount_dir=mount_dir, efs_filesystem_id=efs_filesystem_id, access_point_id=access_point_id)
cluster_config = pcluster_config_reader(
mount_dir=mount_dir, efs_filesystem_id=efs_filesystem_id, access_point_id=access_point_id
)
cluster = clusters_factory(cluster_config)
remote_command_executor = RemoteCommandExecutor(cluster)

Expand All @@ -283,7 +286,6 @@ def test_efs_access_point(
_test_efs_correctly_shared(remote_command_executor, mount_dir, scheduler_commands)



def _check_efs_after_nodes_reboot(
all_mount_dirs,
cluster,
Expand Down

0 comments on commit 715596e

Please sign in to comment.