fix(deploy-mining): 预拉取 Kafka CLI 镜像避免 timeout 期间拉取失败
standalone 模式下 run_kafka_cmd 使用 docker run confluentinc/cp-kafka:7.5.0, 首次运行时镜像未缓存导致 docker pull 被 timeout 30 截断,循环重试卡住。 添加 ensure_kafka_image() 在执行命令前先确保镜像已拉取。 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d53c2212a6
commit
0156be8d25
|
|
@ -330,13 +330,21 @@ run_psql() {
|
|||
# ===========================================================================
|
||||
# Helper: Execute Kafka admin command (auto-detect Docker or remote)
|
||||
# ===========================================================================
|
||||
ensure_kafka_image() {
|
||||
local image="confluentinc/cp-kafka:7.5.0"
|
||||
if ! docker image inspect "$image" &>/dev/null; then
|
||||
log_info "Pulling Kafka CLI image: $image (first time only)..."
|
||||
docker pull "$image"
|
||||
fi
|
||||
}
|
||||
|
||||
run_kafka_cmd() {
|
||||
local cmd="$1"
|
||||
shift
|
||||
|
||||
if [ "$DEPLOY_MODE" = "standalone" ]; then
|
||||
# Standalone: Kafka is remote, use temporary container with host networking
|
||||
# Add timeout to prevent hangs when Kafka is unreachable across servers
|
||||
ensure_kafka_image
|
||||
timeout 30 docker run --rm --network host confluentinc/cp-kafka:7.5.0 \
|
||||
$cmd --bootstrap-server "$KAFKA_BROKERS" "$@"
|
||||
return $?
|
||||
|
|
@ -364,6 +372,7 @@ run_kafka_cmd_stdin() {
|
|||
shift
|
||||
|
||||
if [ "$DEPLOY_MODE" = "standalone" ]; then
|
||||
ensure_kafka_image
|
||||
timeout 30 docker run --rm -i --network host confluentinc/cp-kafka:7.5.0 \
|
||||
$cmd --bootstrap-server "$KAFKA_BROKERS" "$@"
|
||||
return $?
|
||||
|
|
|
|||
Loading…
Reference in New Issue