From 26a3c9d69f8df36de946d993cba73305116a47aa Mon Sep 17 00:00:00 2001 From: Himani Anil Deshpande <79726937+himani2411@users.noreply.github.com> Date: Wed, 22 May 2024 10:29:35 -0400 Subject: [PATCH] Changing the PATH order we set for using the cfnbootstrap script we have installed in virtualenv rather than using default scripts (#2730) * Adding Kitchen test to verify the PATH used for cfn-init is the one we have installed using virtualenv Co-authored-by: Himani Deshpande --- .../templates/cfn_bootstrap/pcluster.sh.erb | 3 +-- .../test/controls/cfn_bootstrap_spec.rb | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cookbooks/aws-parallelcluster-environment/templates/cfn_bootstrap/pcluster.sh.erb b/cookbooks/aws-parallelcluster-environment/templates/cfn_bootstrap/pcluster.sh.erb index 0f23d9c48..f9e2309c6 100644 --- a/cookbooks/aws-parallelcluster-environment/templates/cfn_bootstrap/pcluster.sh.erb +++ b/cookbooks/aws-parallelcluster-environment/templates/cfn_bootstrap/pcluster.sh.erb @@ -2,7 +2,6 @@ # pcluster.sh: # Setup ParallelCluster environment variables # - -PATH=$PATH:<%= @cfn_bootstrap_virtualenv_path %>/bin +PATH=<%= @cfn_bootstrap_virtualenv_path %>/bin:$PATH export PATH diff --git a/cookbooks/aws-parallelcluster-environment/test/controls/cfn_bootstrap_spec.rb b/cookbooks/aws-parallelcluster-environment/test/controls/cfn_bootstrap_spec.rb index d48629c3d..20a83960d 100644 --- a/cookbooks/aws-parallelcluster-environment/test/controls/cfn_bootstrap_spec.rb +++ b/cookbooks/aws-parallelcluster-environment/test/controls/cfn_bootstrap_spec.rb @@ -36,6 +36,12 @@ its('mode') { should cmp '0644' } its('owner') { should eq 'root' } its('group') { should eq 'root' } - its('content') { should match "PATH=\\$PATH:#{pyenv_dir}/versions/#{cfn_python_version}/envs/cfn_bootstrap_virtualenv/bin" } + its('content') { should match "PATH=#{pyenv_dir}/versions/#{cfn_python_version}/envs/cfn_bootstrap_virtualenv/bin:\\$PATH" } end + + desc "cfn-init needs to be from the cfnbootstrap virtualenv" + describe bash("sudo -u #{node['cluster']['cluster_user']} -i which cfn-init") do + its('exit_status') { should eq(0) } + its('stdout') { should match("#{pyenv_dir}/versions/#{cfn_python_version}/envs/cfn_bootstrap_virtualenv/bin/cfn-init") } + end unless os_properties.on_docker? end