Skip to content

CI: append random suffix to GCP Cloud SQL database instance name#2741

Merged
selzoc merged 1 commit into
mainfrom
add-random-suffix-upgrade-mysql-db
Jun 3, 2026
Merged

CI: append random suffix to GCP Cloud SQL database instance name#2741
selzoc merged 1 commit into
mainfrom
add-random-suffix-upgrade-mysql-db

Conversation

@selzoc
Copy link
Copy Markdown
Member

@selzoc selzoc commented Jun 3, 2026

Prevent 'Error waiting for Create Instance' failures in the Concourse 'upgrade-mysql' job when builds are triggered within a short window.

Google Cloud SQL enforces a 7-to-10-day moratorium on reusing the name of a recently-deleted database instance. When integration builds are triggered frequently (such as builds 344 and 345), Terraform's apply step fails because the previously-destroyed name 'upgrade-mysql-mysql-db' is still locked by GCP's resource-reclamation pipeline.

Appending a 4-byte random_id suffix bypasses the name reservation lock while keeping resource names fully compatible with our leftover environment cleanup filter (upgrade-mysql).

References:

Prevent 'Error waiting for Create Instance' failures in the Concourse
'upgrade-mysql' job when builds are triggered within a short window.

Google Cloud SQL enforces a 7-to-10-day moratorium on reusing the name
of a recently-deleted database instance. When integration builds are
triggered frequently (such as builds 344 and 345), Terraform's apply
step fails because the previously-destroyed name 'upgrade-mysql-mysql-db'
is still locked by GCP's resource-reclamation pipeline.

Appending a 4-byte `random_id` suffix bypasses the name reservation
lock while keeping resource names fully compatible with our leftover
environment cleanup filter (`upgrade-mysql`).

References:
- Official GCP Error Documentation:
  https://cloud.google.com/sql/docs/error-messages
- Concourse Build Failure:
  https://bosh.ci.cloudfoundry.org/teams/main/pipelines/bosh-director/jobs/upgrade-mysql/builds/345
- Historical Occurrence Pattern (identified via fly-search):
  Builds 319, 325, 344, 345

ai-assisted=yes
[TNZ-88995]
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a2707574-de8e-46a6-a3e7-78bfcd6da69a

📥 Commits

Reviewing files that changed from the base of the PR and between a54ba73 and af4343a.

📒 Files selected for processing (1)
  • ci/bats/iaas/gcp/terraform/main.tf

Walkthrough

The PR adds a conditional random_id resource to generate a unique 4-byte hex suffix for the MySQL database instance name. The google_sql_database_instance.mysql-db resource is updated to append this suffix to its name when var.create_mysql_db is true, replacing the fixed name format with a dynamically generated unique identifier.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the problem, solution, and references, but is missing several required template sections including tests run, release notes, breaking changes assessment, and team tags. Add the missing sections: 'What tests have you run against this PR?', 'How should this change be described in bosh release notes?', 'Does this PR introduce a breaking change?', and 'Tag your pair, your PM, and/or team!'.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: appending a random suffix to the GCP Cloud SQL database instance name, which directly aligns with the code modification and the primary objective.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-random-suffix-upgrade-mysql-db

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 and usage tips.

@selzoc selzoc merged commit b651e80 into main Jun 3, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants