Skip to content

Commit 296ec42

Browse files
authored
Download http-parser from s3 (#2896)
* Download http-parser from s3 * Fix isolated spec test
1 parent 65c1b4e commit 296ec42

File tree

5 files changed

+72
-24
lines changed

5 files changed

+72
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
it 'has the correct content' do
2828
is_expected.to render_file("#{node['cluster']['scripts_dir']}/patch-iso-instance.sh")
29-
.with_content("USERS=(root #{node['cluster']['cluster_admin_user']} #{node['cluster']['cluster_user']})")
29+
.with_content("source /etc/profile.d/aws-cli-default-config.sh")
3030
end
3131
end
3232
end

cookbooks/aws-parallelcluster-environment/templates/isolated/patch-iso-instance.sh.erb

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,41 @@ REGION="$(get_instance_region)"
1919

2020
source /etc/os-release
2121
OS="${ID}${VERSION_ID}"
22-
[[ "${OS}" != "amzn2" ]] && echo "[ERROR] Unsupported OS '${OS}'. Configuration supported only on Amazon Linux 2." && exit 1
22+
23+
if [[ "${OS}" != "amzn2" && "${OS}" != "amzn2023" ]]; then
24+
echo "[ERROR] Unsupported OS '${OS}'. Configuration supported only on Amazon Linux 2 and Amazon Linux 2023."
25+
exit 1
26+
fi
2327

2428
echo "[INFO] Starting: instance configuration for US isolated region"
2529

2630
echo "[INFO] Starting: installation of packages from amazon Linux 2 repository for US isolated region"
2731

28-
REPOSITORY_DEFINITION_FILE="/etc/yum.repos.d/tmp-amzn2-iso.repo"
32+
REPOSITORY_DEFINITION_FILE="/etc/yum.repos.d/tmp-${OS}-iso.repo"
33+
34+
if [[ "${OS}" == "amzn2023" ]]; then
35+
cat > ${REPOSITORY_DEFINITION_FILE} <<REPO_DEFINITION
36+
[amzn2023-iso]
37+
name=Amazon Linux 2023 isolated Region repository
38+
mirrorlist=http://al2023-repos-\$awsregion-de612dc2.s3.\$awsregion.\$awsdomain/core-iso/mirrors/\$releasever/\$basearch/mirror.list
39+
priority=10
40+
enabled=1
41+
repo_gpgcheck=0
42+
type=rpm
43+
gpgcheck=0
44+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-amazon-linux-2023
45+
REPO_DEFINITION
2946

30-
cat > ${REPOSITORY_DEFINITION_FILE} <<REPO_DEFINITION
47+
echo "sslverify=0" >> /etc/dnf/dnf.conf
48+
echo -n "" | sudo tee /etc/dnf/vars/dualstack
49+
if [[ ${REGION} == us-isob* ]]; then
50+
dnf install -y amazon-linux-repo-iso ca-certificates-isob
51+
else
52+
dnf install -y amazon-linux-repo-iso ca-certificates-iso
53+
fi
54+
sed -i "s/sslverify=0//g" /etc/dnf/dnf.conf
55+
else
56+
cat > ${REPOSITORY_DEFINITION_FILE} <<REPO_DEFINITION
3157
[amzn2-iso]
3258
name=Amazon Linux 2 isolated region repository
3359
mirrorlist=http://amazonlinux.\$awsregion.\$awsdomain/\$releasever/core-\$awsregion/latest/\$basearch/mirror.list
@@ -39,30 +65,35 @@ mirrorlist_expire=300
3965
report_instanceid=yes
4066
REPO_DEFINITION
4167

42-
yum --disablerepo="*" --enablerepo="amzn2-iso" install -y "*-${REGION}"
68+
yum --disablerepo="*" --enablerepo="${OS}-iso" install -y "*-${REGION}"
69+
fi
70+
4371
rm -f ${REPOSITORY_DEFINITION_FILE}
4472

45-
echo "[INFO] Complete: installation of packages from amazon Linux 2 repository for US isolated region"
73+
echo "[INFO] Complete: installation of packages from ${OS} repository for US isolated region"
4674

4775
echo "[INFO] Starting: CA bundle configuration for AWS CLI in US isolated region"
4876

49-
USERS=(<%= @users %>)
5077
CA_BUNDLE="/etc/pki/${REGION}/certs/ca-bundle.pem"
5178

52-
for user in "${USERS[@]}"; do
53-
echo "[INFO] Setting CA bundle ${CA_BUNDLE} for user ${user}"
54-
sudo mkhomedir_helper $user
55-
sudo -u $user aws configure set ca_bundle "$CA_BUNDLE"
56-
done
79+
sudo aws configure set ca_bundle "$CA_BUNDLE"
5780

5881
echo "[INFO] Complete: CA bundle configuration for AWS CLI in US isolated region"
5982

6083
echo "[INFO] Starting: Setting system-wide environment variables for AWS CLI in US isolated region"
6184

85+
echo "export AWS_CA_BUNDLE=/etc/pki/${REGION}/certs/ca-bundle.pem" >> /etc/profile.d/aws-cli-default-config.sh
86+
6287
echo "export AWS_DEFAULT_REGION=${REGION}" >> /etc/profile.d/aws-cli-default-config.sh
6388

64-
echo "Defaults env_keep += \"AWS_DEFAULT_REGION AWS_CA_BUNDLE\"" > /etc/sudoers.d/pcluster-aws-cli-envkeep
89+
echo "export REQUESTS_CA_BUNDLE=${AWS_CA_BUNDLE}" >> /etc/profile.d/aws-cli-default-config.sh
6590

66-
echo "[INFO] Complete: Setting system-wide environment variables for AWS CLI in US isolated region"
91+
echo "export SSL_CERT_FILE=${AWS_CA_BUNDLE}" >> /etc/profile.d/aws-cli-default-config.sh
92+
93+
echo "Defaults env_keep += \"AWS_DEFAULT_REGION AWS_CA_BUNDLE REQUESTS_CA_BUNDLE SSL_CERT_FILE\"" > /etc/sudoers.d/pcluster-aws-cli-envkeep
6794

68-
echo "[INFO] Complete: instance configuration for US isolated region"
95+
source /etc/profile.d/aws-cli-default-config.sh
96+
97+
sudo aws configure set ca_bundle "$CA_BUNDLE"
98+
99+
echo "[INFO] Complete: Setting system-wide environment variables for AWS CLI in US isolated region"

cookbooks/aws-parallelcluster-environment/test/controls/isolated_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@
1717
its('owner') { should cmp 'root' }
1818
its('group') { should cmp 'root' }
1919
its('mode') { should cmp '0744' }
20-
its('content') { should match /USERS=\(root #{node['cluster']['cluster_admin_user']} #{node['cluster']['cluster_user']}\)/ }
2120
end
2221
end

cookbooks/aws-parallelcluster-platform/files/isolated/iso-ca-bundle-config.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ function get_instance_region {
99

1010
REGION="$(get_instance_region)"
1111

12+
CA_BUNDLE="/etc/pki/${REGION}/certs/ca-bundle.pem"
13+
1214
echo "export AWS_CA_BUNDLE=/etc/pki/${REGION}/certs/ca-bundle.pem" >> /etc/profile.d/aws-cli-default-config.sh
1315

1416
echo "export AWS_DEFAULT_REGION=${REGION}" >> /etc/profile.d/aws-cli-default-config.sh

cookbooks/aws-parallelcluster-slurm/resources/slurm_dependencies/slurm_dependencies_alinux2023.rb

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

1515
use 'partial/_slurm_dependencies_common'
1616

17+
http_parser_version = "2.9.4"
18+
http_parser_url = "#{node['cluster']['artifacts_s3_url']}/dependencies/http_parser/v#{http_parser_version}.tar.gz"
19+
http_parser_tarball = "#{node['cluster']['sources_dir']}/http-parser-#{http_parser_version}.tar.gz"
20+
1721
def dependencies
1822
%w(json-c-devel perl perl-Switch lua-devel dbus-devel)
1923
end
@@ -22,13 +26,25 @@ def dependencies
2226
# http parser is no longer maintained, therefore Amazon Linux 2023 does have have the package in OS repos
2327
# https://docs.aws.amazon.com/linux/al2023/release-notes/removed-AL2023.4-AL2.html
2428
# Following https://slurm.schedmd.com/related_software.html#jwt for Installing Http-parser
25-
bash 'Install http-parser' do
26-
code <<-HTTP_PARSER
27-
set -e
28-
git clone --depth 1 --single-branch -b v2.9.4 https://github.com/nodejs/http-parser.git http_parser
29-
cd http_parser
30-
make
31-
make install
32-
HTTP_PARSER
29+
30+
remote_file "#{http_parser_tarball}" do
31+
source "#{http_parser_url}"
32+
mode '0644'
33+
retries 3
34+
retry_delay 5
35+
action :create_if_missing
36+
end
37+
38+
bash 'make install' do
39+
user 'root'
40+
group 'root'
41+
cwd "#{node['cluster']['sources_dir']}"
42+
code <<-HTTP
43+
set -e
44+
tar xf #{http_parser_tarball}
45+
cd http-parser-#{http_parser_version}
46+
make
47+
make install
48+
HTTP
3349
end
3450
end

0 commit comments

Comments
 (0)