mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 00:03:29 +03:00
2ff594f4bb
Add 'silo healthcheck [live|ready|cluster|cluster-read]', a thin anonymous HTTP client for the server's own /minio/health/* endpoints, so containers without a shell, curl, or mc can still run health checks. Design: silo.pgsty.com/compatibility/feature/healthcheck/ The check vocabulary maps 1:1 onto the health API paths; the probe target is derived from the server's own --address/MINIO_ADDRESS contract with HTTPS auto-detected from the certs directory, and can be overridden with --url. Exit codes are 0/1 only (Docker reserves 2); diagnostics (x-minio-server-status, quorum headers) go into a single output line for docker inspect. The request is strictly anonymous (a credentialed request would be rejected by the reserved-path guard), the transport bypasses HTTP_PROXY, and certificate verification is skipped to match kubelet HTTPS probe behavior. Cluster checks default to a 15s deadline so the server's 10s cluster_deadline can elapse. Compatibility notes: the preserved /minio/health/* path literals and the MINIO_ADDRESS env var are upstream wire/config surface, reused on purpose; the rebrand-guard baseline is regenerated for the new route literals (tests included) with zero new exported symbols. The docker entrypoint argv translation learns the new command name. Verified: unit tests, entrypoint tests, go vet, plus an end-to-end run against a live server covering all four checks, --maintenance (412), --json, usage errors, unreachable and timeout paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
77 lines
2.8 KiB
Bash
Executable File
77 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
work_dir="$(mktemp -d)"
|
|
trap 'rm -rf "${work_dir}"' EXIT
|
|
|
|
mkdir -p "${work_dir}/bin"
|
|
cat >"${work_dir}/bin/silo" <<'EOF'
|
|
#!/bin/sh
|
|
printf '%s\n' silo "$@" >"${ENTRYPOINT_CAPTURE}"
|
|
if [ -n "${ENTRYPOINT_HOME_CAPTURE:-}" ]; then
|
|
printf '%s\n' "${HOME:-}" >"${ENTRYPOINT_HOME_CAPTURE}"
|
|
fi
|
|
EOF
|
|
chmod +x "${work_dir}/bin/silo"
|
|
|
|
cat >"${work_dir}/bin/chroot" <<'EOF'
|
|
#!/bin/sh
|
|
printf '%s\n' "$1" "$2" >"${ENTRYPOINT_CHROOT_CAPTURE}"
|
|
shift 2
|
|
exec "$@"
|
|
EOF
|
|
chmod +x "${work_dir}/bin/chroot"
|
|
|
|
run_case() {
|
|
local name="$1"
|
|
local expected="$2"
|
|
shift 2
|
|
local capture="${work_dir}/${name}.actual"
|
|
local expected_file="${work_dir}/${name}.expected"
|
|
|
|
ENTRYPOINT_CAPTURE="${capture}" PATH="${work_dir}/bin:${PATH}" \
|
|
"${script_dir}/docker-entrypoint.sh" "$@"
|
|
printf '%s' "${expected}" >"${expected_file}"
|
|
diff -u "${expected_file}" "${capture}"
|
|
}
|
|
|
|
run_case default $'silo\n'
|
|
run_case server $'silo\nserver\n/data\n' server /data
|
|
run_case option $'silo\n--version\n' --version
|
|
run_case healthcheck $'silo\nhealthcheck\nready\n' healthcheck ready
|
|
run_case explicit-silo $'silo\nserver\n/data\n' silo server /data
|
|
run_case legacy-minio $'silo\nserver\n/data\n' minio server /data
|
|
|
|
shell_capture="${work_dir}/shell.actual"
|
|
# shellcheck disable=SC2016 # ENTRYPOINT_CAPTURE is expanded by the child shell.
|
|
ENTRYPOINT_CAPTURE="${shell_capture}" PATH="${work_dir}/bin:${PATH}" \
|
|
"${script_dir}/docker-entrypoint.sh" sh -c 'printf "%s\n" shell >"${ENTRYPOINT_CAPTURE}"'
|
|
test "$(cat "${shell_capture}")" = shell
|
|
|
|
rootless_capture="${work_dir}/rootless.actual"
|
|
rootless_home_capture="${work_dir}/rootless-home.actual"
|
|
rootless_chroot_capture="${work_dir}/rootless-chroot.actual"
|
|
ENTRYPOINT_CAPTURE="${rootless_capture}" \
|
|
ENTRYPOINT_HOME_CAPTURE="${rootless_home_capture}" \
|
|
ENTRYPOINT_CHROOT_CAPTURE="${rootless_chroot_capture}" \
|
|
HOME=/root MINIO_USERNAME=silo-user MINIO_GROUPNAME=silo-group \
|
|
MINIO_UID=1001 MINIO_GID=1002 PATH="${work_dir}/bin:${PATH}" \
|
|
"${script_dir}/docker-entrypoint.sh" silo --version
|
|
test "$(cat "${rootless_home_capture}")" = /tmp
|
|
test "$(sed -n '1p' "${rootless_chroot_capture}")" = --userspec=1001:1002
|
|
test "$(sed -n '2p' "${rootless_chroot_capture}")" = /
|
|
test "$(cat "${rootless_capture}")" = $'silo\n--version'
|
|
|
|
arbitrary_uid_capture="${work_dir}/arbitrary-uid.actual"
|
|
arbitrary_uid_home_capture="${work_dir}/arbitrary-uid-home.actual"
|
|
ENTRYPOINT_CAPTURE="${arbitrary_uid_capture}" \
|
|
ENTRYPOINT_HOME_CAPTURE="${arbitrary_uid_home_capture}" \
|
|
HOME="${work_dir}/missing-home" PATH="${work_dir}/bin:${PATH}" \
|
|
"${script_dir}/docker-entrypoint.sh" silo --version
|
|
test "$(cat "${arbitrary_uid_home_capture}")" = /tmp
|
|
test "$(cat "${arbitrary_uid_capture}")" = $'silo\n--version'
|
|
|
|
echo "docker entrypoint argv compatibility tests passed"
|