DOCS/troubleshooting/250915_happybell80_rb8001_stats_api_중복_제거.md
happybell80 d890e32a0d fix: rb8001 stats API 문서 사실 검증 수정
- rb8001과 rb10408_test 에러 메시지 구분 명시
- router.py 162줄은 주석만 존재 (호출 코드 없음)
- 확인된 사실만 기록, 추측 제거
2025-09-15 19:55:55 +09:00

3.1 KiB

rb8001 Stats API 중복 구현 조사

작성일: 2025-09-15

작성자: happybell80

상태: 조사 완료


현재 상황

에러 메시지

  • rb8001 에러: Failed to fetch stats: {e}
    • 파일: /home/happybell/projects/ivada/rb8001/app/brain/brain_service.py:56
  • rb10408_test 에러: Failed to load stats: {e}
    • 파일: /home/happybell/projects/ivada/rb10408_test/app/router/router.py:70
  • rb8001 router.py 현재 상태:
    • 80-82줄: _load_stats_from_state() 함수 본문이 pass로만 구성
    • 162줄: 주석 # 1. 스탯 로드 - 제거됨 (robeing-monitor가 담당)

Stats API 엔드포인트 현황

1. rb8001 내부 구현

  • 파일: /home/happybell/projects/ivada/rb8001/app/state/state_service.py
  • GET 엔드포인트: @app.get("/api/stats/{robeing_id}") (67줄)
  • PUT 엔드포인트: @app.put("/api/stats/{robeing_id}") (89줄)
  • DB 모델: RobeingStats (database.py:24-41)
    • 필드: robeing_id, ethics, stat_points 포함
    • 테이블명: "robeing"

2. robeing-monitor 구현 (포트 9024)

  • 파일: /home/happybell/projects/ivada/robeing-monitor/app/state/state_service.py
  • GET 엔드포인트: @app.get("/stats/{robeing_id}") (53줄) - /api 없음
  • PUT 엔드포인트: @app.put("/stats/{robeing_id}") (75줄) - /api 없음
  • DB 모델: RobeingStats (database.py:20-34)
    • 필드: robeing_container_id 사용 (robeing_id 아님)
    • ethics, stat_points 필드 없음
    • 테이블명: "robeing"

3. robeing-gateway 프록시

  • 파일: /home/happybell/projects/ivada/robeing-gateway/app/main.py:304
  • 프록시: f"http://192.168.219.52:9024/api/stats/{robeing_id}"
  • 문제: gateway는 /api/stats/로 프록시하지만 monitor는 /stats/로 서비스

Stats API 호출자

1. rb8001/app/brain/brain_service.py

  • GET 호출: 48줄 f"{settings.STATE_SERVICE_URL}/api/stats/{robeing_id}"
  • PUT 호출: 110줄 f"{settings.STATE_SERVICE_URL}/api/stats/{robeing_id}"
  • 에러 로깅: 56줄 Failed to fetch stats
  • 설정: settings.STATE_SERVICE_URL (config.py:51, 기본값 None)

2. rb8001/app/brain/state_client.py

  • base_url: os.getenv('STATE_SERVICE_URL', 'http://localhost:8507') (17줄)
  • GET 메서드: 25줄 f"{self.base_url}/api/stats/{self.robeing_id}"
  • PUT 메서드: 68줄 f"{self.base_url}/api/stats/{self.robeing_id}"
  • 싱글톤: state_client = StateServiceClient() (168줄)
  • 참고: rb8001 내에서 state_client 직접 사용 흔적 없음

설정값

  • config.py:51: STATE_SERVICE_URL: Optional[str] = None
  • state_client.py:17: os.getenv('STATE_SERVICE_URL', 'http://localhost:8507')

확인된 사실

  1. 경로 불일치:
    • robeing-monitor 실제 엔드포인트: /stats/{robeing_id}
    • robeing-gateway 프록시 대상: /api/stats/{robeing_id}
  2. DB 스키마 차이:
    • rb8001 RobeingStats: robeing_id 필드 사용
    • robeing-monitor RobeingStats: robeing_container_id 필드 사용
  3. 필드 차이:
    • rb8001: ethics, stat_points 필드 존재
    • robeing-monitor: 해당 필드 없음