[FIX#348] Makefile run-issuetracker — chrome 실제 포트 dynamic discovery - #349
Conversation
…348) 문제: - compose chrome 서비스의 host_port_range (9222-9229) 가 Docker engine 의 internal counter drift 로 9226/9227 등에 할당됨 - 그러나 deployments/docker/.env 의 FETCHER_CHROMEDP_REMOTE_URLS=ws://localhost:9222,9223 는 정적 → 앱이 chrome 에 연결 불가 - 라이브 기동 시마다 매번 env override 필요 수정: 1. chrome-remote-urls target 신설 — compose ps 출력 파싱으로 host 포트 추출 후 ws:// URL 목록 (콤마 구분) stdout 출력. 단일 책임으로 분리하여 inspection / 재사용 가능. 2. run-issuetracker 가 build 후 chrome-remote-urls 결과를 export 한 채 entrypoint 실행. chrome 컨테이너가 없으면 (URLs 빈 문자열) .env 의 FETCHER_CHROMEDP_REMOTE_URLS 로 fallback — 기존 동작 보존. 검증: - chrome 이 9226/9227 에 할당된 상태에서 make run-issuetracker 실행 시 'Discovered chrome remote URLs: ws://localhost:9226,ws://localhost:9227' 출력 후 앱이 정상 boot — 모든 crawler 등록 + scheduler tick 정상. scope 외: docker engine port counter 자체는 그대로 — 컨테이너가 9226/9227 에 떠도 앱이 정합.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThe Makefile is enhanced to dynamically discover Chrome container websocket ports from active Docker Compose containers and automatically wire them into the application via environment variables, eliminating the manual port-range drift problem that occurs when containers are repeatedly started and stopped. ChangesChrome Discovery and Dynamic Wiring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
이 PR은 docker compose의 Chrome 서비스가 포트 range에서 실제로 할당받은 host port(예: 9226/9227)를 동적으로 발견해서, make run-issuetracker 실행 시 FETCHER_CHROMEDP_REMOTE_URLS를 자동으로 맞춰 주기 위한 수정입니다(이슈 #348 대응). 호스트에서 바이너리를 직접 실행하는 운영 모드를 유지하면서 Chrome 포트 drift로 인한 부팅 실패를 줄이는 데 목적이 있습니다.
Changes:
chrome-remote-urlsMake target 추가: 실행 중인 chrome compose 컨테이너의HOST_PORT->9222/tcp매핑을 파싱해ws://localhost:<port>,...형태로 출력run-issuetracker에 동적 discovery를 통합: 발견된 URL이 있으면FETCHER_CHROMEDP_REMOTE_URLS를 override한 채로 엔트리포인트 실행.PHONY에 신규 target 등록
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Makefile`:
- Around line 120-123: The current grep pipeline that parses "$(CHROME_COMPOSE)
ps --format '{{.Ports}}' $(CHROME_COMPOSE_SERVICE)" assumes IPv4
"0.0.0.0:<port>->9222/tcp" and misses IPv6/addressed bindings; replace the
three-stage grep chain with a single address-agnostic extraction that first
matches any ":[0-9]+->9222/tcp" (allowing leading "0.0.0.0", ":::", or "[addr]")
and then captures the port number, keeping the use of CHROME_COMPOSE and
CHROME_COMPOSE_SERVICE; update the Makefile pipeline so it extracts the digits
before "->9222/tcp" regardless of IP format (e.g., match ":[0-9]+->9222/tcp"
then output the numeric port).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
There was a problem hiding this comment.
Code Review
This pull request updates the Makefile to dynamically discover Chrome remote debugging URLs for the issuetracker service. It introduces a new chrome-remote-urls target that extracts host ports from running Docker containers and sets the FETCHER_CHROMEDP_REMOTE_URLS environment variable. Feedback was provided to improve the robustness of the port discovery logic by supporting various network interfaces, such as IPv6 and localhost, and ensuring precise container matching using anchors.
Copilot 2건 반영: 1. URL 개수 vs WORKER_COUNT 정합 (Copilot #1): - pkg/config.LoadFetcherChromedpPool 가 RemoteURLs 개수 != WorkerCount 시 fail-fast - 기존: REMOTE_URLS 만 override → WORKER_COUNT 와 mismatch 시 app boot fail - 변경: 발견된 URL 개수 (NF count) 와 WORKER_COUNT 비교 후 분기 * 일치: REMOTE_URLS 만 override (정상 mode) * 불일치: WARNING 로그 + REMOTE_URLS + WORKER_COUNT 둘 다 override (degraded mode) * URL 0개: .env fallback (기존 동작 보존) 2. compose 실패와 0 found 구분 (Copilot #2): - 기존: 2>/dev/null 로 stderr 버림 → docker daemon down / compose 오류도 'no found' 로 처리 - 변경: chrome-remote-urls 가 compose ps 의 exit code 보존 * 0 + 비어있는 output: 정상 (no chrome) — caller 가 fallback * 0 + URL 출력: 정상 — caller 가 export * non-zero: stderr 보존 + 동일 exit code 로 종료 → run-issuetracker 가 ERROR 로그 + 즉시 exit 추가: - exec ./scripts/entrypoint.sh 로 shell PID inheritance — signal 전달 깔끔 - 발견된 URL 개수 (found) 를 메시지에 명시 — 운영 가시성 검증: - chrome-remote-urls 단독 호출: 'ws://localhost:9226,ws://localhost:9227', rc=0 - run-issuetracker: 'Discovered chrome remote URLs (2): ws://localhost:9226,ws://localhost:9227' → 정상 boot, 모든 crawler 등록 + scheduler tick 진행 확인
CodeRabbit Major + gemini Medium (동일 의도) 반영: - 기존: 'grep 0\.0\.0\.0:[0-9]+->9222/tcp' — IPv4 전용 → IPv6 (::) / 127.0.0.1 등 다른 bind address 미인식 - 변경: 'sed -nE s/.*:([0-9]+)->9222\/tcp/\1/p' 단일 추출 + 'tr , \n' 으로 ports 컬럼 항목 분리 + 'sort -un' 으로 unique + 정렬 compose ps 출력의 'docker-chrome-1: 9223/tcp, 0.0.0.0:9226->9222/tcp, [::]:9226->9222/tcp' 같은 IPv4+IPv6 dual listing 도 sort -u 로 dedup. 검증: 동일 결과 (9226,9227).
연관 이슈
Closes #348
배경
compose chrome 서비스의 `ports: "${FETCHER_CHROMEDP_HOST_PORT_RANGE:-9222-9229}:9222"` 가 Docker engine 의 internal counter drift 로 9222/9223 이 아닌 9226/9227 등에 할당. 그러나 앱의 `FETCHER_CHROMEDP_REMOTE_URLS` 는 정적 → 라이브 boot 시 chrome 연결 불가.
라이브 매번 `FETCHER_CHROMEDP_REMOTE_URLS=ws://localhost:9226,9227 ./bin/issuetracker` 식 env override 필요했음.
구현 — option C (dynamic env discovery)
이슈 #348 의 4가지 옵션 (A 단일 포트 고정 / B Docker counter reset / C 동적 env 생성 / D 호스트 매핑 제거) 중 호스트 binary 실행 모드를 유지하면서 가장 깨끗한 option C.
chrome-remote-urlstarget 신설```make
chrome-remote-urls:
@$(CHROME_COMPOSE) ps --status running --format '{{.Ports}}' chrome 2>/dev/null \
| grep -oE '0\.0\.0\.0:[0-9]+->9222/tcp' \
| grep -oE '^0\.0\.0\.0:[0-9]+' \
| grep -oE '[0-9]+$$' \
| sort -n \
| head -n $(CHROME_WORKER_COUNT) \
| sed 's|^|ws://localhost:|' \
| paste -sd,
```
run-issuetracker통합chrome-remote-urls결과를 export 한 채 entrypoint 실행검증
chrome 이 9226/9227 에 할당된 상태에서:
```bash
$ make run-issuetracker
...
Discovered chrome remote URLs: ws://localhost:9226,ws://localhost:9227
Running issuetracker (crawler + processor)...
{"level":"info",...,"message":"starting IssueTracker"}
{"level":"info","source":"inven",...,"message":"crawler registered from db"}
... (모든 crawler 등록 + scheduler tick 정상)
```
CI / 머지 게이트 점검
변경 영향 범위 + 위험도
make run-issuetracker가 자동으로 실제 chrome 포트 매핑 — 매번 env override 불필요paste -sd,가 콤마 구분 single line 보장롤백 계획
git revert— Makefile 단일 파일 변경🤖 Generated with Claude Code
Summary by CodeRabbit