release: bump version to 0.74.6
This commit is contained in:
50
scripts/lib/docker-proxy.zsh
Normal file
50
scripts/lib/docker-proxy.zsh
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
prepare_docker_build_proxy() {
|
||||
# Desktop and remote/rootless daemons are managed in their own environment.
|
||||
docker_uses_local_engine || return 0
|
||||
docker_desktop_present && return 0
|
||||
|
||||
local python_bin="$(command -v python3)"
|
||||
local helper="$SCRIPT_DIR/scripts/docker_proxy.py"
|
||||
local plan_file error_file
|
||||
local mode changed connected status_text
|
||||
if [ -z "$python_bin" ] || ! plan_file="$(mktemp "$PLANET_STATE_DIR/docker-proxy.XXXXXX")"; then
|
||||
log_error "Docker 构建代理检测失败"
|
||||
return 1
|
||||
fi
|
||||
error_file="${plan_file}.error"
|
||||
chmod 600 "$plan_file"
|
||||
: > "$error_file"
|
||||
chmod 600 "$error_file"
|
||||
{
|
||||
if ! "$python_bin" "$helper" plan > "$plan_file" 2> "$error_file"; then
|
||||
log_error "Docker 构建代理检测失败" "$error_file"
|
||||
return 1
|
||||
fi
|
||||
if ! status_text="$("$python_bin" "$helper" status < "$plan_file" 2> "$error_file")"; then
|
||||
log_error "Docker 构建代理检测失败" "$error_file"
|
||||
return 1
|
||||
fi
|
||||
read -r mode changed connected <<< "$status_text"
|
||||
if [ "$changed" -eq 1 ]; then
|
||||
docker_require_sudo || return 1
|
||||
log_note "更新 Docker 构建代理配置,重启后恢复原先运行的容器"
|
||||
if ! docker_as_root "$python_bin" "$helper" apply < "$plan_file" 2> "$error_file"; then
|
||||
log_error "Docker 构建代理更新失败" "$error_file"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ "$connected" -ne 1 ]; then
|
||||
log_error "PLANET_PROXY_NO_ROUTE"
|
||||
return 1
|
||||
fi
|
||||
if [ "$mode" = proxy ]; then
|
||||
log_note "Docker 构建使用已验证可用的主机代理"
|
||||
else
|
||||
log_note "未发现可用主机代理,Docker 构建使用直连"
|
||||
fi
|
||||
} always {
|
||||
rm -f -- "$plan_file" "$error_file"
|
||||
}
|
||||
}
|
||||
61
scripts/lib/error-diagnostics.zsh
Normal file
61
scripts/lib/error-diagnostics.zsh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# The operator-facing table is also the runtime source of diagnostic wording.
|
||||
planet_error_record() {
|
||||
local message="$1"
|
||||
local evidence_file="${2:-/dev/null}"
|
||||
local catalog="$SCRIPT_DIR/docs/technical/zh/ops-runbook.md"
|
||||
[ -r "$catalog" ] || return 1
|
||||
[ -r "$evidence_file" ] || evidence_file=/dev/null
|
||||
|
||||
awk -F '|' -v message="$message" '
|
||||
function trim(value) {
|
||||
sub(/^[[:space:]]+/, "", value)
|
||||
sub(/[[:space:]]+$/, "", value)
|
||||
return value
|
||||
}
|
||||
NR == FNR {
|
||||
if ($0 == "<!-- planet-error-catalog:start -->") active = 1
|
||||
if ($0 == "<!-- planet-error-catalog:end -->") active = 0
|
||||
if (active && trim($2) ~ /^P_[A-Z_]+$/) {
|
||||
count++
|
||||
codes[count] = trim($2)
|
||||
signals[count] = tolower(trim($3))
|
||||
reasons[count] = trim($4)
|
||||
actions[count] = trim($5)
|
||||
if (codes[count] == "P_UNKNOWN") fallback = count
|
||||
}
|
||||
next
|
||||
}
|
||||
{ evidence = evidence "\n" tolower($0) }
|
||||
END {
|
||||
evidence = tolower(message) "\n" evidence
|
||||
selected = fallback
|
||||
for (i = 1; i <= count; i++) {
|
||||
if (i == fallback) continue
|
||||
size = split(signals[i], patterns, ";")
|
||||
for (j = 1; j <= size; j++) {
|
||||
pattern = trim(patterns[j])
|
||||
if (length(pattern) && index(evidence, pattern)) {
|
||||
selected = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if (selected != fallback) break
|
||||
}
|
||||
if (!selected) exit 1
|
||||
printf "%s\t%s\t%s\n", codes[selected], reasons[selected], actions[selected]
|
||||
}
|
||||
' "$catalog" "$evidence_file"
|
||||
}
|
||||
|
||||
report_error_reason() {
|
||||
local record code reason action
|
||||
if ! record="$(planet_error_record "$1" "${2:-/dev/null}")"; then
|
||||
log_note "无法读取运维错误对照表,请检查 docs/technical/zh/ops-runbook.md"
|
||||
return 0
|
||||
fi
|
||||
IFS=$'\t' read -r code reason action <<< "$record"
|
||||
log_note "原因 [${code}]: ${reason}"
|
||||
log_note "处理: ${action}"
|
||||
}
|
||||
Reference in New Issue
Block a user