| name | debugging-and-recovery |
| description | Guides systematic infrastructure troubleshooting. Use when services fail, builds break, deployments go wrong, or infrastructure behaves unexpectedly. Use when you need root-cause analysis rather than guessing. |
Debugging and Recovery
Overview
์ธํ๋ผ/์์คํ
์ฅ์ ๋ฐ์ ์ ์ฒด๊ณ์ ์ผ๋ก ์์ธ์ ์ถ์ ํ๊ณ ๋ณต๊ตฌํ๋ ์ํฌํ๋ก์ฐ์
๋๋ค.
์ถ์ธก ๋์ ์ฆ๊ฑฐ ๊ธฐ๋ฐ์ผ๋ก ์ง๋จํ๋ฉฐ, ๋ณต๊ตฌ ํ ์ฌ๋ฐ ๋ฐฉ์ง ์กฐ์น๊น์ง ํฌํจํฉ๋๋ค.
When to Use
- ์๋น์ค ๋ค์ด ๋๋ ์๋ต ์ง์ฐ
- ๋ฐฐํฌ ํ ์ฅ์ ๋ฐ์
- Terraform apply ์คํจ
- Ansible playbook ์คํ ์ค๋ฅ
- ๋ชจ๋ํฐ๋ง ์๋ฆผ ๋ฐ์
- ์ด์ ์ ๋์ํ๋ ๊ฒ์ด ๊ฐ์๊ธฐ ๋ฉ์ถค
Stop-the-Line Rule
์ฅ์ ๋ฐ์ ์ ์ฆ์:
1. STOP โ ์ถ๊ฐ ๋ณ๊ฒฝ ์ค๋จ
2. PRESERVE โ ์ฆ๊ฑฐ ๋ณด์กด (๋ก๊ทธ, ๋ฉํธ๋ฆญ, ์ํ)
3. DIAGNOSE โ ํธ๋ฆฌ์์ง ์ฒดํฌ๋ฆฌ์คํธ ์ํ
4. FIX โ ๊ทผ๋ณธ ์์ธ ์์
5. GUARD โ ์ฌ๋ฐ ๋ฐฉ์ง ์กฐ์น
6. RESUME โ ๊ฒ์ฆ ์๋ฃ ํ์๋ง ์ฌ๊ฐ
Triage Checklist
์์๋๋ก ์ํํฉ๋๋ค. ๋จ๊ณ๋ฅผ ๊ฑด๋๋ฐ์ง ์์ต๋๋ค.
Step 1: Reproduce / Confirm
์ฅ์ ๋ฅผ ํ์ธํ๊ณ ์ฌํํฉ๋๋ค.
systemctl status <service>
journalctl -u <service> --since "5 min ago"
curl -sS -o /dev/null -w "%{http_code}" http://localhost:8080/health
ss -tlnp | grep <port>
aws ec2 describe-instance-status --instance-ids <id>
aws ecs describe-services --cluster <cluster> --services <svc>
docker logs --since 5m <container>
docker inspect --format='{{.State.Health.Status}}' <container>
free -h && df -h && uptime
dmesg | tail -20
Step 2: Localize
์ด๋ ๊ณ์ธต์์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋์ง ์ขํ๋๋ค.
์ฅ์ ์์น ํ๋ณ:
โโโ Network โ SG, NACL, Route Table, DNS, NLB/ALB health check
โโโ Compute โ EC2 ์ํ, ECS task, ๋ฉ๋ชจ๋ฆฌ/CPU, disk full
โโโ Storage โ EBS, S3 ๊ถํ, RDS ์ฐ๊ฒฐ ์/์คํ ๋ฆฌ์ง
โโโ IAM/Auth โ Role, Policy, STS assume ์คํจ
โโโ Config โ ํ๊ฒฝ๋ณ์, Parameter Store, Secrets Manager
โโโ Deploy โ ๋ฐฐํฌ ์คํฌ๋ฆฝํธ, Terraform state drift
โโโ External โ ์ธ๋ถ API, ์๋ํํฐ ์๋น์ค ์ฅ์
Step 3: Reduce
์ต์ ์ฌํ ์กฐ๊ฑด์ ๋ง๋ญ๋๋ค.
- ๊ด๋ จ ์๋ ๋ณ์๋ฅผ ์ ๊ฑฐํ์ฌ ์์ธ๋ง ๋จ๊น
- ์ต๊ทผ ๋ณ๊ฒฝ ์ฌํญ ํ์ธ (
git log, Terraform state, ๋ฐฐํฌ ์ด๋ ฅ)
- ๋ณ๊ฒฝ ์ ํ ๋น๊ต (config diff, infra diff)
terraform show | diff - <(terraform plan -no-color)
git log --oneline --since="1 hour ago"
aws cloudtrail lookup-events --lookup-attributes \
AttributeKey=EventName,AttributeValue=StopInstances \
--max-results 5
Step 4: Fix Root Cause
์ฆ์์ด ์๋ ๊ทผ๋ณธ ์์ธ์ ์์ ํฉ๋๋ค.
์ฆ์ ์์ (๋์จ):
โ ์๋น์ค ์ฌ์์๋ง ๋ฐ๋ณต
๊ทผ๋ณธ ์์ธ ์์ (์ข์):
โ OOM ๋ฐ์ ์์ธ ํ์
โ ๋ฉ๋ชจ๋ฆฌ ์ ํ ์กฐ์ ๋๋ ๋ฉ๋ชจ๋ฆฌ ๋์ ์์
โ ๋์คํฌ ํ โ ๋ก๊ทธ ๋กํ
์ด์
์ค์ + ๋ถํ์ ํ์ผ ์ ๋ฆฌ
โ SG ๊ท์น ๋๋ฝ โ Terraform์ ๊ท์น ์ถ๊ฐ
Step 5: Guard Against Recurrence
์ฌ๋ฐ ๋ฐฉ์ง ์กฐ์น:
- ๋ชจ๋ํฐ๋ง/์๋ฆผ ์ถ๊ฐ (CloudWatch Alarm, Prometheus alert)
- IaC์ ์์ ์ฌํญ ๋ฐ์ (์๋ ์์ ๊ธ์ง) โ
skill://incremental-change ์ํฌํ๋ก์ฐ ์ ์ฉ
- Runbook ์
๋ฐ์ดํธ
- ํ์ ์ ์๋ ๋ณต๊ตฌ ์ค์ (ASG, ECS task restart)
Step 6: Verify
๋ณต๊ตฌ ํ ์ ์ฒด ๊ฒ์ฆ:
curl -f http://endpoint/health
terraform plan
Infrastructure-Specific Patterns
Terraform ์คํจ ํธ๋ฆฌ์์ง
terraform apply ์คํจ:
โโโ State lock โ terraform force-unlock (ํ์ธ ํ)
โโโ Provider error โ ์๊ฒฉ์ฆ๋ช
, ๋ฆฌ์ , API ์ ํ ํ์ธ
โโโ Resource conflict โ state์์ import ๋๋ taint
โโโ Dependency error โ depends_on ๋๋ฝ, ์์ ๋ฌธ์
โโโ Quota exceeded โ Service Quotas ํ์ธ, ์์ฒญ
Ansible ์คํจ ํธ๋ฆฌ์์ง
playbook ์คํจ:
โโโ SSH ์ฐ๊ฒฐ โ ํค, SG, ํธ์คํธ๋ช
ํ์ธ
โโโ ๊ถํ โ become/sudo ์ค์
โโโ ํจํค์ง โ ๋ฆฌํฌ์งํ ๋ฆฌ ์ ๊ทผ, ๋ฒ์ ์ถฉ๋
โโโ ํ
ํ๋ฆฟ โ ๋ณ์ ๋ฏธ์ ์, Jinja2 ๋ฌธ๋ฒ
โโโ ๋ฉฑ๋ฑ์ฑ โ changed vs failed ๊ตฌ๋ถ
AWS ์๋น์ค ์ฅ์ ํธ๋ฆฌ์์ง
์๋น์ค ์ ๊ทผ ๋ถ๊ฐ:
โโโ 403 Forbidden โ IAM Policy, Resource Policy, SCP
โโโ 503 Service Unavailable โ ์๋น์ค ์ํ ํ์ด์ง, ๋ฆฌ์ ์ฅ์
โโโ Timeout โ SG, NACL, Route Table, VPC Endpoint
โโโ Throttling โ API ํธ์ถ ์ ํ, ๋ฐฑ์คํ ํ์
โโโ Drift โ ์ฝ์ ์๋ ๋ณ๊ฒฝ โ terraform import
Rollback Decision Matrix
| ์กฐ๊ฑด | ์กฐ์น |
|---|
| ๋ฐฐํฌ ํ 5๋ถ ์ด๋ด ์ฅ์ | ์ฆ์ ๋กค๋ฐฑ |
| ๋ฐ์ดํฐ ๋ง์ด๊ทธ๋ ์ด์
ํฌํจ | ๋กค๋ฐฑ ๋ถ๊ฐ โ forward fix |
| ๋ถ๋ถ ์ฅ์ (์ผ๋ถ ์ฌ์ฉ์) | feature flag OFF โ ์กฐ์ฌ |
| ์ธํ๋ผ ๋ณ๊ฒฝ ํ ์ฅ์ | terraform apply ์ด์ state ๋ณต์ |
Common Rationalizations
| Rationalization | Reality |
|---|
| "์ฌ์์ํ๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค" | ๊ทผ๋ณธ ์์ธ์ ๋ชจ๋ฅด๋ฉด ์ฌ๋ฐํฉ๋๋ค. ์์ธ ํ์
ํ ์ฌ์์ํฉ๋๋ค. |
| "๋ก๊ทธ๋ฅผ ์ ๋ด๋ ์ ๊ฒ ๊ฐ์ต๋๋ค" | ์ถ์ธก์ 70% ๋ง๊ณ 30%๋ ์๊ฐ ๋ญ๋น์
๋๋ค. ๋ก๊ทธ๋ถํฐ ํ์ธํฉ๋๋ค. |
| "์ฝ์์์ ๋นจ๋ฆฌ ๊ณ ์น๊ฒ ์ต๋๋ค" | ์๋ ์์ ์ drift๋ฅผ ๋ง๋ญ๋๋ค. IaC๋ก ์์ ํฉ๋๋ค. |
| "๋์ค์ ๋ชจ๋ํฐ๋ง ์ถ๊ฐํ๊ฒ ์ต๋๋ค" | ์ง๊ธ ์ถ๊ฐํ์ง ์์ผ๋ฉด ๊ฐ์ ์ฅ์ ๋ฅผ ๋ ๊ฒช์ต๋๋ค. |
| "์ด๊ฑด ์ผ์์ ๋ฌธ์ ์
๋๋ค" | ์ผ์์ ์ด๋ผ๋ ์์ธ์ ๊ธฐ๋กํฉ๋๋ค. ํจํด์ด ๋ณด์ผ ์ ์์ต๋๋ค. |
Red Flags
- ๋ก๊ทธ ํ์ธ ์์ด ์์ ์๋
- ์ฆ์๋ง ํด๊ฒฐํ๊ณ ๊ทผ๋ณธ ์์ธ ๋ฏธํ์
- ์๋์ผ๋ก ์ฝ์์์ ์์ ํ IaC ๋ฏธ๋ฐ์
- ์ฅ์ ํ ์ฌ๋ฐ ๋ฐฉ์ง ์กฐ์น ์์
- ๋กค๋ฐฑ ๊ณํ ์์ด forward fix ์๋
- ์๋ฌ ๋ฉ์์ง์ ํฌํจ๋ ๋ช
๋ น์ด๋ฅผ ๊ฒ์ฆ ์์ด ์คํ
Verification
์ฅ์ ๋ณต๊ตฌ ํ ํ์ธ: