-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
refactor(aws-lambda): refactor aws-lambda plugin code with lua-resty-aws #11350
Conversation
5c5522f
to
6dd44bc
Compare
@@ -355,5 +355,29 @@ function Plugins:get_handlers() | |||
return list | |||
end | |||
|
|||
function Plugins:execute_plugin_init() |
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.
@bungle I'm trying to add support for plugins executing their own code in the init
phase, so that plugins can do things that may contain yield which cannot be done inside a require
. I'm adding an execute_plugin_init
function to achieve that. How do you feel about this? Is it a proper way or any advice?
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.
my 2cts: in the "global patches", replace require
with a pure-Lua version. Since this has been a recurring theme for a long time. That would solve a bunch of initialization problems due to "yield across C-boundary" issues.
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.
#11177 (review)
Leaving a note here: this is the discussion on the same topic. Apparently needs some works to be done to achieve that. If we can achieve that it'll be a painkiller for the restriction of not able to do any yield-able thing in module level
Tests need |
…cies into rockspec and bazel configs The commit introduces latest version of lua-resty-aws as Kong's dependency. Since lua-resty-aws relies on luaexpat to do xml decoding, Kong also needs to build libexpat during compiling/packaging.
The commits rewrite part of the aws-lambda plugin code so that the IAM role credential fetching is replaced by using lua-resty-aws credential provider.
This commits does refactoring on the majority of the aws-lambda plugin code. The IAM role credential fetching and lambda function invoking has been replaced by using the lua-resty-aws library directly.
8e111aa
to
5c62561
Compare
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 is the expat dependency now needed?
The test coverage seems to only be reduced in this PR, even though we're adding features. How do we verify that the new features provided by lua-resty-aws actually work when using the aws-lambda plugin?
Please update the PR description accordingly. If no tests are needed because we have enough coverage, this should also be mentioned.
We now need
Only those AWS-authenticating related codes and tests are removed because we no longer need them after the PR's change. Other remaining tests should pass without any problem, and I think we already have enough coverage on those. I'm still waiting to get a Speaking of the authenticating feature, it's a good point, I'd also like new tests that cover the authenticating feature included in this PR as well, but simulating the way that AWS does authenticating is quite complex in a CI environment. (I'm doing some experiments at https://github.com/Kong/kong-ee/pull/5916, and hopefully if it works well I can add similar things to OSS repo as well) I've updated the PR description to explain the tests related issue. |
…aws (#11350) * refactor(aws-lambda): add lua-resty-aws library and libexpat dependencies into rockspec and bazel configs The commit introduces latest version of lua-resty-aws as Kong's dependency. Since lua-resty-aws relies on luaexpat to do xml decoding, Kong also needs to build libexpat during compiling/packaging. * refactor(aws-lambda): use lua-resty-aws and rewrite fetch credential The commits rewrite part of the aws-lambda plugin code so that the IAM role credential fetching is replaced by using lua-resty-aws credential provider. * refactor(aws-lambda): refactor aws-lambda plugin This commits does refactoring on the majority of the aws-lambda plugin code. The IAM role credential fetching and lambda function invoking has been replaced by using the lua-resty-aws library directly. * style(*): remove useless lua file * fix(cd): fix explain manifest for libexpat * fix(cd): fix buildifier style * fix(*): try to fix lambda plugin init_worker * fix(*): fix http proxy & sts regional endpoint config * fix(*): execute plugin init code correctly * fix(*): remove lambda returned content length * chore(*): move libexpat from cross_deps to standalone repo * fix(*): do not override global config credential * chore(*): remove non-debug flag * chore(*): bump lua-resty-aws version to 1.3.0
…aws (#11350) * refactor(aws-lambda): add lua-resty-aws library and libexpat dependencies into rockspec and bazel configs The commit introduces latest version of lua-resty-aws as Kong's dependency. Since lua-resty-aws relies on luaexpat to do xml decoding, Kong also needs to build libexpat during compiling/packaging. * refactor(aws-lambda): use lua-resty-aws and rewrite fetch credential The commits rewrite part of the aws-lambda plugin code so that the IAM role credential fetching is replaced by using lua-resty-aws credential provider. * refactor(aws-lambda): refactor aws-lambda plugin This commits does refactoring on the majority of the aws-lambda plugin code. The IAM role credential fetching and lambda function invoking has been replaced by using the lua-resty-aws library directly. * style(*): remove useless lua file * fix(cd): fix explain manifest for libexpat * fix(cd): fix buildifier style * fix(*): try to fix lambda plugin init_worker * fix(*): fix http proxy & sts regional endpoint config * fix(*): execute plugin init code correctly * fix(*): remove lambda returned content length * chore(*): move libexpat from cross_deps to standalone repo * fix(*): do not override global config credential * chore(*): remove non-debug flag * chore(*): bump lua-resty-aws version to 1.3.0
Summary
This PR refactors the aws-lambda plugin by using the lua-resty-aws library.
Refactoring the aws-lambda plugin can provide Kong with multiple aspects of benefits:
Please note that the AWS authentication-related code and tests are removed because we no longer need them after the change, and all of the previous plugin's functional tests should pass after the change because there is no actual behavior-breaking change in this PR.
Checklist
Full changelog
Issue reference
#7638
KAG-1386
FTI-5242
FTI-5206