Skip to content

Commit dda2be1

Browse files
committed
Fix package testing for modern base images and improve debugging
- Upgrade deb test image from debian:10 to debian:12 - Migrate rpm test image from centos:8 (EOL) to rockylinux:9 - Fix systemd unit paths for Rocky Linux (/lib -> /usr/lib) - Add proper Cortex config and data directories in test containers - Increase readiness timeout and add diagnostic output on failure - Run containers in privileged mode for systemd compatibility Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
1 parent 3a3917d commit dda2be1

3 files changed

Lines changed: 23 additions & 14 deletions

File tree

packaging/deb/debian-systemd/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:10
1+
FROM debian:12
22
ENV container docker
33
ENV LC_ALL C
44
ENV DEBIAN_FRONTEND noninteractive
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
FROM centos:8
1+
FROM rockylinux:9
22
ENV container docker
3-
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
4-
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
5-
rm -f /lib/systemd/system/multi-user.target.wants/*; \
3+
RUN dnf -y install systemd && dnf clean all && \
4+
(cd /usr/lib/systemd/system/sysinit.target.wants/; for i in *; do [ "$i" = \
5+
systemd-tmpfiles-setup.service ] || rm -f "$i"; done); \
6+
rm -f /usr/lib/systemd/system/multi-user.target.wants/*; \
67
rm -f /etc/systemd/system/*.wants/*; \
7-
rm -f /lib/systemd/system/local-fs.target.wants/*; \
8-
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
9-
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
10-
rm -f /lib/systemd/system/basic.target.wants/*; \
11-
rm -f /lib/systemd/system/anaconda.target.wants/*;
8+
rm -f /usr/lib/systemd/system/local-fs.target.wants/*; \
9+
rm -f /usr/lib/systemd/system/sockets.target.wants/*udev*; \
10+
rm -f /usr/lib/systemd/system/sockets.target.wants/*initctl*; \
11+
rm -f /usr/lib/systemd/system/basic.target.wants/*;
1212

1313
VOLUME [ "/sys/fs/cgroup"]
1414
CMD ["/usr/sbin/init"]

tools/packaging/test-packages

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,23 @@ function test_with_systemd() {
4646

4747
echo "Testing $install_command on $image ($platform)"
4848

49-
container=$(docker run --platform="${platform}" --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro -itd -v "$(pwd)"/dist:/opt/cortex -p 9009 "${image}")
49+
container=$(docker run --platform="${platform}" --privileged --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup -td -v "$(pwd)"/dist:/opt/cortex -v "$(pwd)"/docs/configuration:/opt/config:ro -p 9009 "${image}")
5050
CONTAINERS+=("${container}")
5151

5252
port=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "9009/tcp") 0).HostPort}}' "${container}")
5353

54-
docker exec -it "${container}" /bin/bash -c "${install_command}; systemctl start cortex.service; systemctl enable cortex.service"
55-
56-
ready 10 1 "${port}" || error "Testing image: ${image} with command: '${install_command}' failed"
54+
docker exec "${container}" /bin/bash -c "${install_command}; mkdir -p /tmp/cortex/tsdb /tmp/cortex/tsdb-sync /tmp/cortex/compactor /tmp/cortex/rules /tmp/cortex/alerts /var/lib/cortex/data/tsdb && chown -R cortex:cortex /tmp/cortex /var/lib/cortex; cp /opt/config/single-process-config-blocks-local.yaml /etc/cortex/single-process-config.yaml && chown root:cortex /etc/cortex/single-process-config.yaml; systemctl start cortex.service; systemctl enable cortex.service"
55+
56+
ready 30 2 "${port}" || {
57+
echo "--- curl localhost:${port}/ready ---"
58+
curl -s localhost:"${port}"/ready || true
59+
echo ""
60+
echo "--- systemctl status cortex.service ---"
61+
docker exec "${container}" systemctl status cortex.service || true
62+
echo "--- journalctl -u cortex.service ---"
63+
docker exec "${container}" journalctl -u cortex.service --no-pager -n 50 || true
64+
error "Testing image: ${image} with command: '${install_command}' failed"
65+
}
5766
}
5867

5968
test_with_systemd "${IMAGE_PREFIX}"debian-systemd:amd64 linux/amd64 "dpkg -i /opt/cortex/cortex-${VERSION}_amd64.deb"

0 commit comments

Comments
 (0)