Skip to content

Commit ebb902b

Browse files
authored
Add status in HTTPRoute when Ratelimit is disabled (#982)
* Add status in HTTPRoute when Ratelimit is disabled Signed-off-by: Arko Dasgupta <arko@tetrate.io>
1 parent 82e7672 commit ebb902b

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

internal/gatewayapi/filters.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,12 @@ func (t *Translator) processExtensionRefHTTPFilter(extFilter *v1beta1.LocalObjec
684684
t.processUnresolvedHTTPFilter(errMsg, filterContext)
685685
return
686686
}
687+
if !t.GlobalRateLimitEnabled {
688+
errMsg := fmt.Sprintf("Enable Ratelimit in the EnvoyGateway config to configure RateLimitFilter: %s/%s",
689+
filterNs, extFilter.Name)
690+
t.processUnresolvedHTTPFilter(errMsg, filterContext)
691+
return
692+
}
687693
rateLimit := &ir.RateLimit{
688694
Global: &ir.GlobalRateLimit{
689695
Rules: make([]*ir.RateLimitRule, len(rateLimitFilter.Spec.Global.Rules)),

internal/gatewayapi/runner/runner.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ func (r *Runner) subscribeAndTranslate(ctx context.Context) {
5555

5656
// Translate and publish IRs.
5757
t := &gatewayapi.Translator{
58-
GatewayClassName: v1beta1.ObjectName(update.Key),
58+
GatewayClassName: v1beta1.ObjectName(update.Key),
59+
GlobalRateLimitEnabled: r.EnvoyGateway.RateLimit != nil,
5960
}
6061
// Translate to IR
6162
result := t.Translate(val)

internal/gatewayapi/translator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ type Translator struct {
5757
// the Infra IR. If unspecified, the default proxy
5858
// image will be used.
5959
ProxyImage string
60+
61+
// GlobalRateLimitEnabled is true when global
62+
// ratelimiting has been configured by the admin.
63+
GlobalRateLimitEnabled bool
6064
}
6165

6266
type TranslateResult struct {

internal/gatewayapi/translator_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ func TestTranslate(t *testing.T) {
4747
mustUnmarshal(t, string(output), want)
4848

4949
translator := &Translator{
50-
GatewayClassName: "envoy-gateway-class",
51-
ProxyImage: "envoyproxy/envoy:translator-tests",
50+
GatewayClassName: "envoy-gateway-class",
51+
ProxyImage: "envoyproxy/envoy:translator-tests",
52+
GlobalRateLimitEnabled: true,
5253
}
5354

5455
// Add common test fixtures

0 commit comments

Comments
 (0)