fix(devops): 移除 startup 腳本危險 compose 操作
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
OoO
2026-04-30 14:05:41 +08:00
parent 89e7f2ccd2
commit db21e7e8e8
3 changed files with 26 additions and 6 deletions

View File

@@ -191,10 +191,10 @@ sudo tail -f /var/log/momo_startup.log
# 檢查 Harbor 日誌
docker logs harbor-core
# 全重啟 Harbor
# 全重啟 HarborADR-011禁止 down / --remove-orphans
cd /home/wooo/devops/harbor/harbor
docker compose down --remove-orphans
docker compose up -d
docker compose stop
docker compose up -d --force-recreate
```
### K8s Pod ImagePullBackOff

View File

@@ -126,10 +126,10 @@ main() {
log_info "[2/7] 啟動 Harbor Registry..."
cd /home/wooo/devops/harbor/harbor
# 確保完全停止後再啟動
docker compose down --remove-orphans 2>/dev/null || true
# ADR-011: 多專案共享主機避免使用會清除 orphan 資源的 compose 操作。
docker compose stop 2>/dev/null || true
sleep 5
docker compose up -d
docker compose up -d --force-recreate
wait_for_service "Harbor" "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:5050/api/v2.0/ping | grep -q 200" 60 || {
((errors++))

View File

@@ -87,3 +87,23 @@ def test_tracked_backup_artifacts_stay_removed():
]
assert [path for path in forbidden_artifacts if (ROOT / path).exists()] == []
def test_executable_scripts_do_not_use_remove_orphans():
script_paths = [
ROOT / "scripts",
ROOT / ".gitea" / "workflows",
]
offenders = []
for script_root in script_paths:
if not script_root.exists():
continue
for path in script_root.rglob("*"):
if not path.is_file():
continue
content = path.read_text(encoding="utf-8", errors="ignore")
if "--remove-orphans" in content or "docker compose down" in content:
offenders.append(str(path.relative_to(ROOT)))
assert offenders == []