Skip to content

Commit d2ea61e

Browse files
Fix custom cookbook not used after removing berk
This is a bug from #6909. In the PR, I tested custom cookbook setting didn't produce errors, but didn't test it was actually used. The custom cookbook was extracted wrongly to /tmp/cookbooks instead of /etc/chef. The new command is copied from the command in build-image process https://github.com/aws/aws-parallelcluster/blob/develop/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml#L200
1 parent a50a3af commit d2ea61e

File tree

5 files changed

+5
-13
lines changed

5 files changed

+5
-13
lines changed

cli/src/pcluster/resources/compute_node/user_data.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ write_files:
7878
}
7979
function vendor_cookbook
8080
{
81-
mkdir /tmp/cookbooks
82-
cd /tmp/cookbooks
83-
tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1
81+
cd /etc/chef && tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1 && rm -f aws-parallelcluster-cookbook.tgz
8482
}
8583

8684
function publish_startup_time

cli/src/pcluster/resources/head_node/user_data.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ function error_exit
7575
}
7676
function vendor_cookbook
7777
{
78-
mkdir /tmp/cookbooks
79-
cd /tmp/cookbooks
80-
tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1
78+
cd /etc/chef && tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1 && rm -f aws-parallelcluster-cookbook.tgz
8179
}
8280
[ -f /etc/profile.d/proxy.sh ] && . /etc/profile.d/proxy.sh
8381

cli/src/pcluster/resources/login_node/user_data.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ write_files:
6565
}
6666
function vendor_cookbook
6767
{
68-
mkdir /tmp/cookbooks
69-
cd /tmp/cookbooks
70-
tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1
68+
cd /etc/chef && tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1 && rm -f aws-parallelcluster-cookbook.tgz
7169
}
7270

7371
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin

cloudformation/external-slurmdbd/external-slurmdbd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@
434434
"UserData": {
435435
"Fn::Base64": {
436436
"Fn::Sub": [
437-
"Content-Type: multipart/mixed; boundary=\"==BOUNDARY==\"\nMIME-Version: 1.0\n\n--==BOUNDARY==\nContent-Type: text/cloud-config; charset=us-ascii\nMIME-Version: 1.0\n\npackage_update: false\npackage_upgrade: false\nrepo_upgrade: none\ndatasource_list: [ Ec2, None ]\n\n--==BOUNDARY==\nContent-Type: text/x-shellscript; charset=\"us-ascii\"\nMIME-Version: 1.0\n#!/bin/bash -x\n\nfunction vendor_cookbook\n{\n mkdir /tmp/cookbooks\n cd /tmp/cookbooks\n tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1\n}\n\nfunction wait_for_private_ip_assignment\n{\n rc=1\n retries=10\n retry=1\n sleeptime=1\n while [ \\( $rc -eq 1 \\) -a \\( $retry -le $retries \\) ]; do\n number_of_ips=$(curl -H \"X-aws-ec2-metadata-token: $TOKEN\" -v http://169.254.169.254/latest/meta-data/network/interfaces/macs/\"$MAC\"/local-ipv4s | wc -l)\n ((number_of_ips>0))\n rc=$?\n retry=$((retry+1))\n sleep $sleeptime\n done\n return $rc\n}\n\nTOKEN=`curl -X PUT \"http://169.254.169.254/latest/api/token\" -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\"`\nMAC=$(curl -H \"X-aws-ec2-metadata-token: $TOKEN\" -v http://169.254.169.254/latest/meta-data/mac)\nENI_ID=$(curl -H \"X-aws-ec2-metadata-token: $TOKEN\" -v http://169.254.169.254/latest/meta-data/network/interfaces/macs/\"$MAC\"/interface-id)\nDEVICE_NAME=$(ls /sys/class/net | grep e)\n\n# Configure AWS CLI using the expected overrides, if any.\n[ -f /etc/profile.d/aws-cli-default-config.sh ] && . /etc/profile.d/aws-cli-default-config.sh\n\naws ec2 assign-private-ip-addresses --region \"${AWS::Region}\" --network-interface-id \"${!ENI_ID}\" --private-ip-addresses ${PrivateIp} --allow-reassignment\n\nwait_for_private_ip_assignment || echo \"Assignment of private IP ${PrivateIp} was not successful.\"\n\nip addr add ${PrivateIp}/${SubnetPrefix} dev \"${!DEVICE_NAME}\"\n\nif [ \"${CustomCookbookUrl}\" != \"NONE\" ]; then\n curl --retry 3 -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${CustomCookbookUrl}\n vendor_cookbook\nfi\n\n# This is necessary to find the cfn-init application\nexport PATH=/opt/aws/bin:${!PATH}\n[ -f /etc/parallelcluster/pcluster_cookbook_environment.sh ] && . /etc/parallelcluster/pcluster_cookbook_environment.sh\n\n$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-init -s ${AWS::StackName} -v -c default -r LaunchTemplate --region \"${AWS::Region}\"\n",
437+
"Content-Type: multipart/mixed; boundary=\"==BOUNDARY==\"\nMIME-Version: 1.0\n\n--==BOUNDARY==\nContent-Type: text/cloud-config; charset=us-ascii\nMIME-Version: 1.0\n\npackage_update: false\npackage_upgrade: false\nrepo_upgrade: none\ndatasource_list: [ Ec2, None ]\n\n--==BOUNDARY==\nContent-Type: text/x-shellscript; charset=\"us-ascii\"\nMIME-Version: 1.0\n#!/bin/bash -x\n\nfunction vendor_cookbook\n{\n cd /etc/chef && tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1 && rm -f aws-parallelcluster-cookbook.tgz\n}\n\nfunction wait_for_private_ip_assignment\n{\n rc=1\n retries=10\n retry=1\n sleeptime=1\n while [ \\( $rc -eq 1 \\) -a \\( $retry -le $retries \\) ]; do\n number_of_ips=$(curl -H \"X-aws-ec2-metadata-token: $TOKEN\" -v http://169.254.169.254/latest/meta-data/network/interfaces/macs/\"$MAC\"/local-ipv4s | wc -l)\n ((number_of_ips>0))\n rc=$?\n retry=$((retry+1))\n sleep $sleeptime\n done\n return $rc\n}\n\nTOKEN=`curl -X PUT \"http://169.254.169.254/latest/api/token\" -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\"`\nMAC=$(curl -H \"X-aws-ec2-metadata-token: $TOKEN\" -v http://169.254.169.254/latest/meta-data/mac)\nENI_ID=$(curl -H \"X-aws-ec2-metadata-token: $TOKEN\" -v http://169.254.169.254/latest/meta-data/network/interfaces/macs/\"$MAC\"/interface-id)\nDEVICE_NAME=$(ls /sys/class/net | grep e)\n\n# Configure AWS CLI using the expected overrides, if any.\n[ -f /etc/profile.d/aws-cli-default-config.sh ] && . /etc/profile.d/aws-cli-default-config.sh\n\naws ec2 assign-private-ip-addresses --region \"${AWS::Region}\" --network-interface-id \"${!ENI_ID}\" --private-ip-addresses ${PrivateIp} --allow-reassignment\n\nwait_for_private_ip_assignment || echo \"Assignment of private IP ${PrivateIp} was not successful.\"\n\nip addr add ${PrivateIp}/${SubnetPrefix} dev \"${!DEVICE_NAME}\"\n\nif [ \"${CustomCookbookUrl}\" != \"NONE\" ]; then\n curl --retry 3 -v -L -o /etc/chef/aws-parallelcluster-cookbook.tgz ${CustomCookbookUrl}\n vendor_cookbook\nfi\n\n# This is necessary to find the cfn-init application\nexport PATH=/opt/aws/bin:${!PATH}\n[ -f /etc/parallelcluster/pcluster_cookbook_environment.sh ] && . /etc/parallelcluster/pcluster_cookbook_environment.sh\n\n$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-init -s ${AWS::StackName} -v -c default -r LaunchTemplate --region \"${AWS::Region}\"\n",
438438
{
439439
"CustomCookbookUrl": {
440440
"Ref": "CustomCookbookUrl"

cloudformation/external-slurmdbd/resources/user_data.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ MIME-Version: 1.0
1717

1818
function vendor_cookbook
1919
{
20-
mkdir /tmp/cookbooks
21-
cd /tmp/cookbooks
22-
tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1
20+
cd /etc/chef && tar -xzf /etc/chef/aws-parallelcluster-cookbook.tgz --strip-components 1 && rm -f aws-parallelcluster-cookbook.tgz
2321
}
2422

2523
function wait_for_private_ip_assignment

0 commit comments

Comments
 (0)