Skip to content

Commit aeb87fc

Browse files
himani2411Himani Deshpande
andauthored
Removing usage of /etc/profile.d/pcluster.sh (aws#6266)
* Replacing `/etc/profile.d/pcluster.sh` with `/etc/parallelcluster/pcluster_cookbook_environment.sh` * Using cfn_bootstrap_virtualenv_path directly for cfn commands * Add missing import statement for test_update --------- Co-authored-by: Himani Deshpande <[email protected]>
1 parent 754d04b commit aeb87fc

File tree

10 files changed

+593
-590
lines changed

10 files changed

+593
-590
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ CHANGELOG
1414
This is to avoid cluster deletion failure for instance types with longer termination cycles.
1515
- Allow cloudwatch dashboard to be enabled and alarms to be disabled in the `Monitoring` section of the cluster config.
1616
- Allow ParallelCluster Custom Resource to suppress validators using `PclusterCluster/SuppressValidators`.
17+
- Removing `/etc/profile.d/pcluster.sh` so that it's not executed at every user login and
18+
`cfn_bootstrap_virtualenv` is not added in PATH environment variable.
1719

1820
**CHANGES**
1921
- Upgrade Cinc Client to version to 18.4.12 from 18.2.7.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ write_files:
9595

9696
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin
9797

98-
[ -f /etc/profile.d/pcluster.sh ] && . /etc/profile.d/pcluster.sh
98+
[ -f /etc/parallelcluster/pcluster_cookbook_environment.sh ] && . /etc/parallelcluster/pcluster_cookbook_environment.sh
9999

100-
cfn-init -s ${AWS::StackName} -v -c deployFiles -r ${LaunchTemplateResourceId} --region ${AWS::Region} --url ${CloudFormationUrl} --role ${CfnInitRole} || error_exit 'Failed to bootstrap the compute node. Please check /var/log/cfn-init.log in the compute node or in CloudWatch logs. Please refer to https://docs.aws.amazon.com/parallelcluster/latest/ug/troubleshooting-v3.html#troubleshooting-v3-get-logs for more details on ParallelCluster logs.'
100+
$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-init -s ${AWS::StackName} -v -c deployFiles -r ${LaunchTemplateResourceId} --region ${AWS::Region} --url ${CloudFormationUrl} --role ${CfnInitRole} || error_exit 'Failed to bootstrap the compute node. Please check /var/log/cfn-init.log in the compute node or in CloudWatch logs. Please refer to https://docs.aws.amazon.com/parallelcluster/latest/ug/troubleshooting-v3.html#troubleshooting-v3-get-logs for more details on ParallelCluster logs.'
101101

102102
[ -f /etc/profile.d/proxy.sh ] && . /etc/profile.d/proxy.sh
103103

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function error_exit
7070
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html
7171
cutoff=$(expr 4096 - $(stat --printf="%s" /tmp/wait_condition_handle.txt))
7272
reason=$(head --bytes=${!cutoff} /var/log/parallelcluster/bootstrap_error_msg 2>/dev/null) || reason="$1"
73-
cfn-signal --exit-code=1 --reason="${!reason}" "${!wait_condition_handle_presigned_url}" --region ${AWS::Region} --url ${CloudFormationUrl}
73+
$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-signal --exit-code=1 --reason="${!reason}" "${!wait_condition_handle_presigned_url}" --region ${AWS::Region} --url ${CloudFormationUrl}
7474
exit 1
7575
}
7676
function vendor_cookbook
@@ -94,10 +94,10 @@ function vendor_cookbook
9494
# deploy config files
9595
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin
9696
# Load ParallelCluster environment variables
97-
[ -f /etc/profile.d/pcluster.sh ] && . /etc/profile.d/pcluster.sh
97+
[ -f /etc/parallelcluster/pcluster_cookbook_environment.sh ] && . /etc/parallelcluster/pcluster_cookbook_environment.sh
9898

9999
cd /tmp
100-
cfn-init -s ${AWS::StackName} -v -c deployFiles -r HeadNodeLaunchTemplate --region ${AWS::Region} --url ${CloudFormationUrl}
100+
$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-init -s ${AWS::StackName} -v -c deployFiles -r HeadNodeLaunchTemplate --region ${AWS::Region} --url ${CloudFormationUrl}
101101
wait_condition_handle_presigned_url=$(cat /tmp/wait_condition_handle.txt)
102102

103103
custom_cookbook=${CustomChefCookbook}
@@ -134,7 +134,7 @@ if [ "${!custom_cookbook}" != "NONE" ]; then
134134
fi
135135

136136
# Call CloudFormation
137-
cfn-init -s ${AWS::StackName} -v -c default -r HeadNodeLaunchTemplate --region ${AWS::Region} --url ${CloudFormationUrl} || error_exit 'Failed to bootstrap the head node. Please check /var/log/cfn-init.log and /var/log/chef-client.log in the head node or in CloudWatch logs. Please refer to https://docs.aws.amazon.com/parallelcluster/latest/ug/troubleshooting-v3.html#troubleshooting-v3-get-logs for more details on ParallelCluster logs.'
138-
cfn-signal --exit-code=0 --reason="HeadNode setup complete" "${!wait_condition_handle_presigned_url}" --region ${AWS::Region} --url ${CloudFormationUrl}
137+
$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-init -s ${AWS::StackName} -v -c default -r HeadNodeLaunchTemplate --region ${AWS::Region} --url ${CloudFormationUrl} || error_exit 'Failed to bootstrap the head node. Please check /var/log/cfn-init.log and /var/log/chef-client.log in the head node or in CloudWatch logs. Please refer to https://docs.aws.amazon.com/parallelcluster/latest/ug/troubleshooting-v3.html#troubleshooting-v3-get-logs for more details on ParallelCluster logs.'
138+
$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-signal --exit-code=0 --reason="HeadNode setup complete" "${!wait_condition_handle_presigned_url}" --region ${AWS::Region} --url ${CloudFormationUrl}
139139
# End of file
140140
--==BOUNDARY==

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ write_files:
7979

8080
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin
8181
# Load ParallelCluster environment variables
82-
[ -f /etc/profile.d/pcluster.sh ] && . /etc/profile.d/pcluster.sh
82+
[ -f /etc/parallelcluster/pcluster_cookbook_environment.sh ] && . /etc/parallelcluster/pcluster_cookbook_environment.sh
8383

84-
cfn-init -s ${AWS::StackName} -v -c deployFiles -r ${LaunchTemplateResourceId} --region ${AWS::Region} --url ${CloudFormationUrl} --role ${CfnInitRole} || error_exit 'Failed to bootstrap the login node. Please check /var/log/cfn-init.log in the login node or in CloudWatch logs. Please refer to https://docs.aws.amazon.com/parallelcluster/latest/ug/troubleshooting-v3.html#troubleshooting-v3-get-logs for more details on ParallelCluster logs.'
84+
$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-init -s ${AWS::StackName} -v -c deployFiles -r ${LaunchTemplateResourceId} --region ${AWS::Region} --url ${CloudFormationUrl} --role ${CfnInitRole} || error_exit 'Failed to bootstrap the login node. Please check /var/log/cfn-init.log in the login node or in CloudWatch logs. Please refer to https://docs.aws.amazon.com/parallelcluster/latest/ug/troubleshooting-v3.html#troubleshooting-v3-get-logs for more details on ParallelCluster logs.'
8585

8686
[ -f /etc/profile.d/proxy.sh ] && . /etc/profile.d/proxy.sh
8787

cli/src/pcluster/templates/cluster_stack.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,16 +1460,16 @@ def _add_head_node(self):
14601460
"commands": {
14611461
"chef": {
14621462
"command": (
1463-
". /etc/profile.d/pcluster.sh; "
1463+
". /etc/parallelcluster/pcluster_cookbook_environment.sh; "
14641464
"cinc-client --local-mode --config /etc/chef/client.rb --log_level info"
14651465
" --logfile /var/log/chef-client.log --force-formatter --no-color"
14661466
" --chef-zero-port 8889 --json-attributes /etc/chef/dna.json"
14671467
" --override-runlist aws-parallelcluster-entrypoints::update &&"
14681468
" /opt/parallelcluster/scripts/fetch_and_run -postupdate &&"
1469-
f" cfn-signal --exit-code=0 --reason='Update complete'"
1469+
f" $CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-signal --exit-code=0 --reason='Update complete'"
14701470
f" --region {self.stack.region} --url {cloudformation_url}"
14711471
f" '{self.wait_condition_handle.ref}' ||"
1472-
f" cfn-signal --exit-code=1 --reason='Update failed'"
1472+
f" $CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-signal --exit-code=1 --reason='Update failed'"
14731473
f" --region {self.stack.region} --url {cloudformation_url}"
14741474
f" '{self.wait_condition_handle.ref}'"
14751475
),

cli/src/pcluster/templates/login_nodes_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def _add_login_nodes_pool_launch_template(self):
328328
"commands": {
329329
"chef": {
330330
"command": (
331-
". /etc/profile.d/pcluster.sh; "
331+
". /etc/parallelcluster/pcluster_cookbook_environment.sh; "
332332
"cinc-client --local-mode --config /etc/chef/client.rb --log_level info"
333333
" --logfile /var/log/chef-client.log --force-formatter --no-color"
334334
" --chef-zero-port 8889 --json-attributes /etc/chef/dna.json"

cli/src/pcluster/templates/queues_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def _add_compute_resource_launch_template(
439439
"commands": {
440440
"chef": {
441441
"command": (
442-
". /etc/profile.d/pcluster.sh; "
442+
". /etc/parallelcluster/pcluster_cookbook_environment.sh; "
443443
"cinc-client --local-mode --config /etc/chef/client.rb --log_level info"
444444
" --logfile /var/log/chef-client.log --force-formatter --no-color"
445445
" --chef-zero-port 8889 --json-attributes /etc/chef/dna.json"

0 commit comments

Comments
 (0)