Skip to content

feat: Blue/Green 배포 시 Prometheus 스크랩 타겟 자동 업데이트#763

Merged
Hexeong merged 3 commits into
developfrom
feat/762-auto-update-promethus-actuator-port
Jun 17, 2026
Merged

feat: Blue/Green 배포 시 Prometheus 스크랩 타겟 자동 업데이트#763
Hexeong merged 3 commits into
developfrom
feat/762-auto-update-promethus-actuator-port

Conversation

@Hexeong

@Hexeong Hexeong commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

관련 이슈

작업 내용

Blue/Green 슬롯 전환 완료 후 monitoring 서버의 Prometheus 타겟 파일을 자동으로 갱신하는 스텝을 CD 워크플로우에 추가했습니다.

  • prod-cd.yml: nginx 전환 완료 후 prod.json 타겟 파일 업데이트 스텝 추가
  • dev-cd.yml: nginx 전환 완료 후 stage.json 타겟 파일 업데이트 스텝 추가

동작 방식

  1. app 서버에 SSH 접속 → nginx upstream.conf에서 현재 활성 포트 확인 → management 포트 결정 (blue: 8081 / green: 9081)
  2. monitoring 서버에 SSH 접속 → 기존 HOST / DEV_HOST 시크릿의 퍼블릭 IP와 결정된 management 포트로 타겟 JSON 파일(prod.json / stage.json) 갱신

타겟 파일 경로는 ~/solid-connection-monitor/prometheus/targets/로, docker-compose 볼륨 마운트(./prometheus:/etc/prometheus)에 의해 컨테이너 내부 /etc/prometheus/targets/에 반영됩니다.

특이 사항

  • 사전에 등록된 Secrets(MONITORING_HOST, MONITORING_USERNAME, MONITORING_PRIVATE_KEY)를 사용합니다.
  • app 서버 IP는 기존 HOST / DEV_HOST 시크릿을 그대로 활용하므로 별도 SSH로 IP를 조회하지 않습니다.
  • monitoring 서버의 홈 디렉토리 하위 경로이므로 sudo 없이 파일 쓰기가 가능합니다.
  • Prometheus의 file_sd_configs 방식은 타겟 파일 변경을 주기적으로 감지하므로, 파일 갱신 후 별도 reload 없이 자동 반영됩니다.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Hexeong, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 19 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bf055a3d-f1f8-446c-b92c-29c73494d6b5

📥 Commits

Reviewing files that changed from the base of the PR and between d5f4476 and e2503e1.

📒 Files selected for processing (2)
  • .github/workflows/dev-cd.yml
  • .github/workflows/prod-cd.yml

Walkthrough

  1. stage 환경 Prometheus 타겟 자동 갱신 추가

    • .github/workflows/dev-cd.ymldeploy 잡 마지막에 Update Prometheus scrape target (stage) 단계가 추가됨.
    • 원격 서버의 Nginx upstream.conf에서 활성 포트를 읽어 관리 포트(8081 또는 9081)를 결정함.
    • 원격 서버의 private IP를 조회한 뒤, 별도의 모니터링 SSH 자격증명으로 stage.jsonPRIVATE_IP:NEW_MGMT_PORT를 기록함.
  2. prod 환경 Prometheus 타겟 자동 갱신 추가

    • .github/workflows/prod-cd.ymldeploy 잡 마지막에 Update Prometheus scrape target (prod) 단계가 추가됨.
    • stage와 동일한 흐름으로 upstream 포트 조회 → 관리 포트 결정 → private IP 조회 → prod.json 갱신이 이루어짐.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • whqtker
  • wibaek
  • Gyuhyeok99
  • JAEHEE25
  • sukangpunch
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 Blue/Green 배포 시 Prometheus 스크랩 타겟 자동 업데이트라는 핵심 변경사항을 명확하고 간결하게 설명합니다.
Linked Issues check ✅ Passed 변경사항이 #762의 모든 주요 요구사항을 충족합니다: prod-cd.yml과 dev-cd.yml에 타겟 파일 업데이트 단계가 추가되었고, 필요한 로직(포트 결정, private IP 조회, 모니터링 서버 SSH 접속, 타겟 파일 갱신)이 구현되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 #762의 범위 내에 있으며, CD 워크플로우의 nginx 전환 후 Prometheus 타겟 파일 업데이트 단계 추가라는 목표에만 집중합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed PR 설명이 필수 섹션을 완전히 충족하며 명확한 작업 내용과 동작 방식을 포함하고 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/762-auto-update-promethus-actuator-port

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Hexeong Hexeong self-assigned this Jun 17, 2026
@Hexeong Hexeong added 인프라 진행 중 자유롭게 merge 가능 labels Jun 17, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 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 @.github/workflows/dev-cd.yml:
- Around line 186-199: The SSH commands connecting to both DEV_HOST and
MONITORING_HOST use StrictHostKeyChecking=no which disables host key
verification and creates a MITM vulnerability. Remove the -o
StrictHostKeyChecking=no option from both SSH commands (the one connecting to
DEV_USERNAME@DEV_HOST and the one connecting to
MONITORING_USERNAME@MONITORING_HOST), and instead populate the known_hosts file
with the host keys of these servers beforehand in the workflow, or use -o
StrictHostKeyChecking=accept-new to securely accept new host keys on first
connection while still verifying them on subsequent connections.
- Around line 192-195: The current PRIVATE_IP extraction using `hostname -I |
awk '{print $1}'` is non-deterministic and can select incorrect IP addresses in
multi-NIC or Docker bridge environments by blindly taking the first IP. Replace
this approach with a routing-based method that extracts the actual source IP
address that would be used for outgoing connections, such as using `ip route get
1 | awk '{print $(NF-2);exit}'` or similar command that determines the IP based
on the system's routing table. Apply the same fix to both the dev and prod
deployment steps.
- Around line 186-191: Remove the unsafe fallback value `|| echo 9080` from the
UPSTREAM_PORT assignment and add explicit validation to ensure the port is one
of the expected values (8080 or 9080). After assigning UPSTREAM_PORT from the
ssh command, add a validation check that confirms the port is either "8080" or
"9080" and exits with an error message if it is neither of these expected
values. Apply the same validation approach to any similar port detection logic
in the prod deployment step to maintain consistency and safety across
environments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 89c1e56d-916f-48cd-8414-7dede6ec20e7

📥 Commits

Reviewing files that changed from the base of the PR and between bf0b7b2 and d5f4476.

📒 Files selected for processing (2)
  • .github/workflows/dev-cd.yml
  • .github/workflows/prod-cd.yml

Comment thread .github/workflows/dev-cd.yml
Comment thread .github/workflows/dev-cd.yml
Comment thread .github/workflows/dev-cd.yml Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5f44767b5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .github/workflows/prod-cd.yml Outdated
@Hexeong Hexeong force-pushed the feat/762-auto-update-promethus-actuator-port branch from 528b78a to e2503e1 Compare June 17, 2026 07:07
@Hexeong Hexeong added 최종 리뷰 최소 1명 필수 and removed 진행 중 자유롭게 merge 가능 labels Jun 17, 2026

@whqtker whqtker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니닷

@Hexeong Hexeong merged commit 8977b28 into develop Jun 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

인프라 최종 리뷰 최소 1명 필수

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Blue/Green 배포 시 Prometheus 스크랩 타겟 자동 업데이트

2 participants