Skip to content

Commit 5d08ca9

Browse files
author
Himani Deshpande
committed
Configure Pyxis during AMI build Phase
* Replacing sed commands with templates * Replacing creation of directories with chef resource * Adding Chef Attributes for enabling Pyxis * Changing Kitchen test for Enroot and Pyxis
1 parent 8aeba2c commit 5d08ca9

File tree

8 files changed

+128
-43
lines changed

8 files changed

+128
-43
lines changed

cookbooks/aws-parallelcluster-platform/resources/enroot/partial/_enroot_common.rb

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,38 @@
1818
action :setup do
1919
return if on_docker?
2020
action_install_package
21-
end
22-
23-
action :configure do
24-
return if on_docker?
25-
return unless enroot_installed
2621

27-
cookbook_file "/tmp/enroot.template.conf" do
28-
source 'enroot/enroot.template.conf'
29-
cookbook 'aws-parallelcluster-platform'
22+
directory node['cluster']['enroot_dir'] do
3023
owner 'root'
3124
group 'root'
3225
mode '0755'
33-
action :create_if_missing
26+
action :create
3427
end
3528

36-
bash "Configure enroot" do
37-
user 'root'
38-
code <<-ENROOT_CONFIGURE
39-
set -e
40-
ENROOT_CONFIG_RELEASE=pyxis
41-
SHARED_DIR=#{node['cluster']['shared_dir']}
42-
NONROOT_USER=#{node['cluster']['cluster_user']}
43-
mkdir -p ${SHARED_DIR}/enroot
44-
chown ${NONROOT_USER} ${SHARED_DIR}/enroot
45-
ENROOT_CACHE_PATH=${SHARED_DIR}/enroot envsubst < /tmp/enroot.template.conf > /tmp/enroot.conf
46-
mv /tmp/enroot.conf /etc/enroot/enroot.conf
47-
chmod 0644 /etc/enroot/enroot.conf
48-
49-
mkdir -p /tmp/enroot
50-
chmod 1777 /tmp/enroot
51-
mkdir -p /tmp/enroot/data
52-
chmod 1777 /tmp/enroot/data
29+
directory node['cluster']['enroot_cache_path'] do
30+
owner 'root'
31+
group 'root'
32+
mode '0755'
33+
action :create
34+
end
5335

54-
chmod 1777 ${SHARED_DIR}/enroot
36+
directory "/tmp/enroot" do
37+
mode '1777'
38+
action :create
39+
end
5540

56-
mkdir -p ${SHARED_DIR}/pyxis/
57-
chown ${NONROOT_USER} ${SHARED_DIR}/pyxis/
58-
sed -i '${s/$/ runtime_path=${SHARED_DIR}\\/pyxis/}' /opt/slurm/etc/plugstack.conf.d/pyxis.conf
59-
SHARED_DIR=${SHARED_DIR} envsubst < /opt/slurm/etc/plugstack.conf.d/pyxis.conf > /opt/slurm/etc/plugstack.conf.d/pyxis.tmp.conf
60-
mv /opt/slurm/etc/plugstack.conf.d/pyxis.tmp.conf /opt/slurm/etc/plugstack.conf.d/pyxis.conf
41+
directory "/tmp/enroot/data" do
42+
mode '1777'
43+
action :create
44+
end
6145

62-
ENROOT_CONFIGURE
63-
retries 3
64-
retry_delay 5
46+
template "/etc/enroot/enroot.conf" do
47+
source 'enroot/enroot.conf.erb'
48+
cookbook 'aws-parallelcluster-platform'
49+
owner 'root'
50+
group 'root'
51+
mode '0644'
52+
action :create
6553
end
6654
end
6755

cookbooks/aws-parallelcluster-platform/files/enroot/enroot.template.conf renamed to cookbooks/aws-parallelcluster-platform/templates/enroot/enroot.conf.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ENROOT_LIBRARY_PATH /usr/lib/enroot
22
#ENROOT_SYSCONF_PATH /etc/enroot
33
ENROOT_RUNTIME_PATH /tmp/enroot/user-$(id -u)
4-
ENROOT_CONFIG_PATH ${ENROOT_CONFIG_PATH}
5-
ENROOT_CACHE_PATH ${ENROOT_CACHE_PATH}
4+
ENROOT_CONFIG_PATH
5+
ENROOT_CACHE_PATH <%= node['cluster']['enroot_cache_path'] %>
66
ENROOT_DATA_PATH /tmp/enroot/data/user-$(id -u)
77
#ENROOT_TEMP_PATH ${TMPDIR:-/tmp}
88

@@ -68,4 +68,4 @@ ENROOT_RESTRICT_DEV no
6868
#all_proxy
6969
#no_proxy
7070
#http_proxy
71-
#https_proxy
71+
#https_proxy
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# THIS IS AN EXAMPLE OF pyxis.conf file
2+
# When you want to enable please move this to /opt/slurm/etc/plugstack.conf.d/
3+
required /usr/local/lib/slurm/spank_pyxis.so runtime_path=<%= @pyxis_persistent_runtime_path %>

cookbooks/aws-parallelcluster-platform/test/controls/enroot_spec.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,37 @@
1414

1515
expected_enroot_version = node['cluster']['enroot']['version']
1616

17-
describe "gdrcopy version is expected to be #{expected_enroot_version}" do
17+
describe "enroot version is expected to be #{expected_enroot_version}" do
1818
subject { command('enroot version').stdout.strip() }
1919
it { should eq expected_enroot_version }
2020
end
21+
22+
base_dir1 = "/etc/enroot"
23+
etc_dirs = [ base_dir1, "#{base_dir1}/enroot-cache"]
24+
25+
etc_dirs.each do |path|
26+
describe directory(path) do
27+
it { should exist }
28+
its('mode') { should cmp '0755' }
29+
its('owner') { should eq 'root' }
30+
its('group') { should eq 'root' }
31+
end
32+
end
33+
34+
base_dir2 = "/tmp/enroot"
35+
tmp_dirs = [ base_dir2, "#{base_dir2}/data" ]
36+
etc_dirs.each do |path|
37+
describe directory(path) do
38+
it { should exist }
39+
its('mode') { should cmp '1777' }
40+
end
41+
end
2142
end
2243

2344
control 'tag:config_enroot_enabled_on_graphic_instances' do
2445
only_if { !os_properties.on_docker? && ['yes', true].include?(node['cluster']['nvidia']['enabled']) }
2546

26-
describe file("/opt/parallelcluster/shared/enroot") do
47+
describe file("/etc/enroot/enroot-cache") do
2748
it { should exist }
2849
its('group') { should eq 'root' }
2950
end unless os_properties.redhat_on_docker?

cookbooks/aws-parallelcluster-shared/attributes/cluster.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@
3333

3434
# Default NFS mount options
3535
default['cluster']['nfs']['hard_mount_options'] = 'hard,_netdev,noatime'
36+
37+
# Pyxis+Enroot Exmaple Config files
38+
default['cluster']['config_examples_dir'] = "#{node['cluster']['configs_dir']}/examples"
39+
default['cluster']['enroot_dir'] = "/etc/enroot"
40+
default['cluster']['enroot_cache_path'] = "#{node['cluster']['enroot_dir']}/enroot-cache"

cookbooks/aws-parallelcluster-slurm/recipes/install/install_pyxis.rb

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,51 @@
3737
cd /tmp/pyxis-#{pyxis_version}
3838
CPPFLAGS='-I /opt/slurm/include/' make
3939
CPPFLAGS='-I /opt/slurm/include/' make install
40-
mkdir -p /opt/slurm/etc/plugstack.conf.d
41-
echo -e 'include /opt/slurm/etc/plugstack.conf.d/*' | tee /opt/slurm/etc/plugstack.conf
42-
ln -fs /usr/local/share/pyxis/pyxis.conf /opt/slurm/etc/plugstack.conf.d/pyxis.conf
4340
PYXIS_INSTALL
4441
retries 3
4542
retry_delay 5
4643
end
44+
45+
directory "#{node['cluster']['slurm']['install_dir']}/etc" do
46+
user 'root'
47+
group 'root'
48+
mode '0755'
49+
end
50+
51+
directory "#{node['cluster']['slurm']['install_dir']}/etc/plugstack.conf.d"
52+
53+
directory node['cluster']['config_examples_dir']
54+
55+
directory "#{node['cluster']['config_examples_dir']}/spank"
56+
57+
directory "#{node['cluster']['config_examples_dir']}/pyxis"
58+
59+
directory "/tmp/pyxis" do
60+
owner node['cluster']['cluster_user']
61+
# group node['cluster']['cluster_user']
62+
# mode '0755'
63+
action :create
64+
end
65+
66+
template "#{node['cluster']['config_examples_dir']}/spank/plugstack.conf" do
67+
source 'pyxis/plugstack.conf.erb'
68+
cookbook 'aws-parallelcluster-slurm'
69+
owner 'root'
70+
group 'root'
71+
mode '0644'
72+
end
73+
74+
link '/usr/local/share/pyxis/pyxis.conf' do
75+
to "#{node['cluster']['slurm']['install_dir']}/etc/plugstack.conf.d/pyxis.conf"
76+
end
77+
78+
template "#{node['cluster']['config_examples_dir']}/pyxis/pyxis.conf" do
79+
source 'pyxis/pyxis.conf.erb'
80+
cookbook 'aws-parallelcluster-platform'
81+
owner 'root'
82+
group 'root'
83+
mode '0644'
84+
variables(
85+
pyxis_persistent_runtime_path: "/tmp/pyxis"
86+
)
87+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include <%= node['cluster']['slurm']['install_dir'] %>/etc/plugstack.conf.d/*

cookbooks/aws-parallelcluster-slurm/test/controls/pyxis_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@
1414

1515
title 'Checks Pyxis has been installed'
1616

17+
describe directory('/opt/slurm/etc') do
18+
it { should exist }
19+
its('mode') { should cmp '0755' }
20+
its('owner') { should eq 'root' }
21+
its('group') { should eq 'root' }
22+
end
23+
24+
base_dir = "/opt/parallelcluster/configs/examples"
25+
dirs = [ base_dir, "#{base_dir}/spank", "#{base_dir}/pyxis" ]
26+
dirs.each do |path|
27+
describe directory(path) do
28+
it { should exist }
29+
end
30+
end
31+
32+
describe directory('/tmp/pyxis') do
33+
it { should exist }
34+
its('owner') { should eq "#{node['cluster']['cluster_user']}" }
35+
end
36+
37+
describe directory('/opt/slurm/etc/plugstack.conf.d') do
38+
it { should exist }
39+
its('owner') { should eq 'root' }
40+
its('group') { should eq 'root' }
41+
end
42+
1743
describe file("/opt/slurm/etc/plugstack.conf.d/pyxis.conf") do
1844
it { should exist }
1945
end

0 commit comments

Comments
 (0)