fix: /api/health degraded 시 HTTP 503 반환 (#14) #40

Merged
xhh merged 1 commit from issue-14-health-503 into main 2026-04-22 22:26:09 +09:00
Owner

Summary

DB 테이블 조회가 하나라도 실패하면 status=degraded + HTTP 503. Docker healthcheck(curl -fsS) 와 로드밸런서가 비정상 상태를 감지할 수 있게 된다.

  • routers/system.py::healthResponse 의존성으로 503 세팅
  • 지역변수 statushealth_status 리네임 (FastAPI status 모듈 섀도잉 방지)
  • OpenAPI responses 에 503 명시
  • 회귀 테스트 1건 추가 (TRACKED_TABLES monkeypatch)

Test plan

  • ruff check clean
  • 48 tests pass (47 → 48)
  • Docker healthcheck (curl -fsS) 는 5xx 를 실패로 인식 → 컨테이너 unhealthy 마킹

Closes #14

## Summary DB 테이블 조회가 하나라도 실패하면 `status=degraded` + HTTP 503. Docker healthcheck(`curl -fsS`) 와 로드밸런서가 비정상 상태를 감지할 수 있게 된다. - `routers/system.py::health` 에 `Response` 의존성으로 503 세팅 - 지역변수 `status` → `health_status` 리네임 (FastAPI status 모듈 섀도잉 방지) - OpenAPI `responses` 에 503 명시 - 회귀 테스트 1건 추가 (TRACKED_TABLES monkeypatch) ## Test plan - [x] ruff check clean - [x] 48 tests pass (47 → 48) - [x] Docker healthcheck (`curl -fsS`) 는 5xx 를 실패로 인식 → 컨테이너 unhealthy 마킹 Closes #14
fix: /api/health degraded 시 HTTP 503 반환 (#14)
All checks were successful
Tests (PR) / pytest (pull_request) Successful in 23s
84e419d729
DB 테이블 조회가 하나라도 실패하면 status=degraded 와 함께 503 으로
응답. Docker healthcheck(`curl -fsS`) 와 로드밸런서 프로브가 비정상
상태를 감지해 재시작/라우팅 차단을 트리거할 수 있게 된다.

- `routers/system.py::health` 에 `Response` 의존성 추가 후 503 세팅.
  기존 지역 변수 `status` 가 FastAPI `status` 모듈과 섀도잉 되므로
  `health_status` 로 리네임.
- OpenAPI responses 에 503 스키마 명시 (문서화용).
- 회귀 테스트: TRACKED_TABLES 에 존재하지 않는 테이블을 monkeypatch
  로 주입 → 503 + tables[missing] == -1 검증.

48 tests pass (47 → 48).

Closes #14

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
xhh merged commit bac8011867 into main 2026-04-22 22:26:09 +09:00
xhh deleted branch issue-14-health-503 2026-04-22 22:26:09 +09:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
xhh/financial-data-platform!40
No description provided.