Skip to content

Commit 7917bb2

Browse files
authored
[chore]: fix linux packaging tests (open-telemetry#30202)
Fixes open-telemetry#16450 The original packaging tests for the Linux packages (deb, rpm) that were created in #405 used a bit of gnarly work around in order to allow very limited Systemd functionality to be used in Docker/Containerd At the time when those packaging tests were written, podman was already able to run Systemd, but podman was not included in Ubuntu 20.04 yet ... Now that Podman is available in Ubuntu 22.04, running SystemD in Podman just works. Signed-off-by: Christoph Wegener <[email protected]>
1 parent 0613fb6 commit 7917bb2

File tree

5 files changed

+19
-40
lines changed

5 files changed

+19
-40
lines changed

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,7 @@ jobs:
458458
path: ./bin/*
459459

460460
build-package:
461-
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
462-
runs-on: ubuntu-20.04
461+
runs-on: ubuntu-latest
463462
needs: [cross-compile]
464463
strategy:
465464
fail-fast: false

internal/buildscripts/packaging/fpm/common.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ docker_cp() {
3131
local dest_dir="$( dirname "$dest" )"
3232

3333
echo "Copying $src to $container:$dest ..."
34-
docker exec $container mkdir -p "$dest_dir"
35-
docker cp "$src" $container:"$dest"
34+
podman exec $container mkdir -p "$dest_dir"
35+
podman cp "$src" $container:"$dest"
3636
}
3737

3838
install_pkg() {
@@ -43,9 +43,9 @@ install_pkg() {
4343
echo "Installing $pkg_base ..."
4444
docker_cp $container "$pkg_path" /tmp/$pkg_base
4545
if [[ "${pkg_base##*.}" = "deb" ]]; then
46-
docker exec $container dpkg -i /tmp/$pkg_base
46+
podman exec $container dpkg -i /tmp/$pkg_base
4747
else
48-
docker exec $container rpm -ivh /tmp/$pkg_base
48+
podman exec $container rpm -ivh /tmp/$pkg_base
4949
fi
5050
}
5151

@@ -56,8 +56,8 @@ uninstall_pkg() {
5656

5757
echo "Uninstalling $pkg_name ..."
5858
if [[ "$pkg_type" = "deb" ]]; then
59-
docker exec $container dpkg -r $pkg_name
59+
podman exec $container dpkg -r $pkg_name
6060
else
61-
docker exec $container rpm -e $pkg_name
61+
podman exec $container rpm -e $pkg_name
6262
fi
63-
}
63+
}

internal/buildscripts/packaging/fpm/deb/Dockerfile.test

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ ENV DEBIAN_FRONTEND noninteractive
99
RUN apt-get update ; \
1010
apt-get install -y systemd systemd-sysv procps; \
1111
apt-get clean ; \
12-
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ; \
13-
rm -rf /lib/systemd/system/multi-user.target.wants/* ; \
14-
rm -rf /etc/systemd/system/*.wants/* ; \
15-
rm -rf /lib/systemd/system/local-fs.target.wants/* ; \
16-
rm -rf /lib/systemd/system/sockets.target.wants/*udev* ; \
17-
rm -rf /lib/systemd/system/sockets.target.wants/*initctl* ; \
18-
rm -rf /lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* ; \
19-
rm -rf /lib/systemd/system/systemd-update-utmp*
12+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2013

21-
VOLUME [ "/sys/fs/cgroup" ]
2214
CMD ["/lib/systemd/systemd"]

internal/buildscripts/packaging/fpm/rpm/Dockerfile.test

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,4 @@ ENV container docker
66

77
RUN dnf install -y initscripts
88

9-
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \
10-
"systemd-tmpfiles-setup.service" ] || rm -f $i; done); \
11-
rm -f /lib/systemd/system/multi-user.target.wants/*;\
12-
rm -f /lib/systemd/system/local-fs.target.wants/*; \
13-
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
14-
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
15-
rm -f /lib/systemd/system/basic.target.wants/*;\
16-
rm -f /lib/systemd/system/anaconda.target.wants/*;
17-
18-
VOLUME [ "/sys/fs/cgroup" ]
19-
209
CMD ["/usr/sbin/init"]

internal/buildscripts/packaging/fpm/test.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,47 +30,46 @@ if [[ ! "$pkg_type" =~ ^(deb|rpm)$ ]]; then
3030
fi
3131
image_name="otelcontribcol-$pkg_type-test"
3232
container_name="$image_name"
33-
docker_run="docker run --name $container_name -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro --privileged $image_name"
34-
docker_exec="docker exec $container_name"
33+
container_exec="podman exec $container_name"
3534

36-
trap "docker rm -fv $container_name >/dev/null 2>&1 || true" EXIT
35+
trap "podman rm -fv $container_name >/dev/null 2>&1 || true" EXIT
3736

38-
docker build -t $image_name -f "$SCRIPT_DIR/$pkg_type/Dockerfile.test" "$SCRIPT_DIR"
39-
docker rm -fv $container_name >/dev/null 2>&1 || true
37+
podman build -t $image_name -f "$SCRIPT_DIR/$pkg_type/Dockerfile.test" "$SCRIPT_DIR"
38+
podman rm -fv $container_name >/dev/null 2>&1 || true
4039

4140
# test install
4241
echo
43-
$docker_run
42+
podman run --name $container_name -d $image_name
4443
install_pkg $container_name "$PKG_PATH"
4544

4645
# ensure service has started and still running after 5 seconds
4746
sleep 5
4847
echo "Checking $SERVICE_NAME service status ..."
49-
$docker_exec systemctl --no-pager status $SERVICE_NAME
48+
$container_exec systemctl --no-pager status $SERVICE_NAME
5049

5150
echo "Checking $PROCESS_NAME process ..."
52-
$docker_exec pgrep -a -u otel $PROCESS_NAME
51+
$container_exec pgrep -a -u otel $PROCESS_NAME
5352

5453
# test uninstall
5554
echo
5655
uninstall_pkg $container_name $pkg_type
5756

5857
echo "Checking $SERVICE_NAME service status after uninstall ..."
59-
if $docker_exec systemctl --no-pager status $SERVICE_NAME; then
58+
if $container_exec systemctl --no-pager status $SERVICE_NAME; then
6059
echo "$SERVICE_NAME service still running after uninstall" >&2
6160
exit 1
6261
fi
6362
echo "$SERVICE_NAME service successfully stopped after uninstall"
6463

6564
echo "Checking $SERVICE_NAME service existence after uninstall ..."
66-
if $docker_exec systemctl list-unit-files --all | grep $SERVICE_NAME; then
65+
if $container_exec systemctl list-unit-files --all | grep $SERVICE_NAME; then
6766
echo "$SERVICE_NAME service still exists after uninstall" >&2
6867
exit 1
6968
fi
7069
echo "$SERVICE_NAME service successfully removed after uninstall"
7170

7271
echo "Checking $PROCESS_NAME process after uninstall ..."
73-
if $docker_exec pgrep $PROCESS_NAME; then
72+
if $container_exec pgrep $PROCESS_NAME; then
7473
echo "$PROCESS_NAME process still running after uninstall"
7574
exit 1
7675
fi

0 commit comments

Comments
 (0)