feat(queue): 增加非文本模型分布式准入队列
使用 PostgreSQL 统一同步与异步非文本任务的并发准入、持久化等待和 Worker 容量分配,并将生产 API 与独立 Worker 角色拆分。 补充策略管理、共享契约、OpenAPI、Kubernetes 双节点 Worker 清单及跨节点验收脚本;未默认启用任何生产 queue_size 策略。 已在原基线完成 Go、前端、迁移、Shell、Kustomize 与长任务容量验收;合入最新主干后将重新执行发布门禁。
This commit is contained in:
@@ -23,6 +23,11 @@ node "$cluster_root/scripts/release-manifest.mjs" validate "$release_manifest" >
|
||||
api_image=$(node "$cluster_root/scripts/release-manifest.mjs" get "$release_manifest" images.api)
|
||||
web_image=$(node "$cluster_root/scripts/release-manifest.mjs" get "$release_manifest" images.web)
|
||||
source_sha=$(node "$cluster_root/scripts/release-manifest.mjs" get "$release_manifest" sourceSha)
|
||||
activate_workers=${AI_GATEWAY_ACTIVATE_WORKERS:-true}
|
||||
[[ $activate_workers == true || $activate_workers == false ]] || {
|
||||
echo 'AI_GATEWAY_ACTIVATE_WORKERS must be true or false' >&2
|
||||
exit 64
|
||||
}
|
||||
[[ $api_image =~ ^registry\.cn-shanghai\.aliyuncs\.com/easyaigc/ai-gateway@sha256:[0-9a-f]{64}$ ]]
|
||||
[[ $web_image =~ ^registry\.cn-shanghai\.aliyuncs\.com/easyaigc/ai-gateway-web@sha256:[0-9a-f]{64}$ ]]
|
||||
|
||||
@@ -87,11 +92,28 @@ if [[ $mode == prepare ]]; then
|
||||
sed -i.bak 's/^ replicas: 1$/ replicas: 0/' "$working_directory/production/application.yaml"
|
||||
rm -f -- "$working_directory/production/application.yaml.bak"
|
||||
fi
|
||||
if [[ ${AI_GATEWAY_ACTIVATE_WORKERS:-true} == false ]]; then
|
||||
sed -i.bak \
|
||||
's/^ AI_GATEWAY_ASYNC_QUEUE_WORKER_ENABLED: "true"$/ AI_GATEWAY_ASYNC_QUEUE_WORKER_ENABLED: "false"/' \
|
||||
"$working_directory/production/application-config.yaml"
|
||||
rm -f -- "$working_directory/production/application-config.yaml.bak"
|
||||
if [[ $activate_workers == false ]]; then
|
||||
awk '
|
||||
/^---$/ {
|
||||
document_kind = ""
|
||||
worker_deployment = 0
|
||||
print
|
||||
next
|
||||
}
|
||||
/^kind: / {
|
||||
document_kind = $2
|
||||
}
|
||||
document_kind == "Deployment" && /^ name: easyai-worker-/ {
|
||||
worker_deployment = 1
|
||||
}
|
||||
worker_deployment && /^ replicas: 1$/ {
|
||||
sub(/1$/, "0")
|
||||
}
|
||||
{ print }
|
||||
' "$working_directory/production/application.yaml" \
|
||||
>"$working_directory/production/application.yaml.next"
|
||||
mv "$working_directory/production/application.yaml.next" \
|
||||
"$working_directory/production/application.yaml"
|
||||
fi
|
||||
kubectl kustomize "$working_directory/production" >"$working_directory/easyai-production.yaml"
|
||||
if rg -q 'sha256:0{64}|image: (easyai-api|easyai-web)$' "$working_directory/easyai-production.yaml"; then
|
||||
@@ -136,10 +158,12 @@ for file in "${platform_files[@]}"; do
|
||||
cluster_scp "$working_directory/$file" "$CLUSTER_NINGBO_HOST:/root/$file"
|
||||
done
|
||||
|
||||
cluster_ssh "$CLUSTER_NINGBO_HOST" bash -s -- "$source_sha" "$mode" <<'REMOTE'
|
||||
cluster_ssh "$CLUSTER_NINGBO_HOST" bash -s -- \
|
||||
"$source_sha" "$mode" "$activate_workers" <<'REMOTE'
|
||||
set -euo pipefail
|
||||
source_sha=$1
|
||||
mode=$2
|
||||
activate_workers=$3
|
||||
kubectl='k3s kubectl'
|
||||
runtime_environment=
|
||||
cleanup_bootstrap_files() {
|
||||
@@ -234,6 +258,10 @@ $kubectl apply --server-side --dry-run=server --force-conflicts \
|
||||
$kubectl apply -f /root/easyai-production.yaml >/dev/null
|
||||
$kubectl annotate namespace easyai easyai.io/release="$source_sha" --overwrite >/dev/null
|
||||
if [[ $mode == activate ]]; then
|
||||
if [[ $activate_workers == true ]]; then
|
||||
$kubectl rollout status deployment/easyai-worker-hongkong -n easyai --timeout=300s
|
||||
$kubectl rollout status deployment/easyai-worker-ningbo -n easyai --timeout=300s
|
||||
fi
|
||||
$kubectl rollout status deployment/easyai-api-hongkong -n easyai --timeout=300s
|
||||
$kubectl rollout status deployment/easyai-web-hongkong -n easyai --timeout=300s
|
||||
$kubectl rollout status deployment/easyai-api-ningbo -n easyai --timeout=300s
|
||||
|
||||
Reference in New Issue
Block a user