fix(acceptance): 移除生产验收持久管理隧道

管理 API 改为通过短 SSH 在宁波节点调用内部 api-ningbo-edge Service,避免长期端口转发与大量集群控制连接竞争导致 SSH 握手限流。Token 和请求体以 Base64 传输且不输出。\n\n验证:内部 traffic-mode 端到端返回 200;GNU Bash 3.2;bash -n;shellcheck -x -P .;git diff --check。
This commit is contained in:
2026-07-31 00:41:56 +08:00
parent 0e22ccb0b8
commit 3b67038660
+46 -14
View File
@@ -95,6 +95,7 @@ stable_profile=P24
active_profile=P24
failure_reason=
failure_recorded=false
acceptance_admin_base=
cleanup() {
local status=$?
@@ -130,21 +131,52 @@ admin_request() {
local path=$2
local body=${3:-}
local output=$4
local admin_base=${AI_GATEWAY_ACCEPTANCE_GATEWAYS%%,*}
local status
if [[ -n $body ]]; then
status=$(curl -sS --max-time 30 -o "$output" -w '%{http_code}' \
-X "$method" \
-H "Authorization: Bearer $AI_GATEWAY_ACCEPTANCE_ADMIN_TOKEN" \
-H 'Content-Type: application/json' \
--data-binary "$body" \
"$admin_base$path")
else
status=$(curl -sS --max-time 30 -o "$output" -w '%{http_code}' \
-X "$method" \
-H "Authorization: Bearer $AI_GATEWAY_ACCEPTANCE_ADMIN_TOKEN" \
"$admin_base$path")
local status response payload token_encoded body_encoded has_body=false
local service_ip service_port remote_script remote_command
if [[ -z $acceptance_admin_base ]]; then
service_ip=$(remote_kubectl get service api-ningbo-edge -n "$namespace" \
-o 'jsonpath={.spec.clusterIP}')
service_port=$(remote_kubectl get service api-ningbo-edge -n "$namespace" \
-o 'jsonpath={.spec.ports[0].port}')
[[ $service_ip =~ ^[0-9.]+$ && $service_port =~ ^[0-9]+$ ]] || {
echo 'acceptance admin Service has an invalid cluster address' >&2
return 1
}
acceptance_admin_base=http://$service_ip:$service_port
fi
token_encoded=$(printf '%s' "$AI_GATEWAY_ACCEPTANCE_ADMIN_TOKEN" |
openssl base64 -A)
body_encoded=$(printf '%s' "$body" | openssl base64 -A)
[[ -n $body ]] && has_body=true
# shellcheck disable=SC2016 # This script is quoted for execution on the remote node.
remote_script='
set -euo pipefail
admin_base=$1
method=$2
path=$3
token=$(printf "%s" "$4" | base64 -d)
body=$(printf "%s" "$5" | base64 -d)
has_body=$6
if [[ $has_body == true ]]; then
curl -sS --max-time 30 -w "\n%{http_code}" -X "$method" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json" \
--data-binary "$body" "$admin_base$path"
else
curl -sS --max-time 30 -w "\n%{http_code}" -X "$method" \
-H "Authorization: Bearer $token" "$admin_base$path"
fi
'
printf -v remote_command 'bash -c %q -- %q %q %q %q %q %q' \
"$remote_script" "$acceptance_admin_base" "$method" "$path" \
"$token_encoded" "$body_encoded" "$has_body"
if ! response=$(cluster_ssh "$CLUSTER_NINGBO_HOST" "$remote_command"); then
echo "acceptance control API transport failed: method=$method path=$path" >&2
return 1
fi
status=${response##*$'\n'}
payload=${response%$'\n'*}
printf '%s' "$payload" >"$output"
[[ $status =~ ^2[0-9][0-9]$ ]] || {
echo "acceptance control API failed: method=$method path=$path status=$status" >&2
return 1