Skip to content

Commit 9c5af13

Browse files
authored
Merge branch 'develop' into PCLUSTER-5187
2 parents f1096fa + cdb654a commit 9c5af13

File tree

101 files changed

+475
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+475
-160
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ assets/
1616
report.html
1717
tests_outputs/
1818
.python-version
19+
test.yaml

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
repos:
2-
- repo: git://github.com/pre-commit/pre-commit-hooks
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v3.4.0
44
hooks:
55
- id: trailing-whitespace
@@ -37,7 +37,7 @@ repos:
3737
args: ['-rc', '-w 120', '--settings-path=cli/.isort.cfg']
3838

3939
- repo: https://github.com/ambv/black
40-
rev: 20.8b1
40+
rev: 22.6.0
4141
hooks:
4242
- id: black
4343
args: ['-l 120']

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CHANGELOG
55
-----
66

77
**ENHANCEMENTS**
8-
- Add new configuration parameter `DeletionPolicy` for EFs and FSx for Lustre shared storage
8+
- Add new configuration parameter `DeletionPolicy` for EFs and FSx for Lustre shared storage
99
to support storage retention on deletion.
1010

1111
**CHANGES**
@@ -14,9 +14,10 @@ CHANGELOG
1414
- Move head node tags from Launch Template to instance definition to avoid head node replacement on tags updates.
1515
- Disable Multithreading through script executed by cloud-init and not through CpuOptions set into Launch Template.
1616
- Add support for multiple instance types in the same Compute Resource.
17+
- Add support for a Name field in PlacementGroup as the preferred naming method.
1718

1819
**BUG FIXES**
19-
- Fix validation of parameter `SharedStorage/EfsSettings`: now validation fails when `FileSystemId` is specified
20+
- Fix validation of parameter `SharedStorage/EfsSettings`: now validation fails when `FileSystemId` is specified
2021
along with other `SharedStorage/EfsSettings` parameters, whereas it was previously ignoring them.
2122
- Fix cluster update when changing the order of SharedStorage together with other changes in the configuration.
2223
- Avoid failing on DescribeCluster when cluster configuration is not available.
@@ -74,7 +75,7 @@ CHANGELOG
7475
- Fix file handle leak in `computemgtd`.
7576
- Fix race condition that was sporadically causing launched instances to be immediately terminated because not available yet in EC2 DescribeInstances response
7677
- Fix support for `DisableSimultaneousMultithreading` parameter on instance types with Arm processors.
77-
- Fix ParallelCluster API stack update failure when upgrading from a previus version. Add resource pattern used for the `ListImagePipelineImages` action in the `EcrImageDeletionLambdaRole`.
78+
- Fix ParallelCluster API stack update failure when upgrading from a previus version. Add resource pattern used for the `ListImagePipelineImages` action in the `EcrImageDeletionLambdaRole`.
7879
- Fix ParallelCluster API adding missing permissions needed to import/export from S3 when creating an FSx for Lustre storage.
7980

8081
3.1.4

cli/src/pcluster/config/cluster_config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
InstanceTypeMemoryInfoValidator,
120120
InstanceTypeValidator,
121121
KeyPairValidator,
122-
PlacementGroupIdValidator,
122+
PlacementGroupNamingValidator,
123123
)
124124
from pcluster.validators.fsx_validators import (
125125
FsxAutoImportValidator,
@@ -539,13 +539,14 @@ def availability_zone(self):
539539
class PlacementGroup(Resource):
540540
"""Represent the placement group for the Queue networking."""
541541

542-
def __init__(self, enabled: bool = None, id: str = None):
542+
def __init__(self, enabled: bool = None, name: str = None, id: str = None):
543543
super().__init__()
544544
self.enabled = Resource.init_param(enabled, default=False)
545-
self.id = Resource.init_param(id)
545+
self.name = Resource.init_param(name)
546+
self.id = Resource.init_param(id) # Duplicate of name
546547

547548
def _register_validators(self):
548-
self._register_validator(PlacementGroupIdValidator, placement_group=self)
549+
self._register_validator(PlacementGroupNamingValidator, placement_group=self)
549550

550551

551552
class _QueueNetworking(_BaseNetworking):

cli/src/pcluster/schemas/cluster_schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ class PlacementGroupSchema(BaseSchema):
630630

631631
enabled = fields.Bool(metadata={"update_policy": UpdatePolicy.QUEUE_UPDATE_STRATEGY})
632632
id = fields.Str(metadata={"update_policy": UpdatePolicy.QUEUE_UPDATE_STRATEGY})
633+
name = fields.Str(metadata={"update_policy": UpdatePolicy.QUEUE_UPDATE_STRATEGY})
633634

634635
@post_load
635636
def make_resource(self, data, **kwargs):

cli/src/pcluster/templates/cluster_stack.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ def _add_placement_groups(self) -> Dict[str, ec2.CfnPlacementGroup]:
13671367
if (
13681368
queue.networking.placement_group
13691369
and queue.networking.placement_group.enabled
1370-
and not queue.networking.placement_group.id
1370+
and not (queue.networking.placement_group.id or queue.networking.placement_group.name)
13711371
):
13721372
managed_placement_groups[queue.name] = ec2.CfnPlacementGroup(
13731373
self, f"PlacementGroup{create_hash_suffix(queue.name)}", strategy="cluster"
@@ -1382,10 +1382,10 @@ def _add_launch_templates(self, managed_placement_groups, instance_profiles):
13821382

13831383
queue_placement_group = None
13841384
if queue.networking.placement_group:
1385-
if queue.networking.placement_group.id and (
1385+
if (queue.networking.placement_group.id or queue.networking.placement_group.name) and (
13861386
queue.networking.placement_group.enabled or queue.networking.placement_group.is_implied("enabled")
1387-
): # Do not use `PlacementGroup/Id` when `PlacementGroup/Enabled` is explicitly set to `false`
1388-
queue_placement_group = queue.networking.placement_group.id
1387+
):
1388+
queue_placement_group = queue.networking.placement_group.name or queue.networking.placement_group.id
13891389
elif queue.networking.placement_group.enabled:
13901390
queue_placement_group = managed_placement_groups[queue.name].ref
13911391

cli/src/pcluster/validators/ec2_validators.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,27 @@ def _validate(self, key_name: str):
9999
)
100100

101101

102-
class PlacementGroupIdValidator(Validator): # TODO: add tests
103-
"""Placement group id validator."""
102+
class PlacementGroupNamingValidator(Validator): # TODO: add tests
103+
"""Placement group naming validator."""
104104

105105
def _validate(self, placement_group):
106-
if placement_group.id:
106+
if placement_group.id and placement_group.name:
107+
self._add_failure(
108+
"PlacementGroup Id cannot be set when setting PlacementGroup Name. Please "
109+
"set either Id or Name but not both.",
110+
FailureLevel.ERROR,
111+
)
112+
identifier = placement_group.name or placement_group.id
113+
if identifier:
107114
if not placement_group.is_implied("enabled") and not placement_group.enabled:
108115
self._add_failure(
109-
"PlacementGroup Id can not be set when setting 'Enabled: false' in queue's "
110-
"networking section. Please remove PlacementGroup Id if you don't want"
111-
" to use PlacementGroup.",
116+
"The PlacementGroup feature must be enabled (Enabled: true) in order "
117+
"to assign a Name or Id parameter",
112118
FailureLevel.ERROR,
113119
)
114120
else:
115121
try:
116-
AWSApi.instance().ec2.describe_placement_group(placement_group.id)
122+
AWSApi.instance().ec2.describe_placement_group(identifier)
117123
except AWSClientError as e:
118124
self._add_failure(str(e), FailureLevel.ERROR)
119125

cli/tests/pcluster/validators/test_ec2_validators.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
InstanceTypeMemoryInfoValidator,
2222
InstanceTypeValidator,
2323
KeyPairValidator,
24-
PlacementGroupIdValidator,
24+
PlacementGroupNamingValidator,
2525
)
2626
from tests.pcluster.aws.dummy_aws_api import mock_aws_api
2727
from tests.pcluster.validators.utils import assert_failure_messages
@@ -408,6 +408,16 @@ def test_compute_ami_os_compatible_validator(mocker, image_id, os, ami_info, exp
408408
None,
409409
None,
410410
),
411+
(
412+
PlacementGroup(enabled=True, name="test"),
413+
{
414+
"PlacementGroups": [
415+
{"GroupName": "test", "State": "available", "Strategy": "cluster", "GroupId": "pg-0123"}
416+
]
417+
},
418+
None,
419+
None,
420+
),
411421
(
412422
PlacementGroup(enabled=True),
413423
{
@@ -428,12 +438,28 @@ def test_compute_ami_os_compatible_validator(mocker, image_id, os, ami_info, exp
428438
None,
429439
None,
430440
),
441+
(
442+
PlacementGroup(name="test"),
443+
{
444+
"PlacementGroups": [
445+
{"GroupName": "test", "State": "available", "Strategy": "cluster", "GroupId": "pg-0123"}
446+
]
447+
},
448+
None,
449+
None,
450+
),
431451
(
432452
PlacementGroup(id="test"),
433453
None,
434454
AWSClientError(function_name="describe_placement_group", message="The Placement Group 'test' is unknown"),
435455
"The Placement Group 'test' is unknown",
436456
),
457+
(
458+
PlacementGroup(name="test"),
459+
None,
460+
AWSClientError(function_name="describe_placement_group", message="The Placement Group 'test' is unknown"),
461+
"The Placement Group 'test' is unknown",
462+
),
437463
(
438464
PlacementGroup(enabled=False, id="test"),
439465
{
@@ -442,7 +468,28 @@ def test_compute_ami_os_compatible_validator(mocker, image_id, os, ami_info, exp
442468
]
443469
},
444470
None,
445-
"PlacementGroup Id can not be set when setting",
471+
"The PlacementGroup feature must be enabled (Enabled: true) in order to assign a Name or Id parameter",
472+
),
473+
(
474+
PlacementGroup(enabled=False, name="test"),
475+
{
476+
"PlacementGroups": [
477+
{"GroupName": "test", "State": "available", "Strategy": "cluster", "GroupId": "pg-0123"}
478+
]
479+
},
480+
None,
481+
"The PlacementGroup feature must be enabled (Enabled: true) in order to assign a Name or Id parameter",
482+
),
483+
(
484+
PlacementGroup(enabled=True, id="test", name="test2"),
485+
{
486+
"PlacementGroups": [
487+
{"GroupName": "test", "State": "available", "Strategy": "cluster", "GroupId": "pg-0123"}
488+
]
489+
},
490+
None,
491+
"PlacementGroup Id cannot be set when setting PlacementGroup Name. Please "
492+
"set either Id or Name but not both.",
446493
),
447494
],
448495
)
@@ -455,5 +502,5 @@ def test_placement_group_validator(
455502
return_value=describe_placement_group_return,
456503
side_effect=side_effect,
457504
)
458-
actual_failures = PlacementGroupIdValidator().execute(placement_group=placement_group)
505+
actual_failures = PlacementGroupNamingValidator().execute(placement_group=placement_group)
459506
assert_failure_messages(actual_failures, expected_message)

cli/tests/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
assertpy
2+
aws-lambda-powertools
23
freezegun
34
jinja2
5+
munch
46
pytest
57
pytest-cov
68
pytest-datadir
79
pytest-html
810
pytest-mock
911
pytest-xdist
1012
recordclass
11-
munch

tests/integration-tests/benchmarks/test_scaling_performance/test_scaling_performance/pcluster.config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Scheduling:
1414
- Name: queue-0
1515
ComputeResources:
1616
- Name: compute-resource-0
17-
InstanceType: {{ instance }}
17+
InstanceTypeList:
18+
- InstanceType: {{ instance }}
1819
MaxCount: {{ scaling_target }}
1920
Networking:
2021
SubnetIds:

0 commit comments

Comments
 (0)