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

[backport -> release/3.7.x] fix(certificate): unable to refresh certificate entity with vault reference when initial with an invalid string #14072

Open
wants to merge 1 commit into
base: release/3.7.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/kong-ee/fix-certificate-reference.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message: Fixed an issue that certificate entity configured with vault reference may not get refreshed on time when initial with an invalid string.
type: bugfix
scope: Core
30 changes: 29 additions & 1 deletion kong/resty/mlcache/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,28 @@ local function set_shm(self, shm_key, value, ttl, neg_ttl, flags, shm_set_tries,
end


local function del_shm(self, shm_key, value)
local shm = self.shm
local dict = self.dict

if value == nil then
if self.dict_miss then
shm = self.shm_miss
dict = self.dict_miss
end
end

local ok, err = dict:delete(shm_key)

if not ok then
ngx_log(WARN, "could not delete from lua_shared_dict '" .. shm
.. "': " .. err)
return
end

return true
end

local function set_shm_set_lru(self, key, shm_key, value, ttl, neg_ttl, flags,
shm_set_tries, l1_serializer, throw_no_mem)

Expand All @@ -421,7 +443,13 @@ local function set_shm_set_lru(self, key, shm_key, value, ttl, neg_ttl, flags,
return nil, err
end

return set_lru(self, key, value, ttl, neg_ttl, l1_serializer)
ok, err = set_lru(self, key, value, ttl, neg_ttl, l1_serializer)
if not ok and err then
-- l1_serializer returned nil + err, do not store the cached vaule in L2
del_shm(self, shm_key, value)
end

return ok, err
end


Expand Down
Loading
Loading