-
Notifications
You must be signed in to change notification settings - Fork 33
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
Limitador cluster EnvoyFilter controller #243
Conversation
Codecov Report
@@ Coverage Diff @@
## main #243 +/- ##
==========================================
- Coverage 63.83% 62.87% -0.97%
==========================================
Files 32 32
Lines 3127 3135 +8
==========================================
- Hits 1996 1971 -25
- Misses 969 994 +25
- Partials 162 170 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Looking for early review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, @eguzki! I know you'll probably add some tests still, but leaving my 👍 here since now 'cause I like the direction this is going. Thanks!
f182cc9
to
10cc4fc
Compare
Test script for macos failing 🤷
|
It's been for a while, including in I think the GHA fails to resolve Update: IPv6-related issue reported in the past: rvm/rvm#4215 |
} | ||
|
||
if logger.V(1).Enabled() { | ||
jsonData, err := json.MarshalIndent(gw, "", " ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why MarshalIndent
? I wonder whether it's suitable for when using structured logging, aka production
log mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, from the go-logr
interface I can only check logger level, nothing about the format (defined by development or production mode). I see that this MarshalIndent
call is not entirely correct as logger could be configured with structured format and debug level. By default (no LOG_*
env vars), the logger is configured with info
level and production
level. When running with make run
. it is debug
and development
. Thus, no issue with this so far.
Any better approach you are considering? Not for this PR, but considering that (almost) all controllers have this code in the beginning of the Reconcile
method, it would be nice to have all of them fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mean checking here what the log mode setting is. I just assumed that log level and log mode were two separate things, like in Authorino. But it looks like log mode and log level are somehow coupled together.
IMO, it does not have to be like that.
In Authorino, all 4 combinations are allowed, i.e.:
level: info, mode: production
level: debug, mode: production
level: info, mode: development
level: debug, mode: production
(Maybe the naming is a bit unfortunate, because production
and development
mean actually "structured" and "human-readable", respectively.)
Because it felt weird printing indented JSON when log mode is set to production
, I'd probably have used json.Marshal
instead. Not a big deal though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This project's log system is exactly the same, with those 4 combinations allowed.
Because it felt weird printing indented JSON when log mode is set to production, I'd probably have used json.Marshal instead. Not a big deal though.
Check my previous comment out again. You are right. However, if I change to Mashal
, when I run in debug + development mode when I run with make run
, it is not human readable. I need to indent it :)
So looking for alternatives that makes a good dev experience as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple comments, but nothing that would block the PR.
In general, excellent work, @eguzki!
Co-authored-by: Guilherme Cassolato <[email protected]>
What
Specific controller to manage rate limit's EnvoyFilter used to add Limitador's service cluster to the Gateway config.
RateLimitPolicy CRD controller is responsible of adding/deleting RLP refs to the gateway.
EnvoyFilter controller watches gateways. When one of them has
kuadrant.io/ratelimitpolicies
annotation, it means rate limiting should happen in that gateway, thus a EnvoyFilter resource is created for that gateway.When there is no annotation or the list of RLP refs is empty, the EnvoyFilter resource is deleted (if exists).
The EnvoyFilter resource has owner ref to the gateway associated. The controller also watches for changes in the EnvoyFilter resource and reverts them back (if spec is changed).
Verification steps
Setup the environment:
Request an instance of Kuadrant:
Create a Kuadrant
RateLimitPolicy
to configure rate limiting:Wait for RLP to be available
kubectl wait --for=condition=available ratelimitpolicy/gw-rlp -n istio-system --timeout=10s
Check for the Gateway's references to RLPs
It should output something like
Check for the Limitador's Cluster EnvoyFilter resource
It should output something like
Deleting the RLP should also delete the EnvoyFilter object as there should not be RLP refs in the gateway
Check for the Gateway's references to RLPs
It should output empty array
[]
Check for the Limitador's Cluster EnvoyFilter resource
It should
NotFound
error