Skip to content

Commit

Permalink
Removing usage of /etc/profile.d/pcluster.sh (#6266)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
himani2411 and Himani Deshpande committed Jun 10, 2024
1 parent 754d04b commit aeb87fc
Show file tree
Hide file tree
Showing 10 changed files with 593 additions and 590 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ CHANGELOG
This is to avoid cluster deletion failure for instance types with longer termination cycles.
- Allow cloudwatch dashboard to be enabled and alarms to be disabled in the `Monitoring` section of the cluster config.
- Allow ParallelCluster Custom Resource to suppress validators using `PclusterCluster/SuppressValidators`.
- Removing `/etc/profile.d/pcluster.sh` so that it's not executed at every user login and
`cfn_bootstrap_virtualenv` is not added in PATH environment variable.

**CHANGES**
- Upgrade Cinc Client to version to 18.4.12 from 18.2.7.
Expand Down
4 changes: 2 additions & 2 deletions cli/src/pcluster/resources/compute_node/user_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ write_files:

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

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

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.'
$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.'

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

Expand Down
10 changes: 5 additions & 5 deletions cli/src/pcluster/resources/head_node/user_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function error_exit
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html
cutoff=$(expr 4096 - $(stat --printf="%s" /tmp/wait_condition_handle.txt))
reason=$(head --bytes=${!cutoff} /var/log/parallelcluster/bootstrap_error_msg 2>/dev/null) || reason="$1"
cfn-signal --exit-code=1 --reason="${!reason}" "${!wait_condition_handle_presigned_url}" --region ${AWS::Region} --url ${CloudFormationUrl}
$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-signal --exit-code=1 --reason="${!reason}" "${!wait_condition_handle_presigned_url}" --region ${AWS::Region} --url ${CloudFormationUrl}
exit 1
}
function vendor_cookbook
Expand All @@ -94,10 +94,10 @@ function vendor_cookbook
# deploy config files
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin
# Load ParallelCluster environment variables
[ -f /etc/profile.d/pcluster.sh ] && . /etc/profile.d/pcluster.sh
[ -f /etc/parallelcluster/pcluster_cookbook_environment.sh ] && . /etc/parallelcluster/pcluster_cookbook_environment.sh

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

custom_cookbook=${CustomChefCookbook}
Expand Down Expand Up @@ -134,7 +134,7 @@ if [ "${!custom_cookbook}" != "NONE" ]; then
fi

# Call CloudFormation
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.'
cfn-signal --exit-code=0 --reason="HeadNode setup complete" "${!wait_condition_handle_presigned_url}" --region ${AWS::Region} --url ${CloudFormationUrl}
$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.'
$CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-signal --exit-code=0 --reason="HeadNode setup complete" "${!wait_condition_handle_presigned_url}" --region ${AWS::Region} --url ${CloudFormationUrl}
# End of file
--==BOUNDARY==
4 changes: 2 additions & 2 deletions cli/src/pcluster/resources/login_node/user_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ write_files:

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

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.'
$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.'

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

Expand Down
6 changes: 3 additions & 3 deletions cli/src/pcluster/templates/cluster_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,16 +1460,16 @@ def _add_head_node(self):
"commands": {
"chef": {
"command": (
". /etc/profile.d/pcluster.sh; "
". /etc/parallelcluster/pcluster_cookbook_environment.sh; "
"cinc-client --local-mode --config /etc/chef/client.rb --log_level info"
" --logfile /var/log/chef-client.log --force-formatter --no-color"
" --chef-zero-port 8889 --json-attributes /etc/chef/dna.json"
" --override-runlist aws-parallelcluster-entrypoints::update &&"
" /opt/parallelcluster/scripts/fetch_and_run -postupdate &&"
f" cfn-signal --exit-code=0 --reason='Update complete'"
f" $CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-signal --exit-code=0 --reason='Update complete'"
f" --region {self.stack.region} --url {cloudformation_url}"
f" '{self.wait_condition_handle.ref}' ||"
f" cfn-signal --exit-code=1 --reason='Update failed'"
f" $CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-signal --exit-code=1 --reason='Update failed'"
f" --region {self.stack.region} --url {cloudformation_url}"
f" '{self.wait_condition_handle.ref}'"
),
Expand Down
2 changes: 1 addition & 1 deletion cli/src/pcluster/templates/login_nodes_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _add_login_nodes_pool_launch_template(self):
"commands": {
"chef": {
"command": (
". /etc/profile.d/pcluster.sh; "
". /etc/parallelcluster/pcluster_cookbook_environment.sh; "
"cinc-client --local-mode --config /etc/chef/client.rb --log_level info"
" --logfile /var/log/chef-client.log --force-formatter --no-color"
" --chef-zero-port 8889 --json-attributes /etc/chef/dna.json"
Expand Down
2 changes: 1 addition & 1 deletion cli/src/pcluster/templates/queues_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def _add_compute_resource_launch_template(
"commands": {
"chef": {
"command": (
". /etc/profile.d/pcluster.sh; "
". /etc/parallelcluster/pcluster_cookbook_environment.sh; "
"cinc-client --local-mode --config /etc/chef/client.rb --log_level info"
" --logfile /var/log/chef-client.log --force-formatter --no-color"
" --chef-zero-port 8889 --json-attributes /etc/chef/dna.json"
Expand Down
Loading

0 comments on commit aeb87fc

Please sign in to comment.