Skip to content

feat(ops): 원클릭 행사 시작 스크립트 (dry-run 기본) (#100) - #111

Merged
exijn merged 2 commits into
developfrom
feature/100-event-start-script
Nov 10, 2026
Merged

exijn merged 2 commits into
developfrom
feature/100-event-start-script

Conversation

@exijn

@exijn exijn commented Nov 10, 2026

Copy link
Copy Markdown
Member

Closes #100

변경

  • scripts/event_start.py: 상태 확인 → reset-failed/start → Restart=no drop-in 설치(재부팅 후 유지) → 로봇 늦은 기동 대기·재시도(status.json telemetry.fresh) → 승인 만료 검사(우회 없음, 30분 이하 FAIL) → 오래된 대기 실행 정리 확인(--queue-cleared, Poppy-Server#132) → 켜기(--switch-command) → READY 확인 → 한 줄 결과(OK/DRY-RUN OK/MANUAL/FAIL: 원인·조치).
  • 기본이 dry-run 이며 --execute 없이는 아무 명령도 실행하지 않는다. EnvironmentFile 은 읽지 않고, 로봇 명령은 보내지 않는다.
  • deploy/systemd/poppy-agent.service.d/10-event-no-restart.conf, docs/event-start.md.

검증

  • harness, ruff, ruff format, mypy, pytest 431 passed(신규 15, fake runner·스냅샷 전용), mypy --strict scripts/event_start.py 통과.
  • dry-run 실행(fixture status.json): 계획된 명령 출력 후 DRY-RUN OK. 실제 systemd·서비스·로봇은 건드리지 않았다.

사람이 할 일

  • 운영 노트북에서 켜기 스크립트 경로를 --switch-command 로 지정해 dry-run → --execute 로 첫 실행.
  • Poppy-Server#132 의 정리 API 가 정해지면 --queue-cleared 수동 확인을 자동 확인으로 바꾸는 후속 작업.

🤖 Generated with Claude Code

- scripts/event_start.py: 상태 확인 → reset-failed/start → Restart=no drop-in → 로봇 늦은 기동 대기
  → 승인 만료 검사 → 대기 실행 정리 확인 → 켜기 → 한 줄 결과. 기본 dry-run, --execute 필요.
- deploy/systemd/poppy-agent.service.d/10-event-no-restart.conf, docs/event-start.md
- fake runner/스냅샷 테스트 15개

Closes #100

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@exijn exijn added the ops POPPY ops label Nov 10, 2026

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

리뷰 결과

변경된 4개 파일을 검토했습니다. 인라인 관찰 5개를 게시했습니다.

심각도 개수
치명적 0
높음 5
중간 0
낮음 0

유형: 필수 수정 5, 수정 권장 0, 제안 0, 확인 질문 0, 좋았던 점 0

주요 관찰

  • 필수 수정 · HIGH 서비스 상태 조회 실패를 inactive처럼 처리하면 안 됩니다
  • 필수 수정 · HIGH systemd 및 drop-in 변경 실패가 성공으로 보고됩니다
  • 필수 수정 · HIGH 켜기 명령 타임아웃의 불명확한 결과를 처리해야 합니다
  • 필수 수정 · HIGH 서비스 시작 전에 Restart=no를 적용해야 합니다
  • 필수 수정 · HIGH 이전 실행의 상태 파일을 현재 READY로 오인할 수 있습니다

검토한 head: f889b6d07346 · 최신 head는 /review로 검토하세요.

Comment thread scripts/event_start.py
self._mutate(["sudo", "systemctl", "reset-failed", UNIT])
self._mutate(["sudo", "systemctl", "start", UNIT])
self.report.add("서비스", "failed → reset-failed → start")
elif state in {"inactive", "unknown"}:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 필수 수정 · HIGH

서비스 상태 조회 실패를 inactive처럼 처리하면 안 됩니다

systemctl show의 종료 코드를 확인하지 않고 ActiveState가 없으면 unknown으로 만든 뒤 서비스를 시작합니다. DBus 장애, unit 미설치, 권한 문제 같은 조회 실패가 안전한 inactive 상태로 변환됩니다.

이유: 상태를 확인할 수 없으면 fail-closed 해야 하는 운영 절차가 오히려 서비스를 변경합니다.

제안: 조회 성공과 필수 속성을 검증한 후에만 상태별 동작을 수행하고 실패 경로 테스트를 추가하십시오.

Comment thread scripts/event_start.py
self.report.add("켜기", "READY")

def _mutate(self, command: Sequence[str]) -> CommandResult:
return self.runner(command)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 필수 수정 · HIGH

systemd 및 drop-in 변경 실패가 성공으로 보고됩니다

reset-failed, start, install, daemon-reload의 종료 코드를 전혀 검사하지 않습니다. 예를 들어 drop-in 설치가 실패해도 보고서에는 설치 완료가 기록되고 이후 물리 동작 켜기 단계까지 진행할 수 있습니다.

이유: 운영자가 의존하는 안전 설정의 적용 여부와 스크립트 보고가 달라질 수 있습니다.

제안: 필수 변경용 검사 헬퍼를 두어 0이 아닌 종료 코드에서 즉시 중단하십시오.

Comment thread scripts/event_start.py

def subprocess_runner(command: Sequence[str]) -> CommandResult:
completed = subprocess.run( # noqa: S603 - fixed argument lists only
list(command), capture_output=True, text=True, check=False, timeout=60

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 필수 수정 · HIGH

켜기 명령 타임아웃의 불명확한 결과를 처리해야 합니다

모든 실제 명령에 60초 타임아웃을 적용하지만 TimeoutExpired를 처리하지 않습니다. 켜기 명령은 외부 상태 변경을 이미 완료했을 수도 있으므로 타임아웃은 단순 실패가 아니라 결과 불명 상태입니다.

이유: 부작용이 있는 명령의 타임아웃 후 무심코 재실행하는 것은 단일 실행 안전 절차를 훼손할 수 있습니다.

제안: 타임아웃 전용 실패 경로와 테스트를 추가하고, 수동 상태 확인 전에는 재시도하지 않도록 결과 문구를 명확히 하십시오.

Comment thread scripts/event_start.py
def run(self) -> str:
try:
self._service()
self._drop_in()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 필수 수정 · HIGH

서비스 시작 전에 Restart=no를 적용해야 합니다

현재는 실패하거나 중지된 서비스를 먼저 시작한 뒤 drop-in을 설치합니다. 기존 unit에 자동 재시작 정책이 설정되어 있으면, 새 프로세스가 초기화 중 종료되는 순간 Restart=no가 아직 적용되지 않아 의도와 달리 자동 재시작될 수 있습니다.

이유: 물리 동작을 자동으로 다시 켜지 않겠다는 이 변경의 핵심 안전 목적을 위반할 수 있습니다.

제안: _drop_in()을 _service()보다 먼저 실행하고 이 순서를 검증하는 테스트를 추가하십시오.

Suggested change
self._drop_in()
self._drop_in()
self._service()

Comment thread scripts/event_start.py
self._drop_in()
status = self._wait_for(
"로봇 텔레메트리",
lambda s: s.get("lifecycleState") == "READY" and telemetry_fresh(s),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 필수 수정 · HIGH

이전 실행의 상태 파일을 현재 READY로 오인할 수 있습니다

준비 판단이 파일 안의 lifecycleState와 telemetry.fresh 불리언만 확인합니다. 이전 Agent가 READY 상태를 기록한 뒤 종료했다면 파일이 남아 있는 동안 새 서비스가 아직 준비되지 않았어도 즉시 통과할 수 있습니다.

이유: 파일에 기록된 과거 안전 상태는 현재 로봇이 준비되었다는 증거가 될 수 없습니다.

제안: 스냅샷 세대 또는 타임스탬프 검증을 추가하고, 잔존 상태 파일을 사용하는 회귀 테스트를 추가하십시오.

@exijn
exijn merged commit 849ea9d into develop Nov 10, 2026
1 check passed
@exijn
exijn deleted the feature/100-event-start-script branch November 10, 2026 11:49
exijn added a commit that referenced this pull request Nov 16, 2026
develop(#111~#122)을 받아 #95 의 develop 충돌을 푼다. 충돌은 config/open_motion.py 의 __all__ 두 곳뿐이며
양쪽 이름을 모두 넣어 알파벳 순으로 합쳤다. pytest 504·ruff·ruff format·mypy·harness 통과.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ops POPPY ops

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant