문제: nightly의 redis-topology 8.2 standalone·sentinel·cluster가 run 63에서 RedisTopologyContractTest 「admin 계정이 ADMIN_ONLY 진단을 모두 쓸 수 있다」로 실패한다. 7.2·7.4는 통과한다. 원인은 둘이다. - 명령 정책 catalog는 search 모듈의 FT.INFO를 8.0부터 ADMIN_ONLY로 둔다. fixture ACL의 admin 줄에는 그 권한이 없다(standalone: 거부). - sentinel·cluster lane은 entrypoint를 덮어써 `redis-server`를 바로 실행한다. Redis 8 이미지의 docker-entrypoint.sh가 모듈을 싣는데 그것을 건너뛰어 FT.INFO 자체가 없다(「있어야 할 서버에 없다」). desktop에서 확인: Redis 7.2·7.4는 ACL 규칙 `+ft.info`가 있으면 시작을 거부하고, 8.2는 모듈을 실었을 때만 받는다. cluster 모드에서도 search 모듈은 실리고 FT.INFO가 생긴다. 고른 방법: - sentinel·cluster 데이터 노드가 `exec docker-entrypoint.sh redis-server`로 standalone처럼 이미지 entrypoint를 거친다. 서버도 root가 아니라 이미지의 redis 사용자로 돈다. - 네 구성의 ACL 마운트 원본을 `REDIS_ACL_DIR`로 바꿀 수 있게 한다(기본값은 지금 폴더). redis-topology.sh가 8 이상에서만 커밋한 ACL 파일에서 admin 줄 끝에 `+ft.info`를 더한 사본을 build/ 아래 만들어 쓴다. 실행마다 원본에서 만들어 어긋날 수 없다. ACL README에 이 예외를 적는다. 버린 대안: 버전별 ACL 파일을 하나 더 커밋하기. README가 금하는 두 번째 사본이다. catalog에서 FT.INFO를 빼기. SDK가 문서로 지원한다고 한 진단이다. 위험·한계: entrypoint를 거치며 7.x에서도 서버 사용자가 redis로 바뀐다. /tmp의 nodes.conf와 읽기 전용 ACL 마운트는 그 사용자도 읽고 쓸 수 있다. 검증: runner redis-topology 11칸(nightly 수동 실행, 이 PR 본문에 적는다).
94 lines
4.8 KiB
Bash
Executable File
94 lines
4.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# One Redis topology lane against a real server: start the Compose topology, run the leaves'
|
|
# `redisTopologyTest` for it, print the evidence manifest, stop the topology. Called by the
|
|
# `redis-topology` nightly job of .gitea/workflows/main.yml (one call per matrix row); a person can
|
|
# run the same line on a machine with Docker.
|
|
#
|
|
# bash scripts/ci/redis-topology.sh <standalone|sentinel|cluster|tls> <redis version>
|
|
#
|
|
# The lanes are explicitOnly: they need the endpoint this script passes, so no stage runs them
|
|
# (docs/redis/support-matrix.md records which lane produced which evidence). Each Gradle task fails
|
|
# closed on its own account: an unknown mode, a missing endpoint, a lane with no tagged test class
|
|
# and a run that executed zero tests are all errors.
|
|
set -euo pipefail
|
|
|
|
topology=${1:?topology}
|
|
version=${2:?redis version}
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
|
compose=(docker compose -f "src/adapter/outbound/redis-sdk/compose/${topology}/compose.yml")
|
|
forwarder=''
|
|
stop() {
|
|
[ -z "${forwarder}" ] || kill "${forwarder}" 2>/dev/null || true
|
|
"${compose[@]}" down -v
|
|
}
|
|
trap stop EXIT
|
|
|
|
runtime=:adapter:outbound:redis-runtime:redisTopologyTest
|
|
sdk=:adapter:outbound:redis-sdk:redisTopologyTest
|
|
semantic=:adapter:outbound:cache-redis:redisTopologyTest
|
|
extra=()
|
|
case "${topology}" in
|
|
standalone) port=6379; ports=(6379); tasks=("${runtime}" "${sdk}" "${semantic}") ;;
|
|
sentinel) port=27010; ports=(7010 7011 27010 27011 27012); tasks=("${runtime}" "${sdk}"); extra=(-Predis.topology.master=skeleton) ;;
|
|
cluster) port=7100; ports=(7100 7101 7102 7103 7104 7105); tasks=("${runtime}" "${sdk}" "${semantic}") ;;
|
|
tls) port=6390; ports=(6390); tasks=("${runtime}") ;;
|
|
*) echo "redis-topology: unknown topology ${topology}" >&2; exit 2 ;;
|
|
esac
|
|
|
|
# Redis 8 ships the search module, and the command catalog makes its FT.INFO an admin diagnostic
|
|
# from 8.0 (ADMIN_ONLY). The committed fixture ACL cannot grant it: one file serves every version,
|
|
# and Redis 7 refuses to start on a rule that names a command it does not have. On 8 and later the
|
|
# lane mounts a copy whose admin line also grants +ft.info, made here from that one file so the two
|
|
# cannot drift (compose/redis/acl/README.md).
|
|
if [ "${version%%.*}" -ge 8 ]; then
|
|
acl_dir="${PWD}/src/adapter/outbound/redis-sdk/build/redis-topology-acl"
|
|
rm -rf "${acl_dir}"
|
|
mkdir -p "${acl_dir}"
|
|
sed '/^user ca-skeleton-admin-readonly /s/$/ +ft.info/' compose/redis/acl/lane-fixture-accounts.acl \
|
|
> "${acl_dir}/lane-fixture-accounts.acl"
|
|
grep -q '^user ca-skeleton-admin-readonly .* +ft\.info$' "${acl_dir}/lane-fixture-accounts.acl" \
|
|
|| { echo "redis-topology: the admin line of the fixture ACL was not found" >&2; exit 1; }
|
|
# Read by the image's redis user, which is not the user that made the copy.
|
|
chmod 0755 "${acl_dir}"
|
|
chmod 0644 "${acl_dir}/lane-fixture-accounts.acl"
|
|
export REDIS_ACL_DIR="${acl_dir}"
|
|
fi
|
|
|
|
REDIS_VERSION=${version} "${compose[@]}" up -d --wait
|
|
|
|
# Inside a CI job container the Docker daemon's ports are on the daemon host, not on localhost, and
|
|
# the lanes are built around localhost (cluster redirects announce 127.0.0.1, the TLS certificate
|
|
# names localhost). Forward them, so the lane runs exactly as it does on a workstation.
|
|
if [ -f /.dockerenv ]; then
|
|
# The default gateway of the job's network is the daemon host. /proc/net/route stores it as
|
|
# little-endian hex; awk reads "0x.." as 0 and would point the forwarder at itself.
|
|
daemon_host=$(python3 -c 'import socket, struct
|
|
for line in open("/proc/net/route").readlines()[1:]:
|
|
fields = line.split()
|
|
if fields[1] == "00000000":
|
|
print(socket.inet_ntoa(struct.pack("<L", int(fields[2], 16))))
|
|
break')
|
|
[ -n "${daemon_host}" ] && [ "${daemon_host}" != 0.0.0.0 ] \
|
|
|| { echo "redis-topology: no default gateway to reach the Docker daemon host" >&2; exit 1; }
|
|
python3 scripts/ci/forward-ports.py "${daemon_host}" "${ports[@]}" &
|
|
forwarder=$!
|
|
sleep 1
|
|
fi
|
|
|
|
# The tag says 7.4; the digest says which 7.4. Evidence that names only the tag cannot be reproduced
|
|
# once the tag moves, so a run that cannot name its digest has nothing to certify.
|
|
digest=$(docker image inspect --format '{{index .RepoDigests 0}}' "redis:${version}")
|
|
[ -n "${digest}" ] || { echo "redis-topology: no repository digest for redis:${version}" >&2; exit 1; }
|
|
if [ "${topology}" = tls ]; then
|
|
trust=$(mktemp "${RUNNER_TEMP:-/tmp}/redis-lane-ca.XXXXXX")
|
|
"${compose[@]}" cp redis:/tls/ca.crt "${trust}"
|
|
extra=(-Predis.topology.trust-material="${trust}")
|
|
fi
|
|
|
|
./gradlew "${tasks[@]}" --continue \
|
|
-Predis.topology.host=localhost -Predis.topology.port="${port}" -Predis.topology.mode="${topology}" \
|
|
"${extra[@]}"
|
|
|
|
printf 'evidence: commit=%s run=%s topology=%s redis_version=%s image_digest=%s\n' \
|
|
"$(git rev-parse HEAD)" "${GITHUB_RUN_ID:-local}" "${topology}" "${version}" "${digest}"
|