Skip to content

Commit 907e3ce

Browse files
authored
Merge pull request #139 from ravigurram8/topic-release-11
PCluster-AMI changes to support Spack
2 parents 68406ec + 3efb354 commit 907e3ce

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

products/PCluster/machine-images/config/infra/files/pcluster/Provision-pcluster.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ REGION=`wget -qO- http://instance-data/latest/meta-data/placement/availability-z
2626
aws ec2 describe-tags --region $REGION --filter "Name=resource-id,Values=$INSTANCE_ID" --query 'Tags[*].{Key:Key,Value:Value}' | jq -r '.[] | select( .Key as $a | ["cost_resource", "project_name","researcher_name"] | index($a) )' >> out.json
2727
jq -s '.' out.json >> valid.json
2828
echo "valid.json file is updated with Tags"
29-
yq eval -P valid.json > valid.yaml
29+
cat valid.json | yq -P > valid.yaml
3030
echo "Json file is converted to yaml"
3131
sed -i '1 i\Tags:' valid.yaml
3232
scheduler=$1
@@ -47,6 +47,7 @@ disableSimultaneousMultithreading=${16}
4747
efa=${17}
4848
placementGroup=${18}
4949
FileSystemType=${19}
50+
Nodeconfig=${20}
5051

5152
IFS='-' read -ra TRIMMED <<< "$CustomAMI"
5253
CustomAMIStartsWith=${TRIMMED[0]}
@@ -71,6 +72,7 @@ if [ "$scheduler" == "slurm" ]; then
7172
yq -i ".HeadNode.InstanceType=\"$headnodeinstancetype\"" slurm.yaml
7273
yq -i ".HeadNode.Networking.SubnetId=\"$headnodesubnetId\"" slurm.yaml
7374
yq -i ".HeadNode.Ssh.KeyName=\"$keyname\"" slurm.yaml
75+
yq -i ".HeadNode.CustomActions.OnNodeConfigured.Script=\"$Nodeconfig\"" slurm.yaml
7476
yq -i ".Scheduling.SlurmQueues[0].CapacityType=\"$QueueCapacityType\"" slurm.yaml
7577
yq -i ".Scheduling.SlurmQueues[0].ComputeResources[0].InstanceType=\"$computenodeinstancetype\"" slurm.yaml
7678
yq -i ".Scheduling.SlurmQueues[0].ComputeResources[0].MinCount=\"$minvpc\"" slurm.yaml
@@ -83,10 +85,10 @@ if [ "$scheduler" == "slurm" ]; then
8385
yq eval-all "select(fileIndex == 1) *+ select(fileIndex == 0)" valid.yaml slurm.yaml >> cluster-config-slurm.yaml
8486
echo "valid.yaml file and cluster-config.yaml file is merged into cluster-config-slurm.yaml"
8587
echo "Modified cluster-config-slurm.yaml with Tags"
86-
pcluster create-cluster --cluster-name $CLUSTER_NAME --cluster-configuration cluster-config-slurm.yaml
88+
pcluster create-cluster --cluster-name $CLUSTER_NAME --cluster-configuration cluster-config-slurm.yaml --region $Region
8789
else
8890
echo "batch.yaml exists"
89-
if [ "$CustomAMIStartsWith" == "ami" ]; then
91+
if [ "$CustomAMIStartsWith" == "ami" ]; then
9092
yq -i ".Image.CustomAmi=\"$CustomAMI\"" batch.yaml
9193
fi
9294
if [ "$FileSystemType" == "EFS" ] && [ "$FileSystemId" != "default" ]; then
@@ -101,6 +103,7 @@ else
101103
yq -i ".HeadNode.InstanceType=\"$headnodeinstancetype\"" batch.yaml
102104
yq -i ".HeadNode.Networking.SubnetId=\"$headnodesubnetId\"" batch.yaml
103105
yq -i ".HeadNode.Ssh.KeyName=\"$keyname\"" batch.yaml
106+
yq -i ".HeadNode.CustomActions.OnNodeConfigured.Script=\"$Nodeconfig\"" batch.yaml
104107
yq -i ".Scheduling.AwsBatchQueues[0].CapacityType=\"$QueueCapacityType\"" batch.yaml
105108
yq -i ".Scheduling.AwsBatchQueues[0].ComputeResources[0].InstanceTypes[0]=\"$computenodeinstancetype\"" batch.yaml
106109
yq -i ".Scheduling.AwsBatchQueues[0].ComputeResources[0].MinvCpus=\"$minvpc\"" batch.yaml
@@ -112,7 +115,7 @@ else
112115
yq eval-all "select(fileIndex == 1) *+ select(fileIndex == 0)" valid.yaml batch.yaml >> cluster-config-batch.yaml
113116
echo "valid.yaml file and cluster-config.yaml file is merged into cluster-config-batch.yaml"
114117
echo "Modified cluster-config-batch.yaml with Tags"
115-
pcluster create-cluster --cluster-name $CLUSTER_NAME --cluster-configuration cluster-config-batch.yaml
118+
pcluster create-cluster --cluster-name $CLUSTER_NAME --cluster-configuration cluster-config-batch.yaml --region $Region
116119

117120
fi
118121

products/PCluster/machine-images/config/infra/files/pcluster/batch-main.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ HeadNode:
1717
- Policy: arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
1818
CustomActions:
1919
OnNodeStart:
20-
Script: s3://tempbucket/bootstrap-scripts/pcluster-on-node-start.sh
20+
Script: s3://tempbucket/bootstrap-scripts/pcluster-on-node-start.sh
21+
OnNodeConfigured:
22+
Script:
2123
Imds:
2224
Secured: false
2325
Scheduling:

products/PCluster/machine-images/config/infra/files/pcluster/slurm-main.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ HeadNode:
1717
- Policy: arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
1818
CustomActions:
1919
OnNodeStart:
20-
Script: s3://tempbucket/bootstrap-scripts/pcluster-on-node-start.sh
20+
Script: s3://tempbucket/bootstrap-scripts/pcluster-on-node-start.sh
21+
OnNodeConfigured:
22+
Script:
2123
Scheduling:
2224
Scheduler: slurm
2325
SlurmQueues:

0 commit comments

Comments
 (0)