-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Possible undefined behavior in balancer.lua #4364
Comments
Extra information:
|
Thanks for the report - this seems like a bug. I'll address it as soon as possible. Out of curiosity how did you discover this? I haven't dug deep into this yet, but from my understanding this should affect only EWMA stats in a way that we collect less data about right endpoints. |
@ElvinEfendi |
By reading random parts of code... And because it would be really hard to debug not properly working ewma, we decided that it should be reported. |
very keen indeed! Thanks again. The implication of this bug is very subtle since under enough load EWMA will eventually get stats about all the endpoints anyway. But say you send 5% of traffic to canary and 95% to production. That means it is very likely that EWMA stores the stats about canary endpoints in the production EWMA instance - which means when later on making balancing decision for canary backend it will have less statistics about the endpoints. |
#4365 fixes this bug. Reviews are welcome! |
Thank you for the fix. For me, it looks completely as it should be. |
Hi, I am encountering this recently as well. But what I want to do is actually want to make the balancer change across different region as I want to add a header dynamically during rewrite phase, and it should goes to canary balancer if the header is set, but it does not work because we will not get balancer if we have already, so I want to make a trick like:
with set the balancer to nil manually, it will force in balance phase to get a new balancer based on my added header. But I am not sure if there any risks to leverage this trick and is this a best practice to do it? Thanks very much if you can help! @ElvinEfendi |
BUG REPORT
NGINX Ingress controller version: nginx-0.25
Kubernetes version (use
kubectl version
):Environment:
uname -a
):Linux kube-a-1 4.18.0-20-generic #21~18.04.1 SMP Thu May 16 11:54:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
What happened:
It seems possible to get different balancers in different stages (balance, rewrite, log, etc.) in the same request.
In this function there is a randomness in play which might return different backend name (ergo, balancer) on consecutive invocations: https://github.com/kubernetes/ingress-nginx/blob/master/rootfs/etc/nginx/lua/balancer.lua#L185
get_balancer()
is used 3 times in rewrite, balance, and log stages.What you expected to happen:
Stable way to get balancer that should be used for a single request.
The text was updated successfully, but these errors were encountered: