Skip to content

Commit d57fec0

Browse files
author
Himani Anil Deshpande
committed
Adding fetch_dna_files resource for HeadNode invocation of sharing and cleaning up dna.json and extra.json during an update
* Renaming the files and folders to cfn_hup_configuration * Deleting old recipie config_cfn_hup_spec.rb
1 parent ab09115 commit d57fec0

File tree

13 files changed

+50
-104
lines changed

13 files changed

+50
-104
lines changed

cookbooks/aws-parallelcluster-environment/resources/cfn_hup_configuration.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
end
4040

4141
template '/etc/cfn/cfn-hup.conf' do
42-
source 'cfn_hup/cfn-hup.conf.erb'
42+
source 'cfn_hup_configuration/cfn-hup.conf.erb'
4343
owner 'root'
4444
group 'root'
4545
mode '0400'
@@ -54,7 +54,7 @@
5454
action_extra_configuration
5555

5656
template '/etc/cfn/hooks.d/pcluster-update.conf' do
57-
source "cfn_hup/cfn-hook-update.conf.erb"
57+
source "cfn_hup_configuration/cfn-hook-update.conf.erb"
5858
owner 'root'
5959
group 'root'
6060
mode '0400'
@@ -73,7 +73,7 @@
7373
case node['cluster']['node_type']
7474
when 'HeadNode'
7575
cookbook_file "#{node['cluster']['scripts_dir']}/get_compute_user_data.py" do
76-
source 'cfn_hup/get_compute_user_data.py'
76+
source 'cfn_hup_configuration/get_compute_user_data.py'
7777
owner 'root'
7878
group 'root'
7979
mode '0755'
@@ -84,7 +84,7 @@
8484

8585
when 'ComputeFleet'
8686
template "#{node['cluster']['scripts_dir']}/cfn-hup-update-action.sh" do
87-
source "cfn_hup/#{node['cluster']['node_type']}/cfn-hup-update-action.sh.erb"
87+
source "cfn_hup_configuration/#{node['cluster']['node_type']}/cfn-hup-update-action.sh.erb"
8888
owner 'root'
8989
group 'root'
9090
mode '0744' # TODO: Change permission

cookbooks/aws-parallelcluster-environment/spec/unit/recipes/config_cfn_hup_spec.rb

Lines changed: 0 additions & 90 deletions
This file was deleted.

cookbooks/aws-parallelcluster-environment/spec/unit/resources/config_cfn_hup_spec.rb renamed to cookbooks/aws-parallelcluster-environment/spec/unit/resources/cfn_hup_configuration_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def self.configure(chef_run)
5656

5757
it "creates the file /etc/cfn/cfn-hup.conf" do
5858
is_expected.to create_template("/etc/cfn/cfn-hup.conf")
59-
.with(source: 'cfn_hup/cfn-hup.conf.erb')
59+
.with(source: 'cfn_hup_configuration/cfn-hup.conf.erb')
6060
.with(user: "root")
6161
.with(group: "root")
6262
.with(mode: "0400")
@@ -70,7 +70,7 @@ def self.configure(chef_run)
7070

7171
it "creates the file /etc/cfn/hooks.d/pcluster-update.conf" do
7272
is_expected.to create_template("/etc/cfn/hooks.d/pcluster-update.conf")
73-
.with(source: 'cfn_hup/cfn-hook-update.conf.erb')
73+
.with(source: 'cfn_hup_configuration/cfn-hook-update.conf.erb')
7474
.with(user: "root")
7575
.with(group: "root")
7676
.with(mode: "0400")
@@ -87,7 +87,7 @@ def self.configure(chef_run)
8787
if %(ComputeFleet).include?(node_type)
8888
it "creates the file #{SCRIPT_DIR}/cfn-hup-update-action.sh" do
8989
is_expected.to create_template("#{SCRIPT_DIR}/cfn-hup-update-action.sh")
90-
.with(source: "cfn_hup/#{node_type}/cfn-hup-update-action.sh.erb")
90+
.with(source: "cfn_hup_configuration/#{node_type}/cfn-hup-update-action.sh.erb")
9191
.with(user: "root")
9292
.with(group: "root")
9393
.with(mode: "0744")
@@ -99,7 +99,7 @@ def self.configure(chef_run)
9999
elsif node_type == 'HeadNode'
100100
it "creates #{SCRIPT_DIR}/get_compute_user_data.py" do
101101
is_expected.to create_if_missing_cookbook_file("#{SCRIPT_DIR}/get_compute_user_data.py")
102-
.with(source: 'cfn_hup/get_compute_user_data.py')
102+
.with(source: 'cfn_hup_configuration/get_compute_user_data.py')
103103
.with(user: 'root')
104104
.with(group: 'root')
105105
.with(mode: '0755')

cookbooks/aws-parallelcluster-platform/recipes/update.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
fetch_dna_files "Fetch ComputeFleet's Dna files"
1819
fetch_config 'Fetch and load cluster configs' do
1920
update true
2021
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
resource_name :fetch_dna_files
4+
provides :fetch_dna_files
5+
unified_mode true
6+
7+
default_action :share
8+
9+
action :share do
10+
return if on_docker?
11+
return unless node['cluster']['node_type'] == 'HeadNode'
12+
13+
Chef::Log.info("Share extra.json with ComputeFleet")
14+
::FileUtils.cp_r('/tmp/extra.json', "#{node['cluster']['shared_dir']}/dna/extra.json",remove_destination: true)
15+
16+
execute "Share dna.json with ComputeFleet" do
17+
command "#{cookbook_virtualenv_path}/bin/python #{node['cluster']['scripts_dir']}/get_compute_user_data.py" \
18+
" --region #{node['cluster']['region']}"
19+
timeout 30
20+
retries 10
21+
retry_delay 90
22+
end
23+
24+
end
25+
26+
action :cleanup do
27+
return if on_docker?
28+
return unless node['cluster']['node_type'] == 'HeadNode'
29+
30+
execute "Cleanup dna.json and extra.json from #{node['cluster']['shared_dir']}/dna" do
31+
command "#{cookbook_virtualenv_path}/bin/python #{node['cluster']['scripts_dir']}/get_compute_user_data.py" \
32+
" --region #{node['cluster']['region']} --cleanup"
33+
timeout 30
34+
retries 10
35+
retry_delay 90
36+
end
37+
end

0 commit comments

Comments
 (0)