fix: verify GCP VM creation before recording gcp_instance #1004
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Summary
Fixes a bug where tests could get stuck forever in "Preparation" phase when GCP VM creation failed (e.g., due to quota limits) but a
gcp_instancedatabase record was still created.Problem
Root Cause Investigation (Test #7768 - CCExtractor PR #2014)
While investigating why Linux tests weren't running for CCExtractor/ccextractor#2014, I discovered test #7768 had been stuck in "Preparation" for 12+ hours.
Investigation steps:
Database state check:
GCP instance check:
gcloud compute instances list --project ccextractor-sampleplatform # linux-7768 NOT listed - VM doesn't exist!GCP operation history:
The bug: The platform created the
gcp_instancerecord BEFORE verifying the GCP operation completed successfully. When the operation failed asynchronously withQUOTA_EXCEEDED, the record remained in the database. The cron job saw this record and assumed the test was running, so it never retried. The test was stuck forever with no way to recover.Solution
After calling
create_instance(), wait for the GCP operation to complete (with a 60-second timeout) before creating thegcp_instancerecord:status: DONE, no error)QUOTA_EXCEEDED, etc.)The 60-second verification timeout is sufficient to catch quota errors (which fail within seconds) while not blocking too long for legitimate slow VM creations.
Changes
mod_ci/controllers.pyGCP_VM_CREATE_VERIFY_TIMEOUT = 60constantstart_test()to callwait_for_operation()with this timeoutgcp_instancerecord after confirming success or timeouttests/test_ci/test_controllers.pytest_start_testto mockwait_for_operationTestVMCreationVerificationclass with 3 comprehensive tests:test_start_test_quota_exceeded_no_db_record- Verifies the exact scenario from test #7768test_start_test_vm_verified_creates_db_record- Verifies successful VMs create recordstest_start_test_operation_timeout_creates_db_record- Verifies slow VMs still get recordsTest plan
Manual verification completed
I manually fixed test #7768 by deleting the stale
gcp_instancerecord:The test was then picked up by the next cron run and completed successfully.
🤖 Generated with Claude Code