Skip to content

Commit 2a1fa48

Browse files
committed
Adjusted several ci components to work well with containers
Ticket: ENT-13030 Changelog: none
1 parent 876e618 commit 2a1fa48

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed

ci/cfengine-build-host-setup.cf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ bundle agent cfengine_build_host_setup
155155
"systemssl_build_host" expression => fileexists("/etc/cfengine-systemssl-build-host.flag");
156156
"bootstrap_pr_host" expression => fileexists("/etc/cfengine-bootstrap-pr-host.flag");
157157
"containers_host" expression => fileexists("/etc/cfengine-containers-host.flag");
158+
"not_in_container" expression => not(fileexists("/etc/cfengine-in-container.flag")),
159+
comment => "We use an explicit flag file that we control to avoid ambiguity about whether we are in a container or not.";
158160
linux::
159161
"have_coredumpctl" expression => returnszero("command -v coredumpctl", "useshell");
160162
"missing_opt_jdk21" expression => not(fileexists("/opt/jdk-21.0.1"));
@@ -180,7 +182,7 @@ bundle agent cfengine_build_host_setup
180182
comment => "note: centos-7 has installed instead of --installed argument, and that works on rhel-8 and rhel-9 so go with the sub-command instead of option";
181183

182184
commands:
183-
have_coredumpctl::
185+
have_coredumpctl.not_in_container::
184186
"sysctl kernel.core_pattern='|/lib/systemd/systemd-coredump %p %u %g %s %t %e'" -> { "ENT-12669" }
185187
comment => "Ensure that core_pattern is proper for systemd-coredump if coredumpctl is present.",
186188
contain => in_shell;
@@ -207,7 +209,7 @@ bundle agent cfengine_build_host_setup
207209
ubuntu_16::
208210
"have_i386_architecture" expression => strcmp(execresult("${paths.dpkg} --print-foreign-architectures", "noshell"), "i386");
209211
ubuntu::
210-
"have_localhost_localdomain_hostname" expression => strcmp(execresult("${paths.hostname} -f", "useshell"), "localhost.localdomain");
212+
"localhost_localdomain_hostname_missing" expression => not(strcmp(execresult("${paths.hostname} -f", "useshell"), "localhost.localdomain"));
211213
opensuse|suse|sles::
212214
"have_$(suse_users_and_groups)_group" expression => returnszero("grep '^$(suse_users_and_groups):' /etc/group >/dev/null", "useshell");
213215
"have_$(suse_users_and_groups)_user" expression => returnszero("grep '^$(suse_users_and_groups):' /etc/passwd >/dev/null", "useshell");
@@ -278,7 +280,7 @@ jenkins_builds ALL=NOPASSWD: /usr/bin/podman
278280
mingw_build_host.!have_i386_architecture::
279281
"${paths.dpkg} --add-architecture i386";
280282

281-
ubuntu.!have_localhost_localdomain_hostname::
283+
ubuntu.not_in_container.localhost_localdomain_hostname_missing::
282284
"/usr/bin/hostnamectl set-hostname localhost.localdomain"
283285
comment => "hack for aws ubuntu hosts having unique ip-n-n-n-n hostnames, we need localhost.localdomain";
284286
!have_daemon_group.(suse|sles|opensuse)::

ci/linux-install-jdk21.sh

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
#!/usr/bin/env bash
22
set -e
3-
# install jdk "manually"
4-
# depending on os, might want to do something like `apt remove default-jre openjdk-*-jre-*`
5-
cd /opt
6-
baseurl=https://download.oracle.com/java/21/latest/
7-
version=21.0.7
8-
if uname -m | grep aarch64; then
9-
tarball=jdk-21_linux-aarch64_bin.tar.gz
10-
sha=47372cfa9244dc74ec783a1b287381502419b564fbd0b18abc8f2d6b19ac865e
11-
else
12-
tarball=jdk-21_linux-x64_bin.tar.gz
13-
sha=267b10b14b4e5fada19aca3be3b961ce4f81f1bd3ffcd070e90a5586106125eb
14-
fi
15-
wget --quiet "$baseurl$tarball"
16-
echo "$sha" "$tarball" | sha256sum --check -
17-
sudo tar xf "$tarball"
18-
sudo tee /etc/profile.d/jdk.sh << EOF
3+
4+
install_jdk() {
5+
# install jdk "manually"
6+
# depending on os, might want to do something like `apt remove default-jre openjdk-*-jre-*`
7+
cd /opt
8+
baseurl=https://download.oracle.com/java/21/latest/
9+
version=21.0.7
10+
if uname -m | grep aarch64; then
11+
tarball=jdk-21_linux-aarch64_bin.tar.gz
12+
sha=47372cfa9244dc74ec783a1b287381502419b564fbd0b18abc8f2d6b19ac865e
13+
else
14+
tarball=jdk-21_linux-x64_bin.tar.gz
15+
sha=267b10b14b4e5fada19aca3be3b961ce4f81f1bd3ffcd070e90a5586106125eb
16+
fi
17+
wget --quiet "$baseurl$tarball"
18+
echo "$sha" "$tarball" | sha256sum --check -
19+
tar xf "$tarball"
20+
tee /etc/profile.d/jdk.sh << EOF
1921
export JAVA_HOME="/opt/jdk-$version"
2022
export PATH=\$PATH:\$JAVA_HOME/bin
2123
EOF
22-
sudo chown -R root:jenkins "/opt/jdk-$version"
23-
sudo chmod -R g+rx "/opt/jdk-$version"
24-
if command -v update-alternatives; then
25-
sudo update-alternatives --install /usr/bin/java java "/opt/jdk-$version/bin/java" 9999
24+
chown -R root:jenkins "/opt/jdk-$version"
25+
chmod -R g+rx "/opt/jdk-$version"
26+
if command -v update-alternatives; then
27+
update-alternatives --install /usr/bin/java java "/opt/jdk-$version/bin/java" 9999
28+
else
29+
ln -s "/opt/jdk-$version/bin/java" /usr/bin/java
30+
fi
31+
cd -
32+
}
33+
34+
if [ "$(whoami)" = "root" ]; then
35+
install_jdk
2636
else
27-
sudo ln -s "/opt/jdk-$version/bin/java" /usr/bin/java
37+
sudo bash -c install_jdk
2838
fi
29-
cd -

ci/setup-cfengine-build-host.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,25 @@ if [ "$(id -u)" != "0" ]; then
1212
fi
1313

1414
ls -la /home/
15+
if ! id -u jenkins; then
16+
useradd jenkins -p jenkins
17+
fi
18+
mkdir -p /home/jenkins
1519
chown -R jenkins /home/jenkins
1620

21+
echo "checking for CFEngine install..."
1722
if [ -d /var/cfengine ]; then
1823
echo "Error: CFEngine already installed on this host. Will not proceed trying to setup build host with CFEngine temporary install."
1924
exit 1
2025
fi
2126

22-
2327
function cleanup()
2428
{
2529
set -ex
2630
if command -v apt 2>/dev/null; then
31+
# workaround for CFE-4544, remove scriptlets call systemctl even when systemctl is-system-running returns false
32+
rm /bin/systemctl
33+
ln -s /bin/echo /bin/systemctl
2734
apt remove -y cfengine-nova || true
2835
elif command -v yum 2>/dev/null; then
2936
yum erase -y cfengine-nova || true
@@ -34,7 +41,8 @@ function cleanup()
3441
exit 1
3542
fi
3643
echo "Ensuring CFEngine fully uninstalled/cleaned up"
37-
rm -rf /var/cfengine /opt/cfengine /var/log/CFE* /var/log/postgresql.log || true
44+
# keep these logs around for debugging failed setup runs
45+
# rm -rf /var/cfengine /opt/cfengine /var/log/CFE* /var/log/postgresql.log || true
3846
if command -v pkill; then
3947
pkill -9 cf-agent || true
4048
pkill -9 cf-serverd || true

0 commit comments

Comments
 (0)