-
Notifications
You must be signed in to change notification settings - Fork 200
balancer_by_lua for streams #30
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
Conversation
Rebase against upstream
…rn status 0 always.
Good work :) |
@rshriram Thanks for your work on this. I'll have a look as soon as I can manage :) |
@rshriram I've just committed a quick fix for travis ci to the master branch. Please rebase to it. The recent system changes in travis ci exposes a bug in our existing |
@rshriram |
ngx_stream_lua_srv_conf_handler_pt handler; | ||
} balancer; | ||
|
||
|
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.
Style: extra blank lines should get removed.
@rshriram Will you also create a separate PR to allow the |
@@ -0,0 +1,81 @@ | |||
sudo: required |
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.
The git master branch already has this file. Please rebase to it.
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.
you mean remove the entire .travis.yml file? I can certainly do it.. I just kept it around for my personal testing.
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.
@agentzh
Could you please give me some pointer on what exactly you mean by allowing ngx.balancer
to work with this? Sorry, I whipped up this PR without going into much of the code base. So, I don't really understand what is needed here.
If you could provide me with a pointer or something, that would be very useful.
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.
@rshriram I mean the git master branch already has the .travis.yml
file:
https://github.com/openresty/stream-lua-nginx-module/blob/master/.travis.yml
And the travis ci tests are all passing on the master branch. So your branch should too. And you should not add your own .travis.yml
changes as seen in this diff.
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.
@rshriram I'm not suggesting removing the .travis.yml
file. Instead I'm suggesting that the master branch already has it and you should not add your own version without good reasons.
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.
@rshriram Theres another PR in resty core for the ngx.balancer side.
@rshriram The existing ngx_http_lua test suite does not test cases utilizing
|
@rshriram Because you are currently working on the stream balancer set timeouts feature, it is your responsibility to add that upstream timeout field patch for the stream subsystem as part of your pull requests. Your change is the first user that makes use of it. But before that, it makes no sense for me to add that since I don't even have ways to actually test it. |
@rshriram If you look at the if (ctx->context & (NGX_HTTP_LUA_CONTEXT_HEADER_FILTER
| NGX_HTTP_LUA_CONTEXT_BALANCER))
{
return 0;
} This avoids yielding from within this function for that balancer by lua context. |
Thanks for the pointer. I added the exit support. |
Hi @agentzh thanks |
@rshriram Thanks for your hard work on this! Will have another look as soon as I can manage. Thanks for your patience and understanding! |
Hi @agentzh |
@rshriram Sorry, been busy with my nginx.conf talk and some other stuff. Will have a look as soon as I can manage. Thanks for your hard work on this! |
|
||
s = bp->session; | ||
|
||
ngx_stream_lua_assert(lscf->balancer.handler && r); |
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.
r
should be s
? compiler error on my side.
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.
That's odd. How did the code even compile and pass Travis tests? Anyway good catch. Will fix it
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.
@rshriram Any update?
@rshriram Thanks for your hard work, we'd better port more test case like Regarding the |
I ported whatever I could from http balancer. A whole bunch of them had to be removed because there was no equivalent in stream subsystem. I don't remember seeing tests related to lua code cache. Will check again. With regard to timeouts, I was also pointing to the fact that stream upstream server structures were different from http upstream structures. We could skip thst whole part now and slowly add that feature. What is more pressing is the support for variables and stuff in the stream subsystem. It's annoying that only a few types of variables are supported in stream subsystem. But I guess that's a patch for the stream subsystem as a whole. |
Yes, only a few types of variables are supported, still deserved a test case. https://github.com/openresty/stream-lua-nginx-module#nginx-api-for-lua |
Any updates here? I have an use case here where I need to dynamically add upstreams and balancer_by_lua would be very handy |
@felipejfc Agreed. Our OpenResty official team developer @doujiang24 will shortly look into this. |
Any news here? I didn't saw this PR today and started to port balancer_by_* to stream module, but we don't have upstream functionalities, so we need to implement them or drop everything using upstream. While working on my own code for PR I found this: https://github.com/tarantool/lua-stream-upstream-nginx-module. Maybe it will be much easier to include someting like this into OpenResty and port balancer_by_* to stream module using upstream functionality? I can help with this if you are interested @agentzh. |
No longer needed. |
Hi @agentzh
here is the PR for balancer_by_lua based on @splitice's work (#7).
Changes on top of his commits:
Fixed styling issues reported by ngx-style.pl
Fixed bugs in the test suite (t/138-balancer.t that was ported from ngx_http_lua_module)
The tests pertaining to balancer_by_lua are passing: https://travis-ci.org/rshriram/stream-lua-nginx-module/jobs/151088688
However, an unrelated test suite (069-null.t) is failing due to missing dependency cjson.lua.
If you want me to remove the
.travis.yml
file let me know. Somehow, GH seems to show that the.travis.yml
is a new addition to your existing repo.Note: I found that ngx.exit does not work inside the balancer_by_lua block. It throws an exception saying
attempt to yield across C-call boundary
. Given that this is a TCP stream block, ngx.exit does not really make sense, and so the above error seems like a valid one. I added a test to this effect. However, this behavior is not documented in the main README.