Skip to content

slot 블록 보강 - 원복 restart 폴백과 슬롯 이름 허용목록 - #39

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

slot 블록 보강 - 원복 restart 폴백과 슬롯 이름 허용목록#39
m-a-king merged 1 commit into
mainfrom
fix/slot-blocks-hardening

Conversation

@m-a-king

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

Copy link
Copy Markdown
Contributor

Situation

Action

  • 원복 reload 에 restart 폴백: 원복 경로가 reload 실패를 삼키면 상태 파일(이전 슬롯)과 nginx 런타임(새 슬롯)이 어긋난 채 호출자가 새 슬롯 컨테이너를 정리해 서빙이 끊길 수 있다. 전환과 같은 reload -> restart 폴백을 원복에도 적용했다. restart 마저 실패하면 nginx 정지 상태라, 수동 기동만으로 상태 파일이 가리키는 이전 슬롯으로 복귀한다 (괴리 창 소멸). 별도 nginx -t 는 두지 않았다 - reload/restart 가 구성 검증을 내장하고 원복 대상은 직전까지 서빙하던 구성이다.
  • 슬롯 이름 charset 허용목록: slot_decide 출력이 eval 로 소비되는 계약이라 이름을 [A-Za-z0-9_-] 로 제한해 미래 호출부의 명령 주입 표면을 닫았다.
  • 셀프 테스트 2케이스 추가 (reload 만 실패하는 스텁 분기 신설).

Result

  • 검증: 셀프 테스트 전 케이스 통과 + shellcheck 클린.

연관 이슈

Summary by CodeRabbit

  • 버그 수정

    • 슬롯 이름에 허용되지 않은 문자가 포함되면 입력을 거부하고 오류를 표시합니다.
    • nginx 설정 reload에 실패하면 자동으로 restart를 시도합니다.
    • 전환 또는 복구 과정이 실패해도 이전 상태가 유지되도록 개선했습니다.
  • 테스트

    • 잘못된 슬롯 이름과 nginx reload 실패 상황에 대한 검증을 추가했습니다.

- slot_switch 원복 경로가 reload 실패를 삼키면 상태 파일은 이전 슬롯인데 nginx 런타임은 새 슬롯을 가리키는 창이 남고, 그 사이 호출자가 새 슬롯 컨테이너를 정리하면 서빙이 끊긴다 (extractor#30 CodeRabbit 지적 수용). 전환과 같은 restart 폴백을 원복에도 적용 - restart 마저 실패하면 nginx 정지이므로 수동 기동만으로 상태 파일(이전 슬롯) 그대로 복귀한다
- 원복 시 별도 nginx -t 는 두지 않는다 - reload/restart 가 구성 검증을 내장하고, 원복 대상은 직전까지 서빙하던 구성이다
- slot_decide 출력은 eval 로 소비되는 계약이라 슬롯 이름 charset 을 [A-Za-z0-9_-] 허용목록으로 닫는다 (현 호출부는 고정 리터럴이지만 미래 호출부의 명령 주입 표면을 블록이 스스로 차단)
- 테스트 2케이스 추가: 허용목록 밖 이름 거절, verify 실패 + reload 불가 시 restart 폴백으로 원복 반영
@m-a-king m-a-king added the fix 외부 가시적 결함 수정 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

슬롯 이름에 허용 문자 검증을 추가했다. restore는 nginx reload 실패 시 restart를 시도한다. 관련 테스트는 입력 거부와 원복 실패 처리를 검증한다.

Changes

슬롯 전환 안정성

Layer / File(s) Summary
슬롯 이름 입력 검증
blocks/slot_decide.sh, blocks/slot_decide.test.sh
슬롯 이름에 영숫자, 밑줄, 하이픈만 허용한다. 세미콜론이 포함된 입력은 종료 코드 2로 거부한다.
nginx 복구 restart 폴백
blocks/slot_switch.sh, blocks/slot_switch.test.sh
reload 실패 시 restart를 실행한다. 두 작업이 실패해도 상태 파일을 원복한다. 테스트 스텁과 실패 시나리오 검증을 확장한다.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • TeamPiKi/infra#38: 동일한 슬롯 전환 스크립트와 테스트의 기반 변경을 포함한다.
🚥 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 제목은 원복 시 restart 폴백과 슬롯 이름 허용목록이라는 변경 사항을 명확하고 간결하게 요약합니다.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@m-a-king
m-a-king merged commit 7c9c0a8 into main Aug 11, 2026
2 of 3 checks passed

@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.

🧹 Nitpick comments (1)
blocks/slot_switch.test.sh (1)

102-111: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

reloadrestart 동시 실패 경로를 추가로 검증하세요.

현재 테스트는 systemctl_reload_fail만 설정합니다. 따라서 restart 폴백 성공과 두 번의 호출만 검증하고, blocks/slot_switch.sh의 Line 66-68 분기는 실행하지 않습니다. systemctl_fail도 설정한 별도 케이스에서 종료 코드, 이전 상태 파일 유지, restore reload/restart FAILED 오류 출력을 확인하세요.

🤖 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 `@blocks/slot_switch.test.sh` around lines 102 - 111, Add a separate test case
in the slot-switch test flow that enables both systemctl_reload_fail and
systemctl_fail, then runs the failed verification rollback scenario. Assert exit
code 1, preservation of the previous state file, and the expected “restore
reload/restart FAILED” error output, covering the failure branch in
blocks/slot_switch.sh.
🤖 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.

Nitpick comments:
In `@blocks/slot_switch.test.sh`:
- Around line 102-111: Add a separate test case in the slot-switch test flow
that enables both systemctl_reload_fail and systemctl_fail, then runs the failed
verification rollback scenario. Assert exit code 1, preservation of the previous
state file, and the expected “restore reload/restart FAILED” error output,
covering the failure branch in blocks/slot_switch.sh.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cff7662e-5546-4ec9-97ba-bb3c193f006d

📥 Commits

Reviewing files that changed from the base of the PR and between 3a29452 and ce584b7.

📒 Files selected for processing (4)
  • blocks/slot_decide.sh
  • blocks/slot_decide.test.sh
  • blocks/slot_switch.sh
  • blocks/slot_switch.test.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 외부 가시적 결함 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant