Skip to content

Conversation

@cfsmp3
Copy link
Contributor

@cfsmp3 cfsmp3 commented Dec 24, 2025

Summary

Before

When GCP zone resources were exhausted, users saw raw error dicts like:

Failed to create VM: {'errors': [{'code': 'ZONE_RESOURCE_POOL_EXHAUSTED', 'message': "The zone 'projects/.../zones/us-central1-a' does not have enough resources..."}]}

After

Users now see:

GCP resources temporarily unavailable in the configured zone. The test will be retried automatically when resources become available.

Known error codes handled

  • ZONE_RESOURCE_POOL_EXHAUSTED - Zone capacity issues
  • QUOTA_EXCEEDED - GCP quota limits
  • TIMEOUT - Operation timeouts
  • RESOURCE_NOT_FOUND - Missing resources
  • RESOURCE_ALREADY_EXISTS - Duplicate VM names
  • Unknown codes: Shows error code + truncated message

Test plan

  • Added 9 unit tests for parse_gcp_error() covering all edge cases
  • All tests pass locally
  • CI passes

Closes #901

🤖 Generated with Claude Code

@cfsmp3
Copy link
Contributor Author

cfsmp3 commented Dec 24, 2025

Good point! I've updated the code to:

  1. Log the full error details server-side (for debugging)
  2. Return a generic message to users: VM creation failed ({error_code}). Please contact the administrator.

For unknown error codes, sensitive info like project names and zone names are now only visible in the server logs, not exposed to users.

Known error codes (ZONE_RESOURCE_POOL_EXHAUSTED, QUOTA_EXCEEDED, etc.) still return their user-friendly messages since those don't contain sensitive data.

Also added tests to verify that sensitive info is logged but not returned.

cfsmp3 and others added 2 commits December 24, 2025 13:53
Fixes #901

When GCP fails to create a VM (e.g., due to zone resource exhaustion),
the error was logged but the test status showed a raw error dict that
was not user-friendly.

Changes:
- Added parse_gcp_error() helper function to extract meaningful messages
  from GCP API error responses
- Added GCP_ERROR_MESSAGES dict mapping known error codes to user-friendly
  messages (ZONE_RESOURCE_POOL_EXHAUSTED, QUOTA_EXCEEDED, TIMEOUT, etc.)
- Updated start_test() to use parse_gcp_error() when VM creation fails
- For unknown errors, shows the error code and a truncated message

Now users see messages like:
"GCP resources temporarily unavailable in the configured zone.
The test will be retried automatically when resources become available."

Instead of raw dicts like:
"{'errors': [{'code': 'ZONE_RESOURCE_POOL_EXHAUSTED', ...}]}"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addresses review feedback: For unknown GCP error codes, the raw error
message could contain sensitive info (project names, zones, etc).

Changes:
- Log full error details server-side for debugging
- Return generic "VM creation failed" message to users for unknown errors
- Known error codes (ZONE_RESOURCE_POOL_EXHAUSTED, etc.) still return
  user-friendly messages
- Added optional `log` parameter for testability
- Updated tests to verify sensitive info is logged but not returned

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@canihavesomecoffee canihavesomecoffee force-pushed the fix/gcp-resource-exhaustion-901 branch from 02a9a49 to e7a2137 Compare December 24, 2025 12:53
@sonarqubecloud
Copy link

@canihavesomecoffee canihavesomecoffee merged commit e3dff04 into master Dec 24, 2025
6 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.

Ensure that if resources are exhausted the test status reflects this

3 participants