mirror of
https://github.com/containers/podman.git
synced 2025-07-02 08:47:43 +08:00
new testimage and systemd-image
Simply because it's been a while since the last testimage build, and I want to confirm that our image build process still works. Added /home/podman/healthcheck. This saves us having to podman-build on each healthcheck test. Removed now- unneeded _build_health_check_image helper. testimage: bump alpine 3.16.2 to 3.19.0 systemd-image: f38 to f39 - tzdata now requires dnf **install**, not reinstall (this is exactly the sort of thing I was looking for) PROBLEMS DISCOVERED: - in e2e, fedoraMinimal is now == SYSTEMD_IMAGE. This screws up some of the image-count tests (CACHE_IMAGES). - "alter tarball" system test now barfs with tar < 1.35. TODO: completely replace fedoraMinimal with SYSTEMD_IMAGE in all tests. Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@ -54,8 +54,8 @@ t POST "libpod/images/pull?reference=alpine&compatMode=true" 200 .error~null .st
|
||||
t POST "images/create?fromImage=alpine&tag=latest" 200
|
||||
|
||||
# 10977 - handle platform parameter correctly
|
||||
t POST "images/create?fromImage=quay.io/libpod/testimage:20210610&platform=linux/arm64" 200
|
||||
t GET "images/testimage:20210610/json" 200 \
|
||||
t POST "images/create?fromImage=quay.io/libpod/testimage:20240123&platform=linux/arm64" 200
|
||||
t GET "images/testimage:20240123/json" 200 \
|
||||
.Architecture=arm64
|
||||
|
||||
# Make sure that new images are pulled
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
|
||||
# WORKDIR=/data
|
||||
ENV_WORKDIR_IMG=quay.io/libpod/testimage:20200929
|
||||
ENV_WORKDIR_IMG=quay.io/libpod/testimage:20240123
|
||||
MultiTagName=localhost/test/testformultitag:tag
|
||||
|
||||
podman pull $IMAGE &>/dev/null
|
||||
|
@ -2,7 +2,7 @@ package integration
|
||||
|
||||
var (
|
||||
REDIS_IMAGE = "quay.io/libpod/redis:alpine" //nolint:revive,stylecheck
|
||||
fedoraMinimal = "quay.io/libpod/systemd-image:20230531"
|
||||
fedoraMinimal = "quay.io/libpod/systemd-image:20240124"
|
||||
ALPINE = "quay.io/libpod/alpine:latest"
|
||||
ALPINELISTTAG = "quay.io/libpod/alpine:3.10.2"
|
||||
ALPINELISTDIGEST = "quay.io/libpod/alpine@sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f"
|
||||
|
@ -1,15 +1,15 @@
|
||||
package integration
|
||||
|
||||
var (
|
||||
STORAGE_FS = "overlay" //nolint:revive,stylecheck
|
||||
STORAGE_OPTIONS = "--storage-driver overlay" //nolint:revive,stylecheck
|
||||
ROOTLESS_STORAGE_FS = "overlay" //nolint:revive,stylecheck
|
||||
ROOTLESS_STORAGE_OPTIONS = "--storage-driver overlay" //nolint:revive,stylecheck
|
||||
CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, NGINX_IMAGE, REDIS_IMAGE, REGISTRY_IMAGE, INFRA_IMAGE, CITEST_IMAGE, HEALTHCHECK_IMAGE, SYSTEMD_IMAGE, fedoraToolbox} //nolint:revive,stylecheck
|
||||
NGINX_IMAGE = "quay.io/libpod/alpine_nginx:latest" //nolint:revive,stylecheck
|
||||
BB_GLIBC = "docker.io/library/busybox:glibc" //nolint:revive,stylecheck
|
||||
REGISTRY_IMAGE = "quay.io/libpod/registry:2.8.2" //nolint:revive,stylecheck
|
||||
CITEST_IMAGE = "quay.io/libpod/testimage:20221018" //nolint:revive,stylecheck
|
||||
SYSTEMD_IMAGE = "quay.io/libpod/systemd-image:20230106" //nolint:revive,stylecheck
|
||||
CIRROS_IMAGE = "quay.io/libpod/cirros:latest" //nolint:revive,stylecheck
|
||||
STORAGE_FS = "overlay" //nolint:revive,stylecheck
|
||||
STORAGE_OPTIONS = "--storage-driver overlay" //nolint:revive,stylecheck
|
||||
ROOTLESS_STORAGE_FS = "overlay" //nolint:revive,stylecheck
|
||||
ROOTLESS_STORAGE_OPTIONS = "--storage-driver overlay" //nolint:revive,stylecheck
|
||||
CACHE_IMAGES = []string{ALPINE, BB, NGINX_IMAGE, REDIS_IMAGE, REGISTRY_IMAGE, INFRA_IMAGE, CITEST_IMAGE, HEALTHCHECK_IMAGE, SYSTEMD_IMAGE, fedoraToolbox} //nolint:revive,stylecheck
|
||||
NGINX_IMAGE = "quay.io/libpod/alpine_nginx:latest" //nolint:revive,stylecheck
|
||||
BB_GLIBC = "docker.io/library/busybox:glibc" //nolint:revive,stylecheck
|
||||
REGISTRY_IMAGE = "quay.io/libpod/registry:2.8.2" //nolint:revive,stylecheck
|
||||
CITEST_IMAGE = "quay.io/libpod/testimage:20240123" //nolint:revive,stylecheck
|
||||
SYSTEMD_IMAGE = "quay.io/libpod/systemd-image:20240124" //nolint:revive,stylecheck
|
||||
CIRROS_IMAGE = "quay.io/libpod/cirros:latest" //nolint:revive,stylecheck
|
||||
)
|
||||
|
@ -9,7 +9,7 @@ var (
|
||||
NGINX_IMAGE = "quay.io/lsm5/alpine_nginx-aarch64:latest" //nolint:revive,stylecheck
|
||||
BB_GLIBC = "docker.io/library/busybox:glibc" //nolint:revive,stylecheck
|
||||
REGISTRY_IMAGE = "quay.io/libpod/registry:2.8.2" //nolint:revive,stylecheck
|
||||
CITEST_IMAGE = "quay.io/libpod/testimage:20221018" //nolint:revive,stylecheck
|
||||
SYSTEMD_IMAGE = "quay.io/libpod/systemd-image:20230106" //nolint:revive,stylecheck
|
||||
CITEST_IMAGE = "quay.io/libpod/testimage:20240123" //nolint:revive,stylecheck
|
||||
SYSTEMD_IMAGE = "quay.io/libpod/systemd-image:20240124" //nolint:revive,stylecheck
|
||||
CIRROS_IMAGE = "quay.io/libpod/cirros:latest" //nolint:revive,stylecheck
|
||||
)
|
||||
|
@ -8,6 +8,6 @@ var (
|
||||
CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, NGINX_IMAGE, REDIS_IMAGE, INFRA_IMAGE, CITEST_IMAGE}
|
||||
NGINX_IMAGE = "quay.io/libpod/alpine_nginx-ppc64le:latest"
|
||||
BB_GLIBC = "docker.io/ppc64le/busybox:glibc"
|
||||
CITEST_IMAGE = "quay.io/libpod/testimage:20221018"
|
||||
CITEST_IMAGE = "quay.io/libpod/testimage:20240123"
|
||||
REGISTRY_IMAGE string
|
||||
)
|
||||
|
@ -148,7 +148,7 @@ var _ = Describe("Podman images", func() {
|
||||
result := podmanTest.Podman([]string{"images", "-q", "-f", "reference=quay.io/libpod/*"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(ExitCleanly())
|
||||
Expect(result.OutputToStringArray()).To(HaveLen(10))
|
||||
Expect(result.OutputToStringArray()).To(HaveLen(9))
|
||||
|
||||
retalpine := podmanTest.Podman([]string{"images", "-f", "reference=*lpine*"})
|
||||
retalpine.WaitWithDefaultTimeout()
|
||||
|
@ -214,7 +214,7 @@ var _ = Describe("Podman rmi", func() {
|
||||
session = podmanTest.Podman([]string{"images", "-q", "-a"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToString()).To(HaveLen(142))
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES)))
|
||||
})
|
||||
|
||||
It("podman rmi -a with no images should be exit 0", func() {
|
||||
|
@ -47,6 +47,14 @@ load helpers
|
||||
# Integration tag to catch future breakage in tar, e.g. #19407
|
||||
# bats test_tags=distro-integration
|
||||
@test "podman export, alter tarball, re-import" {
|
||||
# FIXME: #21373 - tar < 1.35 is broken.
|
||||
# Remove this skip once all VMs are updated to 1.35.2 or above
|
||||
# (.2, because of #19407)
|
||||
tar_version=$(tar --version | head -1 | awk '{print $NF}' | tr -d .)
|
||||
if [[ $tar_version -lt 135 ]]; then
|
||||
skip "test requires tar >= 1.35 (you have: $tar_version)"
|
||||
fi
|
||||
|
||||
# Create a test file following test
|
||||
mkdir $PODMAN_TMPDIR/tmp
|
||||
touch $PODMAN_TMPDIR/testfile1
|
||||
@ -75,7 +83,9 @@ EOF
|
||||
run_podman rm -t 0 -f $b_cnt
|
||||
|
||||
# Modify tarball contents
|
||||
echo "$_LOG_PROMPT tar --delete -f (tmpdir)/$b_cnt.tar tmp/testfile1"
|
||||
tar --delete -f $PODMAN_TMPDIR/$b_cnt.tar tmp/testfile1
|
||||
echo "$_LOG_PROMPT tar -C (tmpdir) -rf (tmpdir)/$b_cnt.tar tmp/testfile2"
|
||||
tar -C $PODMAN_TMPDIR -rf $PODMAN_TMPDIR/$b_cnt.tar tmp/testfile2
|
||||
|
||||
# Import tarball and Tag imported image
|
||||
|
@ -33,15 +33,12 @@ function _check_health {
|
||||
}
|
||||
|
||||
@test "podman healthcheck" {
|
||||
_build_health_check_image healthcheck_i
|
||||
|
||||
# Run that healthcheck image.
|
||||
run_podman run -d --name healthcheck_c \
|
||||
--health-cmd /healthcheck \
|
||||
--health-interval 1s \
|
||||
--health-retries 3 \
|
||||
--health-on-failure=kill \
|
||||
healthcheck_i
|
||||
run_podman run -d --name healthcheck_c \
|
||||
--health-cmd /home/podman/healthcheck \
|
||||
--health-interval 1s \
|
||||
--health-retries 3 \
|
||||
--health-on-failure=kill \
|
||||
$IMAGE /home/podman/pause
|
||||
|
||||
run_podman inspect healthcheck_c --format "{{.Config.HealthcheckOnFailureAction}}"
|
||||
is "$output" "kill" "on-failure action is set to kill"
|
||||
@ -88,25 +85,22 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
|
||||
|
||||
# Clean up
|
||||
run_podman rm -t 0 -f healthcheck_c
|
||||
run_podman rmi healthcheck_i
|
||||
}
|
||||
|
||||
@test "podman healthcheck - restart cleans up old state" {
|
||||
ctr="healthcheck_c"
|
||||
img="healthcheck_i"
|
||||
|
||||
_build_health_check_image $img cleanfile
|
||||
run_podman run -d --name $ctr \
|
||||
--health-cmd /healthcheck \
|
||||
--health-retries=3 \
|
||||
--health-interval=disable \
|
||||
$img
|
||||
run_podman run -d --name $ctr \
|
||||
--health-cmd /home/podman/healthcheck \
|
||||
--health-retries=3 \
|
||||
--health-interval=disable \
|
||||
$IMAGE /home/podman/pause
|
||||
|
||||
run_podman container inspect $ctr --format "{{.State.Healthcheck.FailingStreak}}"
|
||||
is "$output" "0" "Failing streak of fresh container should be 0"
|
||||
|
||||
# Get the healthcheck to fail
|
||||
run_podman exec $ctr touch /uh-oh
|
||||
run_podman exec $ctr touch /uh-oh-only-once
|
||||
run_podman 1 healthcheck run $ctr
|
||||
is "$output" "unhealthy" "output from 'podman healthcheck run'"
|
||||
run_podman container inspect $ctr --format "{{.State.Healthcheck.FailingStreak}}"
|
||||
@ -117,22 +111,20 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
|
||||
is "$output" "0" "Failing streak of restarted container should be 0 again"
|
||||
|
||||
run_podman rm -f -t0 $ctr
|
||||
run_podman rmi $img
|
||||
}
|
||||
|
||||
@test "podman wait --condition={healthy,unhealthy}" {
|
||||
ctr="healthcheck_c"
|
||||
img="healthcheck_i"
|
||||
|
||||
wait_file="$PODMAN_TMPDIR/$(random_string).wait_for_me"
|
||||
_build_health_check_image $img
|
||||
|
||||
for condition in healthy unhealthy;do
|
||||
rm -f $wait_file
|
||||
run_podman run -d --name $ctr \
|
||||
--health-cmd /healthcheck \
|
||||
--health-retries=1 \
|
||||
--health-interval=disable \
|
||||
$img
|
||||
run_podman run -d --name $ctr \
|
||||
--health-cmd /home/podman/healthcheck \
|
||||
--health-retries=1 \
|
||||
--health-interval=disable \
|
||||
$IMAGE /home/podman/pause
|
||||
if [[ $condition == "unhealthy" ]];then
|
||||
# create the uh-oh file to let the health check fail
|
||||
run_podman exec $ctr touch /uh-oh
|
||||
@ -156,8 +148,6 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
|
||||
wait_for_file $wait_file
|
||||
run_podman rm -f -t0 $ctr
|
||||
done
|
||||
|
||||
run_podman rmi $img
|
||||
}
|
||||
|
||||
@test "podman healthcheck --health-on-failure" {
|
||||
@ -165,30 +155,27 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
|
||||
is "$output" "Error: cannot set on-failure action to kill without a health check"
|
||||
|
||||
ctr="healthcheck_c"
|
||||
img="healthcheck_i"
|
||||
|
||||
for policy in none kill restart stop;do
|
||||
if [[ $policy == "none" ]];then
|
||||
# Do not remove the /uh-oh file for `none` as we want to
|
||||
# demonstrate that no action was taken
|
||||
_build_health_check_image $img
|
||||
else
|
||||
_build_health_check_image $img cleanfile
|
||||
uhoh=/uh-oh
|
||||
if [[ $policy != "none" ]];then
|
||||
# only fail the first run
|
||||
uhoh=/uh-oh-only-once
|
||||
fi
|
||||
|
||||
# Run that healthcheck image.
|
||||
run_podman run -d --name $ctr \
|
||||
--health-cmd /healthcheck \
|
||||
--health-retries=1 \
|
||||
--health-on-failure=$policy \
|
||||
--health-interval=disable \
|
||||
$img
|
||||
# Run healthcheck image.
|
||||
run_podman run -d --name $ctr \
|
||||
--health-cmd /home/podman/healthcheck \
|
||||
--health-retries=1 \
|
||||
--health-on-failure=$policy \
|
||||
--health-interval=disable \
|
||||
$IMAGE /home/podman/pause
|
||||
|
||||
# healthcheck should succeed
|
||||
run_podman healthcheck run $ctr
|
||||
|
||||
# Now cause the healthcheck to fail
|
||||
run_podman exec $ctr touch /uh-oh
|
||||
run_podman exec $ctr touch $uhoh
|
||||
|
||||
# healthcheck should now fail, with exit status 1 and 'unhealthy' output
|
||||
run_podman 1 healthcheck run $ctr
|
||||
@ -218,7 +205,6 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\"
|
||||
fi
|
||||
|
||||
run_podman rm -f -t0 $ctr
|
||||
run_podman rmi -f $img
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -324,16 +324,13 @@ LISTEN_FDNAMES=listen_fdnames" | sort)
|
||||
}
|
||||
|
||||
@test "podman create --health-on-failure=kill" {
|
||||
img="healthcheck_i"
|
||||
_build_health_check_image $img
|
||||
|
||||
cname=c_$(random_string)
|
||||
run_podman create --name $cname \
|
||||
--health-cmd /healthcheck \
|
||||
--health-on-failure=kill \
|
||||
--health-retries=1 \
|
||||
--restart=on-failure \
|
||||
$img
|
||||
run_podman create --name $cname \
|
||||
--health-cmd /home/podman/healthcheck \
|
||||
--health-on-failure=kill \
|
||||
--health-retries=1 \
|
||||
--restart=on-failure \
|
||||
$IMAGE /home/podman/pause
|
||||
|
||||
# run container in systemd unit
|
||||
service_setup
|
||||
@ -376,7 +373,6 @@ LISTEN_FDNAMES=listen_fdnames" | sort)
|
||||
|
||||
# stop systemd container
|
||||
service_cleanup
|
||||
run_podman rmi -f $img
|
||||
}
|
||||
|
||||
@test "podman-kube@.service template" {
|
||||
|
@ -45,22 +45,28 @@ function teardown() {
|
||||
run_podman system df --format json
|
||||
local results="$output"
|
||||
|
||||
# FIXME! This needs to be fiddled with every time we bump testimage.
|
||||
local size=11
|
||||
if [[ "$(uname -m)" = "aarch64" ]]; then
|
||||
size=13
|
||||
fi
|
||||
|
||||
# FIXME: we can't check exact RawSize or Size because every CI system
|
||||
# computes a different value: 12701526, 12702113, 12706209... and
|
||||
# those are all amd64. aarch64 gets 12020148, 12019561.
|
||||
#
|
||||
# WARNING: RawSize and Size tests may fail if $IMAGE is updated. Since
|
||||
# that tends to be done yearly or less, and only by Ed, that's OK.
|
||||
local tests='
|
||||
Type | Images | Containers | Local Volumes
|
||||
Total | 1 | 2 | 0
|
||||
Active | 1 | 1 | 0
|
||||
RawSize | ~12...... | !0 | 0
|
||||
RawReclaimable | 0 | !0 | 0
|
||||
Reclaimable | ~\(0%\) | ~\(50%\) | ~\(0%\)
|
||||
TotalCount | 1 | 2 | 0
|
||||
Size | ~12.*MB | !0B | 0B
|
||||
'
|
||||
local tests="
|
||||
Type | Images | Containers | Local Volumes
|
||||
Total | 1 | 2 | 0
|
||||
Active | 1 | 1 | 0
|
||||
RawSize | ~${size}...... | !0 | 0
|
||||
RawReclaimable | 0 | !0 | 0
|
||||
Reclaimable | ~\(0%\) | ~\(50%\) | ~\(0%\)
|
||||
TotalCount | 1 | 2 | 0
|
||||
Size | ~${size}.*MB | !0B | 0B
|
||||
"
|
||||
while read -a fields; do
|
||||
for i in 0 1 2;do
|
||||
expect="${fields[$((i+1))]}"
|
||||
|
@ -31,11 +31,10 @@ cd $tmpdir
|
||||
echo $YMD >testimage-id
|
||||
|
||||
cat >Containerfile <<EOF
|
||||
FROM registry.fedoraproject.org/fedora-minimal:38
|
||||
FROM registry.fedoraproject.org/fedora-minimal:39
|
||||
LABEL created_by="$create_script @ $create_script_rev"
|
||||
LABEL created_at=$create_time_z
|
||||
# Note the reinstall of tzdata is required (https://bugzilla.redhat.com/show_bug.cgi?id=1870814)
|
||||
RUN microdnf install -y systemd && microdnf reinstall -y tzdata && microdnf clean all && sed -i -e 's/.*LogColor.*/LogColor=no/' /etc/systemd/system.conf
|
||||
RUN microdnf install -y systemd tzdata && microdnf clean all && sed -i -e 's/.*LogColor.*/LogColor=no/' /etc/systemd/system.conf
|
||||
ADD testimage-id /home/podman/
|
||||
WORKDIR /home/podman
|
||||
CMD ["/bin/echo", "This image is intended for podman CI testing"]
|
||||
|
@ -51,6 +51,7 @@ cat >pause <<EOF
|
||||
#
|
||||
# Trivial little pause script, used in one of the pod tests
|
||||
#
|
||||
trap 'exit 0' SIGTERM
|
||||
echo Confirmed: testimage pause invoked as \$0
|
||||
while :; do
|
||||
sleep 0.1
|
||||
@ -58,6 +59,26 @@ done
|
||||
EOF
|
||||
chmod 755 pause
|
||||
|
||||
# Add a health check
|
||||
cat >healthcheck <<EOF
|
||||
#!/bin/sh
|
||||
|
||||
if test -e /uh-oh || test -e /uh-oh-only-once; then
|
||||
echo "Uh-oh on stdout!"
|
||||
echo "Uh-oh on stderr!" >&2
|
||||
|
||||
# Special file causes us to fail healthcheck only once
|
||||
rm -f /uh-oh-only-once
|
||||
|
||||
exit 1
|
||||
else
|
||||
echo "Life is Good on stdout"
|
||||
echo "Life is Good on stderr" >&2
|
||||
exit 0
|
||||
fi
|
||||
EOF
|
||||
chmod 755 healthcheck
|
||||
|
||||
# alpine because it's small and light and reliable
|
||||
# - check for updates @ https://hub.docker.com/_/alpine
|
||||
# busybox-extras provides httpd needed in 500-networking.bats
|
||||
@ -73,9 +94,9 @@ chmod 755 pause
|
||||
#
|
||||
cat >Containerfile1 <<EOF
|
||||
ARG REPO=please-override-repo
|
||||
FROM docker.io/\${REPO}/alpine:3.16.2
|
||||
FROM docker.io/\${REPO}/alpine:3.19.0
|
||||
RUN apk add busybox-extras iproute2 socat
|
||||
ADD testimage-id pause /home/podman/
|
||||
ADD testimage-id healthcheck pause /home/podman/
|
||||
RUN rm -f /var/cache/apk/*
|
||||
EOF
|
||||
|
||||
|
@ -11,12 +11,12 @@ PODMAN_RUNTIME=
|
||||
PODMAN_TEST_IMAGE_REGISTRY=${PODMAN_TEST_IMAGE_REGISTRY:-"quay.io"}
|
||||
PODMAN_TEST_IMAGE_USER=${PODMAN_TEST_IMAGE_USER:-"libpod"}
|
||||
PODMAN_TEST_IMAGE_NAME=${PODMAN_TEST_IMAGE_NAME:-"testimage"}
|
||||
PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20221018"}
|
||||
PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20240123"}
|
||||
PODMAN_TEST_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:$PODMAN_TEST_IMAGE_TAG"
|
||||
|
||||
# Larger image containing systemd tools.
|
||||
PODMAN_SYSTEMD_IMAGE_NAME=${PODMAN_SYSTEMD_IMAGE_NAME:-"systemd-image"}
|
||||
PODMAN_SYSTEMD_IMAGE_TAG=${PODMAN_SYSTEMD_IMAGE_TAG:-"20230531"}
|
||||
PODMAN_SYSTEMD_IMAGE_TAG=${PODMAN_SYSTEMD_IMAGE_TAG:-"20240124"}
|
||||
PODMAN_SYSTEMD_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_SYSTEMD_IMAGE_NAME:$PODMAN_SYSTEMD_IMAGE_TAG"
|
||||
|
||||
# Remote image that we *DO NOT* fetch or keep by default; used for testing pull
|
||||
@ -1142,60 +1142,6 @@ function _podman_commands() {
|
||||
awk '/^Available Commands:/{ok=1;next}/^Options:/{ok=0}ok { print $1 }' <<<"$output" | grep .
|
||||
}
|
||||
|
||||
###############################
|
||||
# _build_health_check_image # Builds a container image with a configured health check
|
||||
###############################
|
||||
#
|
||||
# The health check will fail once the /uh-oh file exists.
|
||||
#
|
||||
# First argument is the desired name of the image
|
||||
# Second argument, if present and non-null, forces removal of the /uh-oh file once the check failed; this way the container can be restarted
|
||||
#
|
||||
|
||||
function _build_health_check_image {
|
||||
local imagename="$1"
|
||||
local cleanfile=""
|
||||
|
||||
if [[ ! -z "$2" ]]; then
|
||||
cleanfile="rm -f /uh-oh"
|
||||
fi
|
||||
# Create an image with a healthcheck script; said script will
|
||||
# pass until the file /uh-oh gets created (by us, via exec)
|
||||
cat >${PODMAN_TMPDIR}/healthcheck <<EOF
|
||||
#!/bin/sh
|
||||
|
||||
if test -e /uh-oh; then
|
||||
echo "Uh-oh on stdout!"
|
||||
echo "Uh-oh on stderr!" >&2
|
||||
${cleanfile}
|
||||
exit 1
|
||||
else
|
||||
echo "Life is Good on stdout"
|
||||
echo "Life is Good on stderr" >&2
|
||||
exit 0
|
||||
fi
|
||||
EOF
|
||||
|
||||
cat >${PODMAN_TMPDIR}/entrypoint <<EOF
|
||||
#!/bin/sh
|
||||
|
||||
trap 'echo Received SIGTERM, finishing; exit' SIGTERM; echo WAITING; while :; do sleep 0.1; done
|
||||
EOF
|
||||
|
||||
cat >${PODMAN_TMPDIR}/Containerfile <<EOF
|
||||
FROM $IMAGE
|
||||
|
||||
COPY healthcheck /healthcheck
|
||||
COPY entrypoint /entrypoint
|
||||
|
||||
RUN chmod 755 /healthcheck /entrypoint
|
||||
|
||||
CMD ["/entrypoint"]
|
||||
EOF
|
||||
|
||||
run_podman build -t $imagename ${PODMAN_TMPDIR}
|
||||
}
|
||||
|
||||
##########################
|
||||
# sleep_to_next_second # Sleep until second rolls over
|
||||
##########################
|
||||
|
Reference in New Issue
Block a user