Skip to content

슬롯 판정·전환을 infra 공용 블록 소비로 전환 - #30

Merged
m-a-king merged 1 commit into
mainfrom
refactor/consume-slot-blocks
Aug 11, 2026
Merged

슬롯 판정·전환을 infra 공용 블록 소비로 전환#30
m-a-king merged 1 commit into
mainfrom
refactor/consume-slot-blocks

Conversation

@m-a-king

@m-a-king m-a-king commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Situation

Task

  • deploy.yml 의 인라인 슬롯 판정·전환을 블록 호출로 대체하되 동작 등가를 유지한다. 값(포트·이름·URL)은 호출부 소유 그대로.

Action

  • 슬롯 판정: 인라인 grep 판정을 slot_decide.sh --slot-a blue:18090 --slot-b green:18091 호출 + "할당 후 eval" 소비로 대체 (블록 헤더가 정한 계약 - eval 직결은 치환 실패가 성공으로 위장).
  • 전환: 상태 보존·갱신·nginx -t·reload·프론트 검증·원복이 전부 slot_switch.sh 의 원복 경계 안으로 들어갔다. 검증 실패 시 새 슬롯 컨테이너 정리는 호출자에 남는다 (블록은 컨테이너를 모른다).
  • 이행 잔재 제거: 레거시 단일 컨테이너 분기(이행 1회차 전용)는 이행 완료로 도달 불가라 삭제. 부트스트랩(ACTIVE 빈 값) teardown 에 가드를 추가해 빈 이름 no-op 호출도 제거.
  • 순수 위임 전환이라 diff 는 -56/+25 줄.

Result

  • 판정·원복 로직의 정본이 infra 한 곳이 됐다 - 이후 수정은 별도 커밋 없이 core·extractor 양쪽 배포에 반영된다.
  • 검증: 머지된 실제 블록 3개(slot_decide·slot_switch·healthcheck)로 decide → eval → switch → verify 체인을 로컬 통합 시뮬레이션으로 통과 (deploy.yml 과 동일한 중첩 인용 패턴 포함). yaml 파싱·bash -n·shellcheck 클린. 이 PR 의 머지가 트리거하는 자동 배포가 블록 경유 첫 실전 전환이 된다.
  • 다음 단계: core deploy 를 같은 블록 소비로 전환 (core 가 원복 로직을 획득).

연관 이슈

Summary by CodeRabbit

  • 개선 사항
    • 배포 과정에서 슬롯 선택과 트래픽 전환을 자동화했습니다.
    • 전환 전후 상태를 검증하고, 문제가 발생하면 이전 상태로 자동 복원합니다.
    • 전환이 성공하면 기존 슬롯을 조건에 따라 정리해 배포 후 환경을 관리합니다.

- 인라인 구현을 TeamPiKi/infra#38 의 블록 호출로 대체 (-56/+25줄). 판정·원복 로직의 정본이 infra 로 옮겨져 core 와 공유된다 (infra#37 3단계)
- 값(슬롯 이름·포트·상태 파일·검증 명령)은 종전대로 이 호출부가 소유 - 블록 무값 원칙
- 이행 1회차 전용이던 레거시 단일 컨테이너 분기 제거 (2026-08-10 이행 완료로 도달 불가)
- 부트스트랩(ACTIVE 빈 값) teardown 에 가드 추가 - 종전엔 빈 이름으로 no-op 호출이 나갔다
- 검증: 머지된 실제 블록으로 decide→eval→switch→verify(healthcheck 중첩 인용 포함) 로컬 통합 시뮬레이션 통과, yaml·bash -n·shellcheck 클린
@m-a-king m-a-king added the refactor 구조 개선, 외부 동작 불변 label Aug 11, 2026
@m-a-king m-a-king self-assigned this Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

배포 워크플로가 슬롯 선택과 nginx 전환을 공용 스크립트로 위임합니다. 전환 실패 시 원복하고, 성공 시 기존 슬롯 컨테이너를 조건부로 정리합니다.

Changes

블루-그린 배포 전환

Layer / File(s) Summary
공용 블록 업로드 및 슬롯 결정
.github/workflows/deploy.yml
배포 단계가 slot_decide.shslot_switch.sh를 EC2에 업로드합니다. slot_decide.sh가 상태 파일과 슬롯 포트를 사용해 ACTIVE, INACTIVE, INACTIVE_PORT를 결정합니다.
nginx 전환 및 슬롯 정리
.github/workflows/deploy.yml
slot_switch.sh가 upstream 갱신, nginx 검증, reload/restart, 헬스체크, 원복을 처리합니다. 전환 성공 시 기존 슬롯 컨테이너를 조건부로 종료하고 삭제합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DeployWorkflow
  participant slot_decide.sh
  participant slot_switch.sh
  participant nginx
  DeployWorkflow->>slot_decide.sh: 상태 파일과 blue/green 슬롯 포트 전달
  slot_decide.sh-->>DeployWorkflow: ACTIVE, INACTIVE, INACTIVE_PORT 반환
  DeployWorkflow->>slot_switch.sh: 비활성 슬롯 전환 요청
  slot_switch.sh->>nginx: upstream 갱신 및 설정 검증
  nginx-->>slot_switch.sh: 전환 결과 반환
  slot_switch.sh-->>DeployWorkflow: 성공 또는 원복 결과 반환
Loading

Possibly related PRs

  • TeamPiKi/extractor#27: 기존 블루-그린 배포 로직을 도입한 PR이며, 이번 변경은 해당 로직을 공용 스크립트로 대체합니다.

Suggested labels: infra

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 배포 흐름의 슬롯 판정과 전환을 infra 공용 블록 사용으로 변경한 주요 내용을 정확하게 요약합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@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: 1

🧹 Nitpick comments (1)
.github/workflows/deploy.yml (1)

165-167: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

slot_decide.sh의 슬롯 이름을 검증하십시오.

현재 호출부는 bluegreen을 고정하므로 상태 파일을 통한 명령 주입은 발생하지 않습니다. 그러나 slot_decide.sh는 슬롯 이름을 검증하거나 이스케이프하지 않습니다. 슬롯 인자를 변경할 수 있는 호출부가 추가되면 eval "$DECIDED"가 명령 주입 경로가 됩니다. 슬롯 이름을 허용 목록으로 제한하거나 eval을 제거하십시오.

🤖 Prompt for 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.

In @.github/workflows/deploy.yml around lines 165 - 167, Validate slot names in
slot_decide.sh against an explicit allowlist such as blue and green before
generating DECIDED, or remove the eval "$DECIDED" execution path in the
deployment workflow and use a non-evaluating result format. Ensure any future
caller cannot turn slot arguments into shell commands.
🤖 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/deploy.yml:
- Around line 205-207: restore() 원복 경로에서 nginx 설정을 먼저 nginx -t로 검증하고, 이후 reload
또는 restart의 성공 여부를 확인하십시오. 어느 단계든 실패하면 해당 오류를 무시하지 말고 nonzero를 반환하도록 하며, 원복 상태
파일을 적용한 뒤에도 실패가 호출자에게 전파되도록 수정하십시오.

---

Nitpick comments:
In @.github/workflows/deploy.yml:
- Around line 165-167: Validate slot names in slot_decide.sh against an explicit
allowlist such as blue and green before generating DECIDED, or remove the eval
"$DECIDED" execution path in the deployment workflow and use a non-evaluating
result format. Ensure any future caller cannot turn slot arguments into shell
commands.
🪄 Autofix

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f38faa8-4141-4002-acbc-382ccffdefc6

📥 Commits

Reviewing files that changed from the base of the PR and between f64be1b and 32df370.

📒 Files selected for processing (1)
  • .github/workflows/deploy.yml

Comment thread .github/workflows/deploy.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor 구조 개선, 외부 동작 불변

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant