Skip to content

Commit ec146d3

Browse files
author
Nicolas Malaval
committed
Added support of sequences in tag values
1 parent e2b6271 commit ec146d3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ This JSON file specifies the groups of nodes and associated partitions that Slur
146146
* `LaunchTemplateOverrides`: Must be filled in the same way then the object of the same name in the [EC2 CreateFleet API](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.create_fleet). Do not populate the field `SubnetId` in template overrides.
147147
* `SubnetIds`: List of subnets where EC2 instances can be launched for this node group. If you provide multiple subnets, they must be in different availability zones.
148148
* `Tags`: List of tags applied to the EC2 instances launched for this node group.
149+
* A tag `Name` is automatically added at launch, whose value is the name of the node `[partition_name]-[nodegroup_name][id]`. You should not delete or override this tag, because the script `suspend.py` uses it to find which instance is associated with the node to suspend.
150+
* You use the sequence `{ip_address}` in the value of tag, it will be replaced with the IP address. Similarly, `{node_name}` will be replaced with the name of the node, `{hostname}` with the EC2 hostname.
149151

150152
Refer to the section **Examples of `partitions.json`** for examples of file content.
151153

resume.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,23 @@ def retry(func, *args, **kwargs):
129129
tags = [
130130
{
131131
'Key': 'Name',
132-
'Value': node_name
132+
'Value': '{node_name}'
133133
}
134134
]
135135
if 'Tags' in nodegroup:
136136
tags += nodegroup['Tags']
137+
138+
# Replace the following sequences with context values
139+
# For example, replace {ip_address} with the private IP address
140+
sequences = (
141+
('{ip_address}', ip_address),
142+
('{node_name}', node_name),
143+
('{hostname}', hostname)
144+
)
145+
for tag in tags:
146+
for sequence in sequences:
147+
tag['Value'] = tag['Value'].replace(*sequence)
148+
137149
try:
138150
request_tags = {
139151
'Resources': [instance_id],

0 commit comments

Comments
 (0)