Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Choreo] Changes to consider organization with subscription policies #3504

Merged
merged 18 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions adapter/internal/discovery/xds/rate_limiter_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,22 @@ func (r *rateLimitPolicyCache) generateRateLimitConfig(label string) *rls_config
}

//Iterate through the subscription policies and append it to the orgDescriptors
// domain: Default
// descriptors:
// - key: organisation
// value: org001
// - key: subscription
// descriptors:
// - key: policy
// value: gold
// rate_limit:
// requests_per_unit: 1000
// unit: minute
// - key: policy
// value: silver
// rate_limit:
// requests_per_unit: 200
// unit: minute
// domain: Default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// domain: Default
// Sample Rate Limiter config:
// domain: Default

// descriptors:
// - key: organisation
// value: org001
// - key: subscription
// descriptors:
// - key: policy
// value: gold
// rate_limit:
// requests_per_unit: 1000
// unit: minute
// - key: policy
// value: silver
// rate_limit:
// requests_per_unit: 200
// unit: minute
if subscriptionPoliciesList, ok := r.metadataBasedPolicies[subscriptionPolicyType]; ok {
for orgUUID := range subscriptionPoliciesList {
var metadataDescriptor *rls_config.RateLimitDescriptor
Expand Down Expand Up @@ -331,10 +331,7 @@ func AddSubscriptionLevelRateLimitPolicy(policyList *types.SubscriptionPolicyLis
}

// Need not to add the Unauthenticated and Unlimited policies to the rate limiter service
if policy.Organization == "carbon.super" && policy.Name == "Unauthenticated" {
continue
}
if policy.Name == "Unlimited" {
if (policy.Organization == "carbon.super" && policy.Name == "Unauthenticated") || policy.DefaultLimit.RequestCount.RequestCount == -1 {
continue
}
rateLimitUnit, err := parseRateLimitUnitFromSubscriptionPolicy(policy.DefaultLimit.RequestCount.TimeUnit)
Expand Down
4 changes: 2 additions & 2 deletions adapter/internal/discovery/xds/rate_limiter_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ func TestAddSubscriptionLevelRateLimitPolicy(t *testing.T) {
DefaultLimit: &types.SubscriptionDefaultLimit{
QuotaType: "requestCount",
RequestCount: &types.SubscriptionRequestCount{
RequestCount: 2147483647,
RequestCount: -1,
TimeUnit: "min",
},
},
Expand All @@ -652,7 +652,7 @@ func TestAddSubscriptionLevelRateLimitPolicy(t *testing.T) {
DefaultLimit: &types.SubscriptionDefaultLimit{
QuotaType: "requestCount",
RequestCount: &types.SubscriptionRequestCount{
RequestCount: 2147483647,
RequestCount: -1,
TimeUnit: "min",
},
},
Expand Down
Loading