Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions internal/gatewayapi/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,12 @@ func (t *Translator) processExtensionRefHTTPFilter(extFilter *v1beta1.LocalObjec
t.processUnresolvedHTTPFilter(errMsg, filterContext)
return
}
if !t.GlobalRateLimitEnabled {
errMsg := fmt.Sprintf("Enable Ratelimit in the EnvoyGateway config to configure RateLimitFilter: %s/%s",
filterNs, extFilter.Name)
t.processUnresolvedHTTPFilter(errMsg, filterContext)
return
}
rateLimit := &ir.RateLimit{
Global: &ir.GlobalRateLimit{
Rules: make([]*ir.RateLimitRule, len(rateLimitFilter.Spec.Global.Rules)),
Expand Down
3 changes: 2 additions & 1 deletion internal/gatewayapi/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func (r *Runner) subscribeAndTranslate(ctx context.Context) {

// Translate and publish IRs.
t := &gatewayapi.Translator{
GatewayClassName: v1beta1.ObjectName(update.Key),
GatewayClassName: v1beta1.ObjectName(update.Key),
GlobalRateLimitEnabled: r.EnvoyGateway.RateLimit != nil,
}
// Translate to IR
result := t.Translate(val)
Expand Down
4 changes: 4 additions & 0 deletions internal/gatewayapi/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ type Translator struct {
// the Infra IR. If unspecified, the default proxy
// image will be used.
ProxyImage string

// GlobalRateLimitEnabled is true when global
// ratelimiting has been configured by the admin.
GlobalRateLimitEnabled bool
}

type TranslateResult struct {
Expand Down
5 changes: 3 additions & 2 deletions internal/gatewayapi/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ func TestTranslate(t *testing.T) {
mustUnmarshal(t, string(output), want)

translator := &Translator{
GatewayClassName: "envoy-gateway-class",
ProxyImage: "envoyproxy/envoy:translator-tests",
GatewayClassName: "envoy-gateway-class",
ProxyImage: "envoyproxy/envoy:translator-tests",
GlobalRateLimitEnabled: true,
}

// Add common test fixtures
Expand Down