Describe the bug
When RedisCached storage is set in Limitador CR and the limitador pod gets restarted, the very first http request to the Gateway is never rate limited (no 429 status code) even if it should be. Subsequent http requests behave normally (are rate limited)
To Reproduce
Have redis running and storage-secret created as specified in docs https://github.com/Kuadrant/limitador-operator/blob/main/doc/storage.md
- Set Limitador CR to use RedisCached and wait until ready. The options are not needed as even with defaults the bug appears.
apiVersion: limitador.kuadrant.io/v1alpha1
kind: Limitador
metadata:
name: limitador
spec:
storage:
redis-cached:
configSecretRef:
name: storage-secret
options:
batch-size: 1
flush-period: 1
max-cached: 1
- Apply Gateway, HttpRoute, and RLP. The RLP window time should be large enough so there is time for pod restart
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: gw
namespace: kuadrant
spec:
gatewayClassName: istio
listeners:
- allowedRoutes:
namespaces:
from: Same
hostname: '*.example.com'
name: api
port: 80
protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: route
namespace: kuadrant
spec:
hostnames:
- hostname.example.com
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: gw
rules:
- backendRefs:
- group: ''
kind: Service
name: httpbin
namespace: kuadrant
port: 8080
weight: 1
matches:
- path:
type: PathPrefix
value: /
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
name: limit
namespace: kuadrant
spec:
limits:
basic:
rates:
- limit: 5
window: 600s
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: route
- Perform enough http requests to trigger rate limiting. Last request should be rate limited and return 429
for i in {1..6}; do curl -I hostname.example.com; done
- Restart limitador pod and wait until finish:
oc rollout -n kuadrant-system restart deployment limitador-limitador
oc rollout -n kuadrant-system status deployment limitador-limitador
- Do 3 requests for the endpoint
for i in {1..3}; do curl -I hostname.example.com; done
First will return 200 and subsequent ones are correctly rate limited with 429
Expected behavior
The first http request after limitador pod restart should be rate limited and return 429
Additional context
Happens on newest nightly kuadrant builds and also last stable release of Kuadrant.
Describe the bug
When RedisCached storage is set in Limitador CR and the limitador pod gets restarted, the very first http request to the Gateway is never rate limited (no 429 status code) even if it should be. Subsequent http requests behave normally (are rate limited)
To Reproduce
Have redis running and storage-secret created as specified in docs https://github.com/Kuadrant/limitador-operator/blob/main/doc/storage.md
First will return 200 and subsequent ones are correctly rate limited with 429
Expected behavior
The first http request after limitador pod restart should be rate limited and return 429
Additional context
Happens on newest nightly kuadrant builds and also last stable release of Kuadrant.