Skip to content

Commit 567b916

Browse files
authored
Merge branch 'aws:develop' into wip/group-test-starccm-and-openfoam
2 parents 00ca668 + 35899aa commit 567b916

File tree

17 files changed

+231
-12
lines changed

17 files changed

+231
-12
lines changed

.github/workflows/bump_version.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Bump Version workflow that is triggered manually
2+
name: Bump Version
3+
4+
on:
5+
workflow_dispatch:
6+
# Inputs the workflow accepts.
7+
inputs:
8+
pcluster-version:
9+
description: 'The target version of ParallelCluster CLI'
10+
required: true
11+
type: string
12+
branch:
13+
description: 'The Github branch name'
14+
required: true
15+
type: string
16+
17+
jobs:
18+
create-pull-requests:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
ref: ${{ inputs.branch }}
25+
- uses: actions/setup-java@v1
26+
with:
27+
java-version: 11
28+
- run: |
29+
sudo npm install -g redoc-cli
30+
sudo snap install yq
31+
- name: Modifiy Code to Change version
32+
run: ./util/bump-version.sh --version ${{ inputs.pcluster-version }}
33+
34+
- name: Create a Pull Request
35+
uses: peter-evans/create-pull-request@v6
36+
with:
37+
commit-message: 'Bump version to ${{ inputs.pcluster-version }}'
38+
title: 'Bump version to ${{ inputs.pcluster-version }}'
39+
body: |
40+
This PR contains version bump.
41+
Auto-generated by Github Action
42+
branch: versionbump${{ inputs.branch }}${{ inputs.pcluster-version }}
43+
delete-branch: true
44+
labels: skip-changelog-update
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Bump Version workflow that is triggered manually
2+
name: Bump Version for AWSBatch CLI
3+
4+
on:
5+
workflow_dispatch:
6+
# Inputs the workflow accepts.
7+
inputs:
8+
awsbatch-cli-version:
9+
description: 'The target version of AWSBatch CLI'
10+
required: true
11+
type: string
12+
branch:
13+
description: 'The Github branch name'
14+
required: true
15+
type: string
16+
17+
jobs:
18+
create-pull-requests:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
ref: ${{ inputs.branch }}
25+
- name: Modifiy Code to Change version
26+
run: ./util/bump-awsbatch-cli-version.sh ${{ inputs.awsbatch-cli-version }}
27+
28+
- name: Create a Pull Request
29+
uses: peter-evans/create-pull-request@v6
30+
with:
31+
commit-message: 'Bump version for awsbatch-cli to ${{ inputs.awsbatch-cli-version }}'
32+
title: 'Bump version for awsbatch-cli to ${{ inputs.awsbatch-cli-version }}'
33+
body: |
34+
This PR contains version bump for awsbatch-cli.
35+
Auto-generated by Github Action
36+
branch: versionbumpbatch${{ inputs.branch }}${{ inputs.awsbatch-cli-version }}
37+
delete-branch: true
38+
labels: skip-changelog-update

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
3.11.0
5+
------
6+
7+
**ENHANCEMENTS**
8+
9+
- Add support for custom actions on login nodes.
10+
411
3.10.0
512
------
613

cli/src/pcluster/config/cluster_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@ def __init__(
13461346
networking: LoginNodesNetworking = None,
13471347
count: int = None,
13481348
ssh: LoginNodesSsh = None,
1349+
custom_actions: CustomActions = None,
13491350
iam: LoginNodesIam = None,
13501351
gracetime_period: int = None,
13511352
**kwargs,
@@ -1357,6 +1358,7 @@ def __init__(
13571358
self.networking = networking
13581359
self.count = Resource.init_param(count, default=1)
13591360
self.ssh = ssh
1361+
self.custom_actions = custom_actions
13601362
self.iam = iam or LoginNodesIam(implied=True)
13611363
self.gracetime_period = Resource.init_param(gracetime_period, default=10)
13621364

cli/src/pcluster/schemas/cluster_schema.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,19 @@ def make_resource(self, data, **kwargs):
13151315
return CustomActions(**data)
13161316

13171317

1318+
class LoginNodesCustomActionsSchema(BaseSchema):
1319+
"""Represent the schema for all available custom actions in a login node pool."""
1320+
1321+
on_node_start = OneOrManyCustomActionField(metadata={"update_policy": UpdatePolicy.UNSUPPORTED})
1322+
on_node_configured = OneOrManyCustomActionField(metadata={"update_policy": UpdatePolicy.UNSUPPORTED})
1323+
on_node_updated = OneOrManyCustomActionField(metadata={"update_policy": UpdatePolicy.UNSUPPORTED})
1324+
1325+
@post_load
1326+
def make_resource(self, data, **kwargs):
1327+
"""Generate resource."""
1328+
return CustomActions(**data)
1329+
1330+
13181331
class InstanceTypeSchema(BaseSchema):
13191332
"""Schema of a compute resource that supports a pool of instance types."""
13201333

@@ -1422,6 +1435,7 @@ class LoginNodesPoolSchema(BaseSchema):
14221435
metadata={"update_policy": UpdatePolicy.SUPPORTED},
14231436
)
14241437
ssh = fields.Nested(LoginNodesSshSchema, metadata={"update_policy": UpdatePolicy.LOGIN_NODES_STOP})
1438+
custom_actions = fields.Nested(LoginNodesCustomActionsSchema, metadata={"update_policy": UpdatePolicy.IGNORED})
14251439
iam = fields.Nested(LoginNodesIamSchema, metadata={"update_policy": UpdatePolicy.LOGIN_NODES_STOP})
14261440
gracetime_period = fields.Int(
14271441
validate=validate.Range(

cli/src/pcluster/templates/cdk_builder_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,18 @@ def _build_policy(self) -> List[iam.PolicyStatement]:
934934
sid="CloudFormation",
935935
actions=[
936936
"cloudformation:DescribeStackResource",
937+
"cloudformation:DescribeStacks",
937938
],
938939
effect=iam.Effect.ALLOW,
939-
resources=[core.Aws.STACK_ID],
940+
resources=[
941+
self._format_arn(
942+
service="cloudformation",
943+
resource=f"stack/{Stack.of(self).stack_name}/*",
944+
region=Stack.of(self).region,
945+
account=Stack.of(self).account,
946+
),
947+
core.Aws.STACK_ID,
948+
],
940949
),
941950
iam.PolicyStatement(
942951
sid="DynamoDBTable",

cli/src/pcluster/templates/login_nodes_stack.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ def _add_login_nodes_pool_launch_template(self):
258258
"hosted_zone": (str(self._cluster_hosted_zone.ref) if self._cluster_hosted_zone else ""),
259259
"log_group_name": self._log_group.log_group_name,
260260
"log_rotation_enabled": "true" if self._config.is_log_rotation_enabled else "false",
261+
"pool_name": self._pool.name,
261262
"node_type": "LoginNode",
262263
"proxy": self._pool.networking.proxy.http_proxy_address if self._pool.networking.proxy else "NONE",
263264
"raid_shared_dir": to_comma_separated_string(

cli/tests/pcluster/example_configs/slurm.full.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ LoginNodes:
1717
- subnet-12345678
1818
Ssh:
1919
KeyName: ec2-key-name
20+
CustomActions:
21+
OnNodeStart:
22+
Script: https://test.tgz # s3:// | https://
23+
Args:
24+
- arg1
25+
- arg2
26+
OnNodeConfigured:
27+
Script: https://test.tgz # s3:// | https://
28+
Args:
29+
- arg1
30+
- arg2
31+
OnNodeUpdated:
32+
Script: https://test.tgz # s3:// | https://
33+
Args:
34+
- arg1
35+
- arg2
2036
Iam:
2137
InstanceRole: arn:aws:iam::aws:role/LoginNodeRole
2238
HeadNode:

cli/tests/pcluster/schemas/test_cluster_schema.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
HeadNodeIamSchema,
2626
HeadNodeRootVolumeSchema,
2727
ImageSchema,
28+
LoginNodesCustomActionsSchema,
2829
QueueCustomActionsSchema,
2930
QueueIamSchema,
3031
QueueTagSchema,
@@ -259,14 +260,18 @@ def test_head_node_root_volume_schema(mocker, config_dict, failure_message):
259260
),
260261
],
261262
)
262-
def test_head_node_custom_actions_schema(mocker, config_dict, failure_message):
263+
def test_head_login_node_custom_actions_schema(mocker, config_dict, failure_message):
263264
mock_aws_api(mocker)
264265
if failure_message:
265266
with pytest.raises(ValidationError, match=failure_message):
266267
HeadNodeCustomActionsSchema().load(config_dict)
268+
LoginNodesCustomActionsSchema().load(config_dict)
267269
else:
268-
conf = HeadNodeCustomActionsSchema().load(config_dict)
269-
HeadNodeCustomActionsSchema().dump(conf)
270+
head_conf = HeadNodeCustomActionsSchema().load(config_dict)
271+
login_conf = LoginNodesCustomActionsSchema().load(config_dict)
272+
273+
HeadNodeCustomActionsSchema().dump(head_conf)
274+
LoginNodesCustomActionsSchema().dump(login_conf)
270275

271276

272277
@pytest.mark.parametrize(

cli/tests/pcluster/templates/test_cluster_stack.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,11 +756,25 @@ def assert_iam_policy_properties(self, template, resource_name: str):
756756
"Sid": "Autoscaling",
757757
},
758758
{
759-
"Action": "cloudformation:DescribeStackResource",
759+
"Action": ["cloudformation:DescribeStackResource", "cloudformation:DescribeStacks"],
760760
"Effect": "Allow",
761-
"Resource": {
762-
"Ref": "AWS::StackId",
763-
},
761+
"Resource": [
762+
{
763+
"Fn::Join": [
764+
"",
765+
[
766+
"arn:",
767+
{"Ref": "AWS::Partition"},
768+
":cloudformation:",
769+
{"Ref": "AWS::Region"},
770+
":",
771+
{"Ref": "AWS::AccountId"},
772+
":stack/clustername/*",
773+
],
774+
]
775+
},
776+
{"Ref": "AWS::StackId"},
777+
],
764778
"Sid": "CloudFormation",
765779
},
766780
{

cli/tests/pcluster/templates/test_cluster_stack/test_cluster_config_limits/slurm.full.all_resources.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ LoginNodes:
2020
HttpProxyAddress: https://proxy-address:port
2121
Ssh:
2222
KeyName: validate_key_name
23+
CustomActions:
24+
OnNodeStart:
25+
Script: https://test.tgz
26+
Args:
27+
# Number of args doesn't impact number of resources, just the size of the template
28+
{% for i in range(number_of_script_args) %}
29+
- arg{{ i }}
30+
{% endfor %}
31+
OnNodeConfigured:
32+
Script: https://test.tgz
33+
Args:
34+
{% for i in range(number_of_script_args) %}
35+
- arg{{ i }}
36+
{% endfor %}
37+
OnNodeUpdated:
38+
Script: https://test.tgz
39+
Args:
40+
{% for i in range(number_of_script_args) %}
41+
- arg{{ i }}
42+
{% endfor %}
2343
Iam:
2444
AdditionalIamPolicies:
2545
- Policy: arn:aws:iam::aws:policy/AdministratorAccess

cli/tests/pcluster/templates/test_cluster_stack/test_cluster_config_limits/slurm.full_config.snapshot.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ Imds:
8787
LoginNodes:
8888
Pools:
8989
- Count: 1
90+
CustomActions:
91+
OnNodeConfigured:
92+
Args:
93+
- arg0
94+
Script: https://test.tgz
95+
OnNodeStart:
96+
Args:
97+
- arg0
98+
Script: https://test.tgz
99+
OnNodeUpdated:
100+
Args:
101+
- arg0
102+
Script: https://test.tgz
90103
GracetimePeriod: 10
91104
Iam:
92105
AdditionalIamPolicies:

cli/tests/pcluster/templates/test_login_nodes_stack/test_login_nodes_dna_json/dna-1.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"hosted_zone": "{\"Ref\": \"referencetoclusternameRoute53HostedZone2388733DRef\"}",
3535
"log_group_name": "/aws/parallelcluster/clustername-202401151530",
3636
"log_rotation_enabled": "true",
37+
"pool_name": "login",
3738
"node_type": "LoginNode",
3839
"proxy": "NONE",
3940
"raid_shared_dir": "",

cli/tests/pcluster/templates/test_login_nodes_stack/test_login_nodes_dna_json/dna-2.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"hosted_zone": "{\"Ref\": \"referencetoclusternameRoute53HostedZone2388733DRef\"}",
3535
"log_group_name": "/aws/parallelcluster/clustername-202401151530",
3636
"log_rotation_enabled": "true",
37+
"pool_name": "login",
3738
"node_type": "LoginNode",
3839
"proxy": "NONE",
3940
"raid_shared_dir": "",

tests/integration-tests/tests/basic/test_essential_features.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,13 @@ def _test_custom_bootstrap_scripts_args_quotes(cluster):
321321
The cluster should be created and running.
322322
"""
323323
# Check head node and compute node status
324-
check_status(cluster, "CREATE_COMPLETE", head_node_status="running", compute_fleet_status="RUNNING")
324+
check_status(
325+
cluster,
326+
"CREATE_COMPLETE",
327+
head_node_status="running",
328+
compute_fleet_status="RUNNING",
329+
login_nodes_status="active",
330+
)
325331

326332

327333
def _test_disable_hyperthreading(

tests/integration-tests/tests/basic/test_essential_features/test_essential_features/pcluster.config.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ HeadNode:
2828
Dcv:
2929
Enabled: True
3030
{% endif %}
31+
LoginNodes:
32+
Pools:
33+
- Name: pool
34+
InstanceType: {{ instance }}
35+
Count: 3
36+
Networking:
37+
SubnetIds:
38+
- {{ private_subnet_id }}
39+
CustomActions:
40+
OnNodeStart:
41+
Script: s3://{{ bucket_name }}/scripts/pre_install.sh
42+
Args:
43+
- "R curl wget"
44+
- arg2
45+
- 'arg3 arg3'
46+
OnNodeConfigured:
47+
Script: s3://{{ bucket_name }}/scripts/post_install.sh
48+
Args:
49+
- "R curl wget"
50+
- arg2
51+
- 'arg3 arg3'
52+
Iam:
53+
AdditionalIamPolicies:
54+
- Policy: "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess"
3155
Scheduling:
3256
Scheduler: {{ scheduler }}
3357
{% if scheduler == "awsbatch" %}AwsBatchQueues:{% else %}SlurmQueues:{% endif %}
@@ -130,4 +154,4 @@ Monitoring:
130154
SharedStorage:
131155
- MountDir: /shared
132156
Name: name1
133-
StorageType: Ebs
157+
StorageType: Ebs

tests/integration-tests/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,19 @@ def check_head_node_security_group(region, cluster, port, expected_cidr):
563563
assert_that(target["IpRanges"][0]["CidrIp"]).is_equal_to(expected_cidr)
564564

565565

566-
def check_status(cluster, cluster_status=None, head_node_status=None, compute_fleet_status=None):
567-
"""Check the cluster's status and its head and compute status is as expected."""
566+
def check_status(
567+
cluster, cluster_status=None, head_node_status=None, compute_fleet_status=None, login_nodes_status=None
568+
):
569+
"""Check the cluster's status and its head, compute, and login nodes statuses are as expected."""
568570
cluster_info = cluster.describe_cluster()
569571
if cluster_status:
570572
assert_that(cluster_info["clusterStatus"]).is_equal_to(cluster_status)
571573
if head_node_status:
572574
assert_that(cluster_info["headNode"]["state"]).is_equal_to(head_node_status)
573575
if compute_fleet_status:
574576
assert_that(cluster_info["computeFleetStatus"]).is_equal_to(compute_fleet_status)
577+
if login_nodes_status:
578+
assert_that(cluster_info["loginNodes"]["status"]).is_equal_to(login_nodes_status)
575579

576580

577581
@retry(wait_fixed=seconds(20), stop_max_delay=minutes(5))

0 commit comments

Comments
 (0)