Skip to content

Commit e44c4f7

Browse files
dtantsurmetal3-io-bot
authored andcommitted
Provide scripts to be used as liveness/readiness probes
This change is the first step towards metal3-io/baremetal-operator#1528. Through these scripts, we can decouple the validation logic from the pod definition and provide more sophisticated tests in the future. Right now, the same curl command is used (modulo supporting all variants of deploying Ironic). Signed-off-by: Dmitry Tantsur <dtantsur@protonmail.com>
1 parent 149fc6e commit e44c4f7

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

configure-nonroot.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ chmod 2775 /var/lib/dnsmasq
4444
touch /var/lib/dnsmasq/dnsmasq.leases
4545
chmod 664 /etc/dnsmasq.conf /var/lib/dnsmasq/dnsmasq.leases
4646

47+
# probes that are created before start
48+
touch /bin/ironic-{readi,live}ness
49+
chown root:"${IRONIC_GROUP}" /bin/ironic-{readi,live}ness
50+
chmod 775 /bin/ironic-{readi,live}ness
51+
4752
setcap "cap_net_raw,cap_net_admin,cap_net_bind_service=+eip" /usr/sbin/dnsmasq

scripts/configure-ironic.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,20 @@ configure_client_basic_auth ironic-rpc
9898

9999
# Make sure ironic traffic bypasses any proxies
100100
export NO_PROXY="${NO_PROXY:-},$IRONIC_IP"
101+
102+
PROBE_CURL_ARGS=
103+
if [[ "${IRONIC_REVERSE_PROXY_SETUP}" == "true" ]]; then
104+
if [[ "${IRONIC_PRIVATE_PORT}" == "unix" ]]; then
105+
PROBE_URL="http://127.0.0.1:6385"
106+
PROBE_CURL_ARGS="--unix-socket /shared/ironic.sock"
107+
else
108+
PROBE_URL="http://127.0.0.1:${IRONIC_PRIVATE_PORT}"
109+
fi
110+
else
111+
PROBE_URL="${IRONIC_BASE_URL}"
112+
fi
113+
export PROBE_CURL_ARGS
114+
export PROBE_URL
115+
116+
PROBE_KIND=readiness render_j2_config /bin/ironic-probe.j2 /bin/ironic-readiness
117+
PROBE_KIND=liveness render_j2_config /bin/ironic-probe.j2 /bin/ironic-liveness

scripts/ironic-probe.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -eu -o pipefail
4+
5+
curl -sSf {{ env.PROBE_CURL_ARGS }} "{{ env.PROBE_URL }}"
6+
7+
# TODO(dtantsur): when PROBE_KIND==readiness, try the conductor and driver API
8+
# to make sure the conductor is ready. This requires having access to secrets
9+
# since these endpoints are authenticated.

0 commit comments

Comments
 (0)