Skip to content

Commit c89b393

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 b00a0c6 commit c89b393

File tree

9 files changed

+93
-44
lines changed

9 files changed

+93
-44
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
include_recipe 'aws-parallelcluster-platform::supervisord_config'
2727
fetch_config 'Fetch and load cluster configs'
2828
include_recipe 'aws-parallelcluster-platform::config_login' if node['cluster']['node_type'] == 'LoginNode'
29-
enroot 'Configure Enroot' do
30-
action :configure
29+
if node['cluster']['node_type'] == 'HeadNode'
30+
enroot 'Configure Enroot' do
31+
action :configure
32+
end
3133
end

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

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,43 @@
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'
32-
mode '0755'
33-
action :create_if_missing
25+
mode '1777'
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
29+
directory node['cluster']['enroot_cache_path'] do
30+
owner 'root'
31+
group 'root'
32+
mode '1777'
33+
action :create
34+
end
4835

49-
mkdir -p /tmp/enroot
50-
chmod 1777 /tmp/enroot
51-
mkdir -p /tmp/enroot/data
52-
chmod 1777 /tmp/enroot/data
36+
directory "/tmp/enroot" do
37+
mode '1777'
38+
action :create
39+
end
5340

54-
chmod 1777 ${SHARED_DIR}/enroot
41+
directory "/tmp/enroot/data" do
42+
mode '1777'
43+
action :create
44+
end
45+
end
5546

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
47+
action :configure do
48+
return if on_docker?
49+
return unless enroot_installed
6150

62-
ENROOT_CONFIGURE
63-
retries 3
64-
retry_delay 5
51+
template "/etc/enroot/enroot.conf" do
52+
source 'enroot/enroot.conf.erb'
53+
cookbook 'aws-parallelcluster-platform'
54+
owner 'root'
55+
group 'root'
56+
mode '0644'
57+
action :create
6558
end
6659
end
6760

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
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

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 /opt/slurm/etc/plugstack.conf.d/*

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

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

1515
title 'Checks Pyxis has been installed'
1616

17+
describe directory('/opt/slurm/etc/plugstack.conf.d') do
18+
it { should exist }
19+
end
20+
1721
describe file("/opt/slurm/etc/plugstack.conf.d/pyxis.conf") do
1822
it { should exist }
1923
end

0 commit comments

Comments
 (0)