feat: gated deploy with preview, audit log, rollback trail (stage 4)

- pulp_client: create_publication / update_distribution / wait_for_task
- GET /repos/{uuid}/deploy/confirm: 미리보기(현재→대상, 순 변화) + type-to-confirm 모달
- POST /repos/{uuid}/deploy: 검증 게이트(서버측 재확인) → publication 생성 →
  distribution 교체 → 감사 로그. 2단계 실패 시 '운영망 변경 여부' 명확화
- audit.record_deploy: 누가/언제/repo/이전버전→대상버전 JSONL (롤백 추적)
- 배포 버튼은 검증 통과 + 미배포 버전만 활성, 성공 시 버전목록 OOB 갱신
- 인증은 TODO (operator placeholder, 배포 비밀번호 재확인 예정)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-17 13:31:15 +09:00
parent 72c75252d3
commit 7ad6d65a11
17 changed files with 692 additions and 29 deletions

View File

@@ -9,6 +9,7 @@
from __future__ import annotations
import time
from typing import Any
import httpx
@@ -105,3 +106,39 @@ class PulpClient:
def get_task(self, task_href: str) -> dict[str, Any]:
"""task 단건 조회 (state, progress_reports, created_resources, error)."""
return self.get(task_href)
def create_publication(self, version_href: str) -> str:
"""특정 버전을 배포 가능한 형태로: POST /publications/rpm/rpm/ → task_href.
완료 후 task.created_resources 에서 publication href 를 얻는다.
"""
data = self.post(
f"{API_PREFIX}/publications/rpm/rpm/",
json={"repository_version": version_href},
)
return data["task"]
def update_distribution(self, dist_href: str, publication_href: str) -> str:
"""배포 확정: PATCH {dist_href} publication 교체 → task_href.
운영망이 보는 URL 이 이 publication 을 가리키게 된다(실제 배포 동작, 스펙 §4).
"""
data = self.patch(dist_href, json={"publication": publication_href})
return data["task"]
def wait_for_task(
self, task_href: str, attempts: int = 120, delay: float = 1.0
) -> dict[str, Any]:
"""task 가 종료 상태(completed/failed/canceled)가 될 때까지 대기 후 반환.
배포는 (publication 생성 → distribution 교체) 2단계 task 라 결과 확정이 필요해
서버측에서 짧게 대기한다. 화면 폴링이 어려운 복합 동작에 한정해서 쓴다.
"""
terminal = {"completed", "failed", "canceled"}
task = self.get_task(task_href)
for _ in range(attempts):
if task.get("state") in terminal:
return task
time.sleep(delay)
task = self.get_task(task_href)
return task