Skip to content

Commit

Permalink
Merge branch 'master' into refactor/ai-analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineJac authored Mar 6, 2024
2 parents 97055bc + 3fe3434 commit c6d8a16
Show file tree
Hide file tree
Showing 34 changed files with 1,099 additions and 999 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/autodocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v4

- name: Lookup build cache
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-deps
with:
path: ${{ env.INSTALL_ROOT }}
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
ref: ${{ github.event.inputs.target_branch }}

- name: Lookup build cache
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-deps
with:
path: ${{ env.INSTALL_ROOT }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Lookup build cache
id: cache-deps
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.BUILD_ROOT }}
key: ${{ steps.cache-key.outputs.cache-key }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

- name: Lookup build cache
id: cache-deps
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.BUILD_ROOT }}
key: ${{ needs.build.outputs.cache-key }}
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Download runtimes file
uses: Kong/gh-storage/download@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo-path: Kong/gateway-action-storage/main/.ci/runtimes.json

Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:

- name: Lookup build cache
id: cache-deps
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.BUILD_ROOT }}
key: ${{ needs.build.outputs.cache-key }}
Expand Down Expand Up @@ -345,7 +345,7 @@ jobs:

- name: Lookup build cache
id: cache-deps
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.BUILD_ROOT }}
key: ${{ needs.build.outputs.cache-key }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- name: Lookup build cache
id: cache-deps
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.BUILD_ROOT }}
key: ${{ steps.cache-key.outputs.cache-key }}
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
- name: Load Cached Packages
id: cache-deps
if: env.GHA_CACHE == 'true'
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.BUILD_ROOT }}
key: ${{ needs.build-packages.outputs.cache-key }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
- name: Cache Git
id: cache-git
if: (matrix.package == 'rpm' || matrix.image == 'debian:10') && matrix.image != ''
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /usr/local/git
key: ${{ matrix.label }}-git-2.41.0
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
- name: Cache Packages
id: cache-deps
if: env.GHA_CACHE == 'true'
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: bazel-bin/pkg
key: ${{ steps.cache-key.outputs.cache-key }}
Expand Down Expand Up @@ -401,7 +401,6 @@ jobs:
- name: Comment on commit
if: github.event_name == 'push' && matrix.label == 'ubuntu'
uses: peter-evans/commit-comment@5a6f8285b8f2e8376e41fe1b563db48e6cf78c09 # v3.0.0
continue-on-error: true # TODO: temporary fix until the token is back
with:
token: ${{ secrets.GHA_COMMENT_TOKEN }}
body: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Lookup build cache
id: cache-deps
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.BUILD_ROOT }}
key: ${{ needs.build.outputs.cache-key }}
Expand Down
2 changes: 1 addition & 1 deletion .requirements
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
KONG_PACKAGE_NAME=kong

OPENRESTY=1.25.3.1
LUAROCKS=3.9.2
LUAROCKS=3.10.0
OPENSSL=3.2.1
PCRE=10.43
LIBEXPAT=2.5.0
Expand Down
2 changes: 1 addition & 1 deletion build/luarocks/luarocks_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def luarocks_repositories():
name = "luarocks",
build_file = "//build/luarocks:BUILD.luarocks.bazel",
strip_prefix = "luarocks-" + version,
sha256 = "bca6e4ecc02c203e070acdb5f586045d45c078896f6236eb46aa33ccd9b94edb",
sha256 = "e9bf06d5ec6b8ecc6dbd1530d2d77bdb3377d814a197c46388e9f148548c1c89",
urls = [
"https://luarocks.org/releases/luarocks-" + version + ".tar.gz",
],
Expand Down
2 changes: 1 addition & 1 deletion build/luarocks/luarocks_wrap_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ if install_dest:sub(-1) ~= "/" then
install_dest = install_dest .. "/"
end
-- HACK
cfg.lua_interpreter = "luajit"
cfg.sysconfdir = install_dest .. "etc/luarocks"
cfg.variables["LUA"] = install_dest .. "openresty/luajit/bin/luajit"
cfg.variables["LUA_DIR"] = install_dest .. "openresty/luajit"
cfg.variables["LUA_INCDIR"] = install_dest .. "openresty/luajit/include/luajit-2.1"
cfg.variables["LUA_BINDIR"] = install_dest .. "openresty/luajit/bin"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/bundle/ngx_lua-0.10.26/src/ngx_http_lua_regex.c b/bundle/ngx_lua-0.10.26/src/ngx_http_lua_regex.c
index 1b52fa2..30c1650 100644
--- a/bundle/ngx_lua-0.10.26/src/ngx_http_lua_regex.c
+++ b/bundle/ngx_lua-0.10.26/src/ngx_http_lua_regex.c
@@ -688,11 +688,11 @@ ngx_http_lua_ffi_exec_regex(ngx_http_lua_regex_t *re, int flags,
ngx_pool_t *old_pool;

if (flags & NGX_LUA_RE_MODE_DFA) {
- ovecsize = 2;
+ ovecsize = 1;
re->ncaptures = 0;

} else {
- ovecsize = (re->ncaptures + 1) * 3;
+ ovecsize = re->ncaptures + 1;
}

old_pool = ngx_http_lua_pcre_malloc_init(NULL);
@@ -710,7 +710,7 @@ ngx_http_lua_ffi_exec_regex(ngx_http_lua_regex_t *re, int flags,
}

ngx_regex_match_data_size = ovecsize;
- ngx_regex_match_data = pcre2_match_data_create(ovecsize / 3, NULL);
+ ngx_regex_match_data = pcre2_match_data_create(ovecsize, NULL);

if (ngx_regex_match_data == NULL) {
rc = PCRE2_ERROR_NOMEMORY;
@@ -756,8 +756,8 @@ ngx_http_lua_ffi_exec_regex(ngx_http_lua_regex_t *re, int flags,
"n %ui, ovecsize %ui", flags, exec_opts, rc, n, ovecsize);
#endif

- if (!(flags & NGX_LUA_RE_MODE_DFA) && n > ovecsize / 3) {
- n = ovecsize / 3;
+ if (n > ovecsize) {
+ n = ovecsize;
}

for (i = 0; i < n; i++) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From f1499e3b06f698dc2813e0686aa0cc257299fcd7 Mon Sep 17 00:00:00 2001
From: swananan <[email protected]>
Date: Thu, 11 Jan 2024 08:46:17 +0800
Subject: [PATCH] changes: remove the useless pcre config.

---
config | 39 ---------------------------------------
1 file changed, 39 deletions(-)

diff --git a/bundle/ngx_stream_lua-0.0.14/config b/bundle/ngx_stream_lua-0.0.14/config
index 8db90628..e1470b7a 100644
--- a/bundle/ngx_stream_lua-0.0.14/config
+++ b/bundle/ngx_stream_lua-0.0.14/config
@@ -405,45 +405,6 @@ fi

# ----------------------------------------

-if [ $USE_PCRE = YES -o $PCRE != NONE ] && [ $PCRE != NO -a $PCRE != YES ] && [ $PCRE2 != YES ]; then
- # force pcre_version symbol to be required when PCRE is statically linked
- case "$NGX_PLATFORM" in
- Darwin:*)
- ngx_feature="require defined symbols (-u)"
- ngx_feature_name=
- ngx_feature_path=
- ngx_feature_libs="-Wl,-u,_strerror"
- ngx_feature_run=no
- ngx_feature_incs="#include <stdio.h>"
- ngx_feature_test='printf("hello");'
-
- . auto/feature
-
- if [ $ngx_found = yes ]; then
- CORE_LIBS="-Wl,-u,_pcre_version $CORE_LIBS"
- fi
- ;;
-
- *)
- ngx_feature="require defined symbols (--require-defined)"
- ngx_feature_name=
- ngx_feature_path=
- ngx_feature_libs="-Wl,--require-defined=strerror"
- ngx_feature_run=no
- ngx_feature_incs="#include <stdio.h>"
- ngx_feature_test='printf("hello");'
-
- . auto/feature
-
- if [ $ngx_found = yes ]; then
- CORE_LIBS="-Wl,--require-defined=pcre_version $CORE_LIBS"
- fi
- ;;
- esac
-fi
-
-# ----------------------------------------
-
USE_MD5=YES
USE_SHA1=YES

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/bundle/ngx_stream_lua-0.0.14/src/ngx_stream_lua_regex.c b/bundle/ngx_stream_lua-0.0.14/src/ngx_stream_lua_regex.c
index e32744e..241ec00 100644
--- a/bundle/ngx_stream_lua-0.0.14/src/ngx_stream_lua_regex.c
+++ b/bundle/ngx_stream_lua-0.0.14/src/ngx_stream_lua_regex.c
@@ -695,11 +695,11 @@ ngx_stream_lua_ffi_exec_regex(ngx_stream_lua_regex_t *re, int flags,
ngx_pool_t *old_pool;

if (flags & NGX_LUA_RE_MODE_DFA) {
- ovecsize = 2;
+ ovecsize = 1;
re->ncaptures = 0;

} else {
- ovecsize = (re->ncaptures + 1) * 3;
+ ovecsize = re->ncaptures + 1;
}

old_pool = ngx_stream_lua_pcre_malloc_init(NULL);
@@ -717,7 +717,7 @@ ngx_stream_lua_ffi_exec_regex(ngx_stream_lua_regex_t *re, int flags,
}

ngx_regex_match_data_size = ovecsize;
- ngx_regex_match_data = pcre2_match_data_create(ovecsize / 3, NULL);
+ ngx_regex_match_data = pcre2_match_data_create(ovecsize, NULL);

if (ngx_regex_match_data == NULL) {
rc = PCRE2_ERROR_NOMEMORY;
@@ -762,8 +762,8 @@ ngx_stream_lua_ffi_exec_regex(ngx_stream_lua_regex_t *re, int flags,
"n %ui, ovecsize %ui", flags, exec_opts, rc, n, ovecsize);
#endif

- if (!(flags & NGX_LUA_RE_MODE_DFA) && n > ovecsize / 3) {
- n = ovecsize / 3;
+ if (n > ovecsize) {
+ n = ovecsize;
}

for (i = 0; i < n; i++) {
@@ -796,6 +796,21 @@ ngx_stream_lua_ffi_exec_regex(ngx_stream_lua_regex_t *re, int flags,
re->ncaptures = 0;

} else {
+ /* How pcre_exec() returns captured substrings
+ * The first two-thirds of the vector is used to pass back captured
+ * substrings, each substring using a pair of integers. The remaining
+ * third of the vector is used as workspace by pcre_exec() while
+ * matching capturing subpatterns, and is not available for passing
+ * back information. The number passed in ovecsize should always be a
+ * multiple of three. If it is not, it is rounded down.
+ *
+ * When a match is successful, information about captured substrings is
+ * returned in pairs of integers, starting at the beginning of ovector,
+ * and continuing up to two-thirds of its length at the most. The first
+ * element of each pair is set to the byte offset of the first character
+ * in a substring, and the second is set to the byte offset of the first
+ * character after the end of a substring.
+ */
ovecsize = (re->ncaptures + 1) * 3;
}

2 changes: 1 addition & 1 deletion build/templates/venv-commons
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $KONG_VENV/openresty/site/lualib/?.lua;$KONG_VENV/openresty/site/lualib/?.ljbc;\
$KONG_VENV/openresty/site/lualib/?/init.lua;$KONG_VENV/openresty/site/lualib/?/init.ljbc;\
$KONG_VENV/openresty/lualib/?.lua;$KONG_VENV/openresty/lualib/?.ljbc;\
$KONG_VENV/openresty/lualib/?/init.lua;$KONG_VENV/openresty/lualib/?/init.ljbc;\
$KONG_VENV/openresty/luajit/share/luajit-2.1.0-beta3/?.lua"
$KONG_VENV/openresty/luajit/share/luajit-2.1/?.lua"

# support custom plugin development
if [ -n $KONG_PLUGIN_PATH ] ; then
Expand Down
2 changes: 2 additions & 0 deletions changelog/unreleased/kong/bump-luarocks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
message: "Bumped LuaRocks from 3.9.2 to 3.10.0"
type: dependency
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message: |
Each Kong cache instance now utilizes its own cluster event channel. This approach isolates cache invalidation events and reducing the generation of unnecessary worker events.
type: bugfix
scope: Core
2 changes: 1 addition & 1 deletion kong-3.7.0-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ build = {
["kong.router.expressions"] = "kong/router/expressions.lua",
["kong.router.atc"] = "kong/router/atc.lua",
["kong.router.fields"] = "kong/router/fields.lua",
["kong.router.transform"] = "kong/router/transform.lua",
["kong.router.utils"] = "kong/router/utils.lua",

["kong.conf_loader"] = "kong/conf_loader/init.lua",
Expand Down Expand Up @@ -610,6 +611,5 @@ build = {
["kong.timing.hooks.socket"] = "kong/timing/hooks/socket.lua",

["kong.dynamic_hook"] = "kong/dynamic_hook/init.lua",
["kong.dynamic_hook.wrap_function_gen"] = "kong/dynamic_hook/wrap_function_gen.lua",
}
}
15 changes: 11 additions & 4 deletions kong/cache/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ function _M.new(opts)
error("opts.resty_lock_opts must be a table", 2)
end

if opts.invalidation_channel and type(opts.invalidation_channel) ~= "string" then
error("opts.invalidation_channel must be a string", 2)
end

local shm_name = opts.shm_name
if not shared[shm_name] then
log(ERR, "shared dictionary ", shm_name, " not found")
Expand Down Expand Up @@ -131,17 +135,20 @@ function _M.new(opts)
end

local cluster_events = opts.cluster_events
local invalidation_channel = opts.invalidation_channel
or ("invalidations_" .. shm_name)
local self = {
cluster_events = cluster_events,
mlcache = mlcache,
dict = shared[shm_name],
shm_name = shm_name,
ttl = ttl,
neg_ttl = neg_ttl,
invalidation_channel = invalidation_channel,
}

local ok, err = cluster_events:subscribe("invalidations", function(key)
log(DEBUG, "received invalidate event from cluster for key: '", key, "'")
local ok, err = cluster_events:subscribe(self.invalidation_channel, function(key)
log(DEBUG, self.shm_name .. " received invalidate event from cluster for key: '", key, "'")
self:invalidate_local(key)
end)
if not ok then
Expand Down Expand Up @@ -230,7 +237,7 @@ function _M:invalidate_local(key)
error("key must be a string", 2)
end

log(DEBUG, "invalidating (local): '", key, "'")
log(DEBUG, self.shm_name, " invalidating (local): '", key, "'")

local ok, err = self.mlcache:delete(key)
if not ok then
Expand All @@ -248,7 +255,7 @@ function _M:invalidate(key)

log(DEBUG, "broadcasting (cluster) invalidation for key: '", key, "'")

local ok, err = self.cluster_events:broadcast("invalidations", key)
local ok, err = self.cluster_events:broadcast(self.invalidation_channel, key)
if not ok then
log(ERR, "failed to broadcast cached entity invalidation: ", err)
end
Expand Down
Loading

0 comments on commit c6d8a16

Please sign in to comment.