Skip to content

Commit 5fade07

Browse files
Merge pull request #493 from metal3-io-bot/cherry-pick-492-to-release-24.1
✨ Provide scripts to be used as liveness/readiness probes
2 parents 149fc6e + e44c4f7 commit 5fade07

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)