Open
Conversation
|
This pull request does not have a backport label. Could you fix it @orouz? 🙏
|
orouz
commented
Jan 28, 2026
| projectsRateLimiter: rate.NewLimiter(rate.Every(time.Minute/600), 1), | ||
| } | ||
| wrapper.getProjectDisplayName = func(ctx context.Context, parent string) string { | ||
| if err := wrapper.projectsRateLimiter.Wait(ctx); err != nil { |
Collaborator
Author
There was a problem hiding this comment.
the only addition here
orouz
commented
Jan 28, 2026
Comment on lines
+110
to
+114
| result, _, _ := c.metadataGroup.Do(key, func() (any, error) { | ||
| metadata := c.getMetadata(ctx, orgId, projectId) | ||
| c.accountMetadataCache.Store(key, metadata) | ||
| return metadata, nil | ||
| }) |
Collaborator
Author
There was a problem hiding this comment.
dedupe same key requests
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses GCP Projects API rate limiting errors (429 quota exceeded) by implementing two complementary solutions: rate limiting and request deduplication.
Changes:
- Added rate limiting (600 requests/minute) for GCP Projects API calls to stay within quota
- Added singleflight deduplication to prevent concurrent requests for the same project metadata from making duplicate API calls
- Made golang.org/x/sync a direct dependency (was indirect)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/resources/providers/gcplib/inventory/resource_manager.go | Implemented rate limiter (600 req/min) for Projects API and singleflight for deduplicating concurrent requests for same project |
| internal/resources/providers/gcplib/inventory/resource_manager_test.go | Added unit tests for rate limiter behavior and singleflight deduplication |
| go.mod | Changed golang.org/x/sync from indirect to direct dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
Context
The quota is 600 requests per minute. with many projects and assets arriving concurrently, we could exceed this before the cache was populated.