Skip to content

[DEBUG] 운영 DB 백업 GCS 업로드 실패 수정#610

Merged
Dimo-2562 merged 1 commit into
mainfrom
debug/#607-gcs-upload
Jun 1, 2026
Merged

[DEBUG] 운영 DB 백업 GCS 업로드 실패 수정#610
Dimo-2562 merged 1 commit into
mainfrom
debug/#607-gcs-upload

Conversation

@Dimo-2562
Copy link
Copy Markdown
Contributor

❤️ 기능 설명

운영 DB 백업 smoke test가 dump 파일 생성 후 GCS 업로드 단계에서 실패하던 문제를 수정합니다.

현재 로그상 mysqldump와 gzip 파일 생성은 성공했고, 이후 업로드 단계에서 service가 exit 1로 종료됩니다.
기존 업로드는 gcloud storage cp를 사용했는데, 이 경로는 VM 서비스 계정의 object create 권한만으로는 목적지 확인/read 동작이나 Cloud SDK 사용자 설정에 걸릴 수 있습니다.

변경 사항:

  • gcloud storage cp 대신 GCE metadata server access token + GCS JSON media upload API로 직접 업로드
  • ifGenerationMatch=0을 사용해 기존 백업 객체 overwrite 방지
  • 실패 시 HTTP status/body를 journal에 남겨 다음 원인 확인 가능
  • 백업 런타임 설치 시 google-cloud-cli 설치 의존 제거, curl만 보장
  • 기존 objectCreator 중심 백업 IAM 정책을 유지할 수 있도록 스크립트 레벨에서 업로드 경로 수정

Terraform 변경 및 terraform apply는 없습니다.
Swagger/API 변경은 없는 운영 배포 스크립트 수정입니다.


연결된 issue

관련 issue: #607



🩷 Approve 하기 전 확인해주세요!

  • Terraform/IAM 변경 없이 스크립트만 수정합니다.
  • 운영 VM의 metadata server token으로 GCS 업로드를 수행합니다.
  • 운영 배포 시 DB 백업 smoke test가 실제 GCS 업로드까지 성공하는지 확인해주세요.

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 테스트 결과 사진을 넣었는가? (명령 실행 결과로 대체)
  • 이슈넘버를 적었는가?

테스트 결과:

bash -n scripts/install_backup_systemd.sh scripts/run_db_backup.sh scripts/backup_db.sh scripts/deploy.sh
git diff --check
bash -c 'source /tmp/urlencode-fn.sh; test "$(urlencode "prod/2026/06/cockple-test.sql.gz")" = "prod%2F2026%2F06%2Fcockple-test.sql.gz"'
terraform -chdir=terraform validate

검증 결과: 통과

Upload backups through the GCS JSON media API with the VM metadata token so the backup path only needs object creation and does not depend on gcloud cp destination reads or per-user Cloud SDK config. Keep systemd smoke failures blocking so deploys surface broken backups with HTTP response details.\n\nConstraint: Production IAM must not be changed via Terraform apply during this fix.\nRejected: Granting roles/storage.objectAdmin or objectUser | broader backup object read/delete permissions than the upload path needs.\nConfidence: medium\nScope-risk: narrow\nDirective: Do not reintroduce gcloud storage cp unless the backup service account is intentionally granted the read permissions that command may require.\nTested: bash -n scripts/install_backup_systemd.sh scripts/run_db_backup.sh scripts/backup_db.sh scripts/deploy.sh; git diff --check; urlencode function smoke; terraform -chdir=terraform validate\nNot-tested: Live production GCS upload; requires main deploy on GCE metadata credentials.
@Dimo-2562 Dimo-2562 self-assigned this Jun 1, 2026
@Dimo-2562 Dimo-2562 added the 🕷️ BUG Something isn't working label Jun 1, 2026
@Dimo-2562 Dimo-2562 merged commit de1ced2 into main Jun 1, 2026
1 check passed
@Dimo-2562 Dimo-2562 deleted the debug/#607-gcs-upload branch June 1, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🕷️ BUG Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant