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

fix Openresty coroutine usage #329

Merged
merged 3 commits into from
Jul 31, 2020
Merged

fix Openresty coroutine usage #329

merged 3 commits into from
Jul 31, 2020

Conversation

Tieske
Copy link
Member

@Tieske Tieske commented Jul 31, 2020

OpenResty coroutines break Lua paradigms and hence can break in regular Lua code. The code now tries to detect if the original version are available and then uses those.

Fixes #265

Tieske added 3 commits July 31, 2020 12:01
wherever coroutines are used, we now check on openresty, and if
using openresty, we fallback on the original Lua/LuaJIT coroutine
functions.

Fixes #265
@Tieske Tieske merged commit 120021c into master Jul 31, 2020
@Tieske Tieske deleted the openresty branch July 31, 2020 12:25
bungle added a commit to Kong/kong that referenced this pull request Aug 6, 2020
### Summary

#### New features

  - `pretty.debug` quickly dumps a set of values to stdout for debug purposes

#### Changes

  - `pretty.write`: now also sorts non-string keys [#319](lunarmodules/Penlight#319)
  - `stringx.count` has an extra option to allow overlapping matches
    [#326](lunarmodules/Penlight#326)
  - added an extra changelog entry for `types.is_empty` on the 1.6.0 changelog, due
    to additional fixed behaviour not called out appropriately [#313](lunarmodules/Penlight#313)
  - `path.packagepath` now returns a proper error message with names tried if
    it fails

#### Fixes

  - Fix: `stringx.rfind` now properly works with overlapping matches
    [#314](lunarmodules/Penlight#314)
  - Fix: `package.searchpath` (in module `pl.compat`)
    [#328](lunarmodules/Penlight#328)
  - Fix: `path.isabs` now reports drive + relative-path as `false`, eg. "c:some/path" (Windows only)
  - Fix: OpenResty coroutines, used by `dir.dirtree`, `pl.lexer`, `pl.permute`. If
    available the original coroutine functions are now used [#329](lunarmodules/Penlight#329)
  - Fix: in `pl.strict` also predefine global `_PROMPT2`
  - Fix: in `pl.strict` apply `tostring` to the given name, in case it is not a string.
  - Fix: the lexer would not recognize numbers without leading zero; "-.123".
    See [#315](lunarmodules/Penlight#315)
dndx pushed a commit to Kong/kong that referenced this pull request Aug 12, 2020
### Summary

#### New features

  - `pretty.debug` quickly dumps a set of values to stdout for debug purposes

#### Changes

  - `pretty.write`: now also sorts non-string keys [#319](lunarmodules/Penlight#319)
  - `stringx.count` has an extra option to allow overlapping matches
    [#326](lunarmodules/Penlight#326)
  - added an extra changelog entry for `types.is_empty` on the 1.6.0 changelog, due
    to additional fixed behaviour not called out appropriately [#313](lunarmodules/Penlight#313)
  - `path.packagepath` now returns a proper error message with names tried if
    it fails

#### Fixes

  - Fix: `stringx.rfind` now properly works with overlapping matches
    [#314](lunarmodules/Penlight#314)
  - Fix: `package.searchpath` (in module `pl.compat`)
    [#328](lunarmodules/Penlight#328)
  - Fix: `path.isabs` now reports drive + relative-path as `false`, eg. "c:some/path" (Windows only)
  - Fix: OpenResty coroutines, used by `dir.dirtree`, `pl.lexer`, `pl.permute`. If
    available the original coroutine functions are now used [#329](lunarmodules/Penlight#329)
  - Fix: in `pl.strict` also predefine global `_PROMPT2`
  - Fix: in `pl.strict` apply `tostring` to the given name, in case it is not a string.
  - Fix: the lexer would not recognize numbers without leading zero; "-.123".
    See [#315](lunarmodules/Penlight#315)
Tieske pushed a commit to Kong/kong that referenced this pull request Sep 22, 2020
### Summary

#### New features

  - `pretty.debug` quickly dumps a set of values to stdout for debug purposes

#### Changes

  - `pretty.write`: now also sorts non-string keys [#319](lunarmodules/Penlight#319)
  - `stringx.count` has an extra option to allow overlapping matches
    [#326](lunarmodules/Penlight#326)
  - added an extra changelog entry for `types.is_empty` on the 1.6.0 changelog, due
    to additional fixed behaviour not called out appropriately [#313](lunarmodules/Penlight#313)
  - `path.packagepath` now returns a proper error message with names tried if
    it fails

#### Fixes

  - Fix: `stringx.rfind` now properly works with overlapping matches
    [#314](lunarmodules/Penlight#314)
  - Fix: `package.searchpath` (in module `pl.compat`)
    [#328](lunarmodules/Penlight#328)
  - Fix: `path.isabs` now reports drive + relative-path as `false`, eg. "c:some/path" (Windows only)
  - Fix: OpenResty coroutines, used by `dir.dirtree`, `pl.lexer`, `pl.permute`. If
    available the original coroutine functions are now used [#329](lunarmodules/Penlight#329)
  - Fix: in `pl.strict` also predefine global `_PROMPT2`
  - Fix: in `pl.strict` apply `tostring` to the given name, in case it is not a string.
  - Fix: the lexer would not recognize numbers without leading zero; "-.123".
    See [#315](lunarmodules/Penlight#315)
bungle added a commit to Kong/kong that referenced this pull request Sep 23, 2020
### Summary

#### New features

  - `pretty.debug` quickly dumps a set of values to stdout for debug purposes

#### Changes

  - `pretty.write`: now also sorts non-string keys [#319](lunarmodules/Penlight#319)
  - `stringx.count` has an extra option to allow overlapping matches
    [#326](lunarmodules/Penlight#326)
  - added an extra changelog entry for `types.is_empty` on the 1.6.0 changelog, due
    to additional fixed behaviour not called out appropriately [#313](lunarmodules/Penlight#313)
  - `path.packagepath` now returns a proper error message with names tried if
    it fails

#### Fixes

  - Fix: `stringx.rfind` now properly works with overlapping matches
    [#314](lunarmodules/Penlight#314)
  - Fix: `package.searchpath` (in module `pl.compat`)
    [#328](lunarmodules/Penlight#328)
  - Fix: `path.isabs` now reports drive + relative-path as `false`, eg. "c:some/path" (Windows only)
  - Fix: OpenResty coroutines, used by `dir.dirtree`, `pl.lexer`, `pl.permute`. If
    available the original coroutine functions are now used [#329](lunarmodules/Penlight#329)
  - Fix: in `pl.strict` also predefine global `_PROMPT2`
  - Fix: in `pl.strict` apply `tostring` to the given name, in case it is not a string.
  - Fix: the lexer would not recognize numbers without leading zero; "-.123".
    See [#315](lunarmodules/Penlight#315)
bungle added a commit to Kong/kong that referenced this pull request Sep 24, 2020
### Summary

#### New features

  - `pretty.debug` quickly dumps a set of values to stdout for debug purposes

#### Changes

  - `pretty.write`: now also sorts non-string keys [#319](lunarmodules/Penlight#319)
  - `stringx.count` has an extra option to allow overlapping matches
    [#326](lunarmodules/Penlight#326)
  - added an extra changelog entry for `types.is_empty` on the 1.6.0 changelog, due
    to additional fixed behaviour not called out appropriately [#313](lunarmodules/Penlight#313)
  - `path.packagepath` now returns a proper error message with names tried if
    it fails

#### Fixes

  - Fix: `stringx.rfind` now properly works with overlapping matches
    [#314](lunarmodules/Penlight#314)
  - Fix: `package.searchpath` (in module `pl.compat`)
    [#328](lunarmodules/Penlight#328)
  - Fix: `path.isabs` now reports drive + relative-path as `false`, eg. "c:some/path" (Windows only)
  - Fix: OpenResty coroutines, used by `dir.dirtree`, `pl.lexer`, `pl.permute`. If
    available the original coroutine functions are now used [#329](lunarmodules/Penlight#329)
  - Fix: in `pl.strict` also predefine global `_PROMPT2`
  - Fix: in `pl.strict` apply `tostring` to the given name, in case it is not a string.
  - Fix: the lexer would not recognize numbers without leading zero; "-.123".
    See [#315](lunarmodules/Penlight#315)
bungle added a commit to Kong/kong that referenced this pull request Sep 27, 2020
### Summary

#### New features

  - `pretty.debug` quickly dumps a set of values to stdout for debug purposes

#### Changes

  - `pretty.write`: now also sorts non-string keys [#319](lunarmodules/Penlight#319)
  - `stringx.count` has an extra option to allow overlapping matches
    [#326](lunarmodules/Penlight#326)
  - added an extra changelog entry for `types.is_empty` on the 1.6.0 changelog, due
    to additional fixed behaviour not called out appropriately [#313](lunarmodules/Penlight#313)
  - `path.packagepath` now returns a proper error message with names tried if
    it fails

#### Fixes

  - Fix: `stringx.rfind` now properly works with overlapping matches
    [#314](lunarmodules/Penlight#314)
  - Fix: `package.searchpath` (in module `pl.compat`)
    [#328](lunarmodules/Penlight#328)
  - Fix: `path.isabs` now reports drive + relative-path as `false`, eg. "c:some/path" (Windows only)
  - Fix: OpenResty coroutines, used by `dir.dirtree`, `pl.lexer`, `pl.permute`. If
    available the original coroutine functions are now used [#329](lunarmodules/Penlight#329)
  - Fix: in `pl.strict` also predefine global `_PROMPT2`
  - Fix: in `pl.strict` apply `tostring` to the given name, in case it is not a string.
  - Fix: the lexer would not recognize numbers without leading zero; "-.123".
    See [#315](lunarmodules/Penlight#315)
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 23, 2020
## 1.9.1 (2020-09-27)

 - fix: dir.walk [#350](lunarmodules/Penlight#350)


## 1.9.1 (2020-09-24)

 - released to superseed the 1.9.0 version which was retagged in git after some
   distro's already had picked it up. This version is identical to 1.8.1.

## 1.8.1 (2020-09-24) (replacing a briefly released but broken 1.9.0 version)

## Fixes

  - In `pl.class`, `_init` can now be inherited from grandparent (or older ancestor) classes. [#289](lunarmodules/Penlight#289)
  - Fixes `dir`, `lexer`, and `permute` to no longer use coroutines. [#344](lunarmodules/Penlight#344)

## 1.8.0 (2020-08-05)

### New features

  - `pretty.debug` quickly dumps a set of values to stdout for debug purposes

### Changes

  - `pretty.write`: now also sorts non-string keys [#319](lunarmodules/Penlight#319)
  - `stringx.count` has an extra option to allow overlapping matches
    [#326](lunarmodules/Penlight#326)
  - added an extra changelog entry for `types.is_empty` on the 1.6.0 changelog, due
    to additional fixed behaviour not called out appropriately [#313](lunarmodules/Penlight#313)
  - `path.packagepath` now returns a proper error message with names tried if
    it fails

### Fixes

  - Fix: `stringx.rfind` now properly works with overlapping matches
    [#314](lunarmodules/Penlight#314)
  - Fix: `package.searchpath` (in module `pl.compat`)
    [#328](lunarmodules/Penlight#328)
  - Fix: `path.isabs` now reports drive + relative-path as `false`, eg. "c:some/path" (Windows only)
  - Fix: OpenResty coroutines, used by `dir.dirtree`, `pl.lexer`, `pl.permute`. If
    available the original coroutine functions are now used [#329](lunarmodules/Penlight#329)
  - Fix: in `pl.strict` also predefine global `_PROMPT2`
  - Fix: in `pl.strict` apply `tostring` to the given name, in case it is not a string.
  - Fix: the lexer would not recognize numbers without leading zero; "-.123".
    See [#315](lunarmodules/Penlight#315)
tkan145 added a commit to tkan145/APIcast that referenced this pull request Feb 9, 2024
This commit also removes filesystem.lua as the issue has been fixed
in penlight v1.8.0

lunarmodules/Penlight#329
tkan145 added a commit to tkan145/APIcast that referenced this pull request Feb 9, 2024
This commit also removes filesystem.lua as the issue with dir.dirtree
has been fixed in penlight v1.8.0

lunarmodules/Penlight#329
dagbay-rh added a commit to RedHatInsights/APIcast that referenced this pull request May 13, 2024
* changelog v3.13.0

* oidc: sanity check on the jwk which prevents tokens from foreign realms to be verified

* oidc: test when key not found

* oidc: enhance test when key not found

* changelog updated

* oidc: unittest when oidc pubkey not found

* oidc: add test for issuer verification

* opentelemetry instrumentation THREESCALE-7735

* bump openresty version to 1.9.3-21

* opentelemetry in devel image

* docker_compose 2.14.0

* circleci docker-compose v2.14.0

* pin JAEGERTRACING_CPP_CLIENT to 0.3.1-13.el8

* better tracing examples

* fix opentelemetry_propagate

* opentelemetry 2e2 test

* warning log line when opentracing is enabled

* opentelemetry doc

* otel doc fix

* Text proofreading

* changelog v3.13.2

* added new endpoint

* removed deprecated code

* fixed service version configuration via environment variable

* remote_v2 refactor

* refactor tests

* update doc

* update changelog

* fix t/configuration-loading-with-oidc.t

* Makefile: clean e2e test leftovers

* remote_v2.lua: index_custom_path

* service list pagination

* proxy configs pagination

* fixup! proxy configs pagination

* APICAST_SERVICES_LIST and APICAST_SERVICES_FILTER_BY_URL are compatible with new proxy config endpoint

* proxy configs pagination: unittests

* proxy configs pagination: e2e tests

* doc: services and proxy config endpoint pagination

* doc note on THREESCALE_PORTAL_ENDPOINT

* e2e tests: increases socket timeout

* remote_v2: define standard functions

* THREESCALE-7942 fix apicast bootstrap

* bin/apicast: little fix

* update CHANGELOG

* THREESCALE-9003 in boot mode on worker init check configuration expiration

* comment fix on configuration loader

* changelog updated

* proxy gateway devel environment

* THREESCALE-9193 upstream that require TLS v1.3

* THREESCALE-9193 upstream through a proxy that require TLS v1.3

* CHANGELOG.md updated

* resty/http/proxy.lua: remove leftovers

* circleci: upgrade docker

* Update examples/forward-proxy/README.md

Co-authored-by: Thomas Maas <[email protected]>

* THREESCALE-7941 - Set NGiNX variable variables_hash_max_size to 2048 to avoid startup warning.

* Updated CHANGELOG.md.

* github action: fast forward workflow

* update policy list v3.13.2

* update changelog

* release 3.14.0

* changelog updated with PR

* policy list: 3.14.0

* doc: fix outdated info and broken links

* Update doc/overview.md

Co-authored-by: Darren Fennessy <[email protected]>

* Update doc/overview.md

Co-authored-by: Darren Fennessy <[email protected]>

* doc: remove outdated info

* Update doc/overview.md

Co-authored-by: Darren Fennessy <[email protected]>

* [cli] detect number of available CPU shares from cgroups v2

* CHANGELOG.md: add entry

* cpu detection: early closing of file pointer

* dev-environment: listen-tls

* dev-environment: upstream-tlsv1.3

* dev-environment: plain-http-upstream

* dev-environment: https-proxy-upstream-tlsv13

* dev-environment: http-proxy-plain-http-upstream

* dev-environment: opentelemetry-instrumented-gateway

* THREESCALE-10224 CVE-2023-44487 http/2 rapid reset

Signed-off-by: Eguzki Astiz Lezaun <[email protected]>

* update changelog with PR number

* codecov: 3% tolerance

* enable lua_check_client_abort

Makes HTTP2 reset streams to be accounted and handled by apicast. Ref CVE-2023-44487

* remove unnecessary logs

* fix busted tests: spec/policy/apicast/apicast_spec.lua

* dev-environment: grpc

* resty-ctx.t conversion to APIcast::Blackbox

* custom-config.t conversion to APIcast::Blackbox

* fix GRPC

GRPC relies on POST HTTP2 method and ngx.req.read_body does not support HTTP2

Signed-off-by: Eguzki Astiz Lezaun <[email protected]>

* fix is_http2_request

* fix service_spec unittests

* Add support to use Basic Authentication with the forward proxy

* Update CHANGELOG.md

* Correct the http header var

* Minor refactor to avoid Proxy-Authorization leak

* Update http_proxy documentation

* Update integration tests when sending http request through proxy

Update tests to check if Proxy-Authorization reaches to the proxy
server instead of asserting the header in the upstream block.

* Update proxy url in the documentation

Proxy urls should all be http, https not supported

* Do not send Proxy-Authorization when using Camel proxy policy

* update CHANGELOG.md

* backend-cache-handler.t conversion to APIcast::Blackbox

* apicast-mapping-rules.t conversion to APIcast::Blackbox

* Extract @upstream content to a seperate file

This commit extract @upstream config to a sepearate file so
we can re-use the generic config for different upstream block
by including the upstream_shared.conf file

* Add new @upstream blocks for unbuffered request

* Introduce request_unbuffered policy

This policy allow user to disable request buffering. With this change, the
upstream location is changed based on the value provided in the context.

* Add README file

* Update CHANGELOG

* Correct the integration test

* Fix 'Transfer-Encoding: chunked' issue when sending request via proxy

When a request with the HTTP "Transfer-Encoding: chunked" header is sent, APIcast
buffers the entire request because by default it does not support sending chunked
requests. However, when sending via proxy, APIcast does not remove the header sent
in the initial request, which tells the server that the client is sending a chunk
request. This then causes an Bad Request error because the upstream will not be able
to determine the end of the chunk from the request.

This commit removes the "Transfer-Encoding: chunked" header from the request when
sending through a proxy.

* Support chunked requests when talking to proxy servers with request buffering disabled

* gateway/src/apicast/http_proxy.lua: remove unused code

* gateway/src/apicast/http_proxy.lua: remove unused code

* Correct CHANGELOG entries

* Fixed response body not being sent

* Handle "Expect:100-continue" header only when raw socket is used

With regular socket, openresty will process the Expect header on socket
read, so we only need to send back "100 Continue" when using raw socket.

* Update CHANGELOG.md file

* Wrapping block I/O call in a coroutine

* Update request_unbuffered policy README.md file

* Address PR comments

* THREESCALE-10591 token instrospection field removed

* spec/policy/token_introspection/token_introspection_spec.lua: unit tests

* t/apicast-policy-token-introspection.t: e2e tests

* token_introspection.lua: warning when introspection endpoint is not available

* keycloak dev environment

* Update CHANGELOG.md

* JWT claim check policy: uri was not escape correctly

The uri was not escaped correctly so the mapping rule will not work
as expected.

* Update CHANGELOG

* add default port to request path to the proxy

* http-proxy-plain-http-upstream dev environment: inspect traffic between apicast and proxy

* spec/resty/url_helper_spec.lua unittest for absolute_url

* remove unused code

* add default port to request path to the proxy for camel case

* Update CHANGELOG

* docker compose up instead of docker compose run

* CHANGELOG update

* camel proxy dev environment

* revert changes not related to camel proxy dev env

* CHANGELOG update

* Revert "revert changes not related to camel proxy dev env"

This reverts commit 258b1e9.

* THREESCALE-10582 http client timeouts

* small refactor

- skip_https_connect as request attribute
- http_proxy not used attribute http_backend removed

* THREESCALE-10582 e2e tests

* CHANGELOG update

* spec/http_proxy_spec.lua: very basic unittest

* CHANGELOG fix

* timeouts in src/resty/http/proxy.lua

* e2e test: upstream connection policy with HTTPS_PROXY env var

* e2e test: upstream connection policy with HTTPS_PROXY camel proxy

* Bump penlight from 1.7.0 to 1.31.1

This commit also removes filesystem.lua as the issue with dir.dirtree
has been fixed in penlight v1.8.0

lunarmodules/Penlight#329

* Update lua-resty-http to 0.17.1

* Refactor code to use lua-resty-http 0.17.1

* Update CHANGELOG.md

* Move the proxy DNS resolver code into gateway/src/resty/resolver/http.lua

To avoid having to call a resolver when used with proxies, all DNS resolution
should happen inside the connect() method

* CHANGELOG update

* Add support to set large_client_header_buffers directive

* t/large-client-header-buffers.t fix typo and remove unsued code

* Replace luafilesystem-ffi to fix build issue on aarch64

* [luacheck] update luacheck settings

* [luacheck] Fix luacheck warnings

* Logs: disable invalid upstream warning when api_backend is null and empty

* Move shared dict to seperate file

* [3scale_batcher] Simplify backend_downtime_cache handler

If cache_handler exists, the policy will need to update_downtime_cache
regardless of the backend status code. Thus, instead of passing cache_handler
to other functions it is much simpler to update the cache inside access().

* [3scale_batcher] Introduce APICAST_POLICY_BATCHER_SHARED_MEMORY_SIZE

In some cases, the batcher policy will run out of storage space (batched_reports)
and cause metrics to not being reported. This commit adds a new environment
variable to configure the batcher policy shared memory storage size

* [3scale_batcher] Updates the document with accepted size units for shared memory

* [3scale_batcher] Update README

* [3scale_batcher] Update regrex to match key with special chars

Currently, when key is base64 encoded or contains special chars, the
batcher policy will save it to the cache but won't be able to retrieve
it due to the regrex mismatch. This leads to two problems:
* Reports are not sent to the backend
* Report cache filling up over time.

This commit changes the regular expression key to accept any character
except spaces.

* Disable _G write guard

Previously when we changed penlight version we also removed the code
to silent writing to global variables warning which was added in
3scale@d8bfb0c

This commit has re-added the code to disable the warning again.

* release 3.15.0

* policy list: 3.15.0

* [chore] Remove unused shared dict

* [3scale_batcher] Update regrex to match app_id/access_token with special characters

* add required packages to dockerfile install

* dont delete packages not installed

* add pr check to build our images in prs

* update permissions for pr check

---------

Signed-off-by: Eguzki Astiz Lezaun <[email protected]>
Co-authored-by: Eguzki Astiz Lezaun <[email protected]>
Co-authored-by: lcavalle <[email protected]>
Co-authored-by: Samuele Illuminati <[email protected]>
Co-authored-by: Thomas Maas <[email protected]>
Co-authored-by: Ernani Azevedo <[email protected]>
Co-authored-by: Kevin <[email protected]>
Co-authored-by: Darren Fennessy <[email protected]>
Co-authored-by: Hector Vido <[email protected]>
Co-authored-by: An Tran <[email protected]>
Co-authored-by: tkan145 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

dir.dirtree can enter infinite loop when using ngx_lua
1 participant