ci: retry transient registry failures
Deploy olons-admin production / deploy (push) Successful in 47s

This commit is contained in:
Your Name
2026-10-18 23:55:22 +08:00
parent c8d32eb823
commit e3898b618c
2 changed files with 23 additions and 3 deletions
+19 -3
View File
@@ -62,7 +62,23 @@ jobs:
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts"
chmod 600 "$HOME/.ssh/known_hosts"
SSH_ARGS=(-i "$KEY_FILE" -o BatchMode=yes -o StrictHostKeyChecking=yes)
printf '%s' "$REGISTRY_TOKEN" | ssh "${SSH_ARGS[@]}" "$DEPLOY_USER@$DEPLOY_HOST" \
"docker login git.olns.shop -u admin --password-stdin"
for attempt in 1 2 3; do
if printf '%s' "$REGISTRY_TOKEN" | ssh "${SSH_ARGS[@]}" "$DEPLOY_USER@$DEPLOY_HOST" \
"docker login git.olns.shop -u admin --password-stdin"; then
break
fi
if [[ "$attempt" -eq 3 ]]; then
exit 1
fi
sleep "$((attempt * 5))"
done
ssh "${SSH_ARGS[@]}" "$DEPLOY_USER@$DEPLOY_HOST" \
"cd /opt/olns && docker compose pull olons-admin && docker compose up -d --no-deps --wait olons-admin"
'cd /opt/olns && for attempt in 1 2 3; do
if timeout 180 docker compose pull olons-admin; then
break
fi
if [ "$attempt" -eq 3 ]; then
exit 1
fi
sleep $((attempt * 5))
done && docker compose up -d --no-deps --wait olons-admin'
+4
View File
@@ -29,6 +29,10 @@ class DeployWorkflowContractTest(unittest.TestCase):
self.assertIn("docker compose pull olons-admin", self.workflow)
self.assertIn("docker compose up -d --no-deps --wait olons-admin", self.workflow)
def test_retries_transient_remote_registry_failures(self):
self.assertGreaterEqual(self.workflow.count("for attempt in 1 2 3"), 2)
self.assertIn("timeout 180 docker compose pull olons-admin", self.workflow)
def test_removes_old_kubernetes_and_registry_targets(self):
self.assertNotIn("kubectl", self.workflow)
self.assertNotIn("KUBECONFIG", self.workflow)