fix(cicd): push_retry 加 timeout 60s 包裹,自动处理跨地域 push 死锁
问题:跨地域推 Harbor 时 docker push 推大 layer TCP 死锁, 命令 hang 住不退出,push_retry 永远等不到重试触发。 修复: - 每次 docker push 用 timeout 60 包裹,超 60s 强制杀掉 CLI(断点续传) - 重试次数 10→15,给更多断点续传机会 - 被 timeout 杀掉后返回非零,自动进入下一次重试循环
This commit is contained in:
parent
2c11b45e31
commit
caf3c17fce
12
Jenkinsfile
vendored
12
Jenkinsfile
vendored
@ -51,14 +51,16 @@ pipeline {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: "harbor-credentials", usernameVariable: "HUSER", passwordVariable: "HPASS")]) {
|
||||
sh '''
|
||||
# 跨地域 push 大 blob 易断流 + Harbor auth session 会过期
|
||||
# 每次 push 前重新 login,组合成原子重试单元(断点续传,已传层跳过)
|
||||
# 跨地域 push 大 blob 易断流 + Harbor auth session 会过期 + 网络死锁
|
||||
# 每次 push 前重新 login,用 timeout 包裹防 hang 死,断点续传(已传层跳过)
|
||||
push_retry() {
|
||||
local img=$1
|
||||
for i in 1 2 3 4 5 6 7 8 9 10; do
|
||||
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
|
||||
echo $HPASS | docker login $HARBOR -u $HUSER --password-stdin >/dev/null 2>&1
|
||||
docker push "$img" && return 0
|
||||
echo "push $img 第 $i 次中断,5秒后重试(重新登录+断点续传)..."
|
||||
# timeout 60s:单次 push 超过 60s 强制杀掉(防 TCP 死锁 hang 住)
|
||||
# 被杀后返回非零 → 重试;断点续传已传 layer 跳过,每次推进一部分
|
||||
timeout 60 docker push "$img" && return 0
|
||||
echo "push $img 第 $i 次中断/超时,5秒后重试(重新登录+断点续传)..."
|
||||
sleep 5
|
||||
done
|
||||
return 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user