Skip to content
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

Openresty Update #1272

Merged
merged 13 commits into from
May 24, 2021
Merged

Openresty Update #1272

merged 13 commits into from
May 24, 2021

Conversation

eloycoto
Copy link
Contributor

@eloycoto eloycoto commented May 18, 2021

Hi,

I bumped the Openresty Version to 1.9.3, the latest stable, prior we had almost this version, but with a few commits on top of that.

The most important change is related to how Luajit iterate over metatables, so the order is no longer the creation one; it's arbitrary, so the ngx.decode, cjon.decode, pairs can a different result each time. Saying that almost all test failed because we tested the string.

Example:

bash-4.4$ cat eloy/encode_args.lua
local oo = {
  a = 1,
  b= 1,
  c = 1,
  d= 1,
}
for i=1,5 do
  print(ngx.encode_args(oo))
end
bash-4.4$ resty eloy/encode_args.lua
a=1&b=1&c=1&d=1
a=1&b=1&c=1&d=1
a=1&b=1&c=1&d=1
a=1&b=1&c=1&d=1
a=1&b=1&c=1&d=1
bash-4.4$ resty eloy/encode_args.lua
c=1&a=1&d=1&b=1
c=1&a=1&d=1&b=1
c=1&a=1&d=1&b=1
c=1&a=1&d=1&b=1
c=1&a=1&d=1&b=1
bash-4.4$

Regarding other changes:

  • APICAst Module: Is removed, no longer needed, and we don't want to keep in there. Doc team you should remove from docs.
  • Oath2 support: Also removed, Doc team you should remove it.
  • Small FFI calls need to be fixed.
  • Some Integration and unit tests need to be fixed
  • Now the context is shared on ssl_service, so the PATH routing when SSL was failing, because the path cannot be retrieved, we should return instead of setting the service.
  • Rate limit with Redis was failing because it used semaphores when it was not allowed; fixed that in the best way possible.

Long PR, each commit is self-documented, so should be easy to get the context.

Fix that updates base image to Openresty 1.19.3 version.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
@eloycoto eloycoto requested review from a team as code owners May 18, 2021 09:59
**Deprecated:** Use [policies](./policies.md) instead.

Specifies the name of the main Lua module that implements the API gateway logic. Custom modules can override the functionality of the default `apicast.lua` module. See [an example](../examples/custom-module) of how to use modules.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eloycoto Will there be further text to review? If there is only the removal of text, then it LGTM 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My job is to make you happy, so no changes in doc :-)

@eloycoto eloycoto force-pushed the Openresty1.19.3 branch 3 times, most recently from a005dcb to 9c5a062 Compare May 18, 2021 15:47
@eloycoto eloycoto changed the title WIP: Openresty Update Openresty Update May 18, 2021
@@ -37,7 +37,7 @@ function _M.ref()

local _ = ngx.ctx -- load context

local ctx_ref = C.ngx_http_lua_ffi_get_ctx_ref(r)
local ctx_ref = C.ngx_http_lua_ffi_get_ctx_ref(r, ffi.new("int[1]"), ffi.new("int[1]"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Contributor Author

@eloycoto eloycoto May 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C call definition changed, and now it needs to pass a integer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 1? Does it matter? Or we can just send anything?
Would be good to clarify with a comment.

gateway/src/apicast/management.lua Outdated Show resolved Hide resolved
gateway/src/resty/http_ng/backend/test.lua Outdated Show resolved Hide resolved
spec/configuration_store_spec.lua Outdated Show resolved Hide resolved
@@ -54,7 +56,7 @@ local header_mt = {
__tostring = function(t)
local tmp = {}

for k,v in pairs(t) do
for k,v in tablex_sort(t) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do headers need to be sorted? Is it to pass some tests or is there some part of the code that expects them sorted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to pass the test, is the only way to have consistent data.

prefix = ""
first = false
end
result = string.format("%s%s%s=%s",result, prefix, k, v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to use concat to avoid passing the tmp string to format on every iteration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concat has issues with sort.

t/apicast-async-reporting.t Outdated Show resolved Hide resolved
Load configuration module and APICAST_MODULE will be disabled due to the
deprecation. From now on, policy_loader should be used.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
When using ssl_certificate phase, before the context was not populated
to other phases, so the ctx.service was set by access phase, and path
routing was not working at all.

return on path routing enabled, and setting that on the access() phase.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Semaphores are not enabled on log_by_lua phases, but we need to run this
action here. Thread is not enabled, so the timer is the only way to
execute this function.

FYI: Timer is a local request, this is why a TCP socket can be open.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
On ngx.encode_args, the encoding is not longer sorted because Luajit
changed. This way always set the encode on the sorted way to make test
easier to validate.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
This adds a new helper to validate that the response json body is
correct but it's not the same at all. This validate that a key can be
equal or match a regular expression.

Example body:

```
{"a": 1, "b": 2}
```

Example validator:

```
{"key": "a", "value": 1}
{"key": "b", "value": "\d+", "op", "regexp"}
```

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Because of the Luajit update, and the sort issues, some test need to be
changed to support dynamic information and not be flaky.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
APICAST_MODULE option is no longer supported, due to the new update,
this feature is now deprecated and no longer supported.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Oauth2 is no longer required in the gateway, JWT and Openidconnect is
the prefered way and users are aware of this deprecation since APICast 2.5

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Because of the Luajit update, and the sort issues, some test need to be
changed to support dynamic information and not be flaky.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
When setting headers, the order is important in case of duplication,
using tablex that keep the order as it was set.

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants