Skip to content

Commit

Permalink
fix(vault): reset retry count when resolve successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
windmgc committed Jun 11, 2024
1 parent ef8ae08 commit bf3b914
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kong/pdk/vault.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,8 @@ local function new(self)
local ok, err = get_from_vault(reference, strategy, config, new_cache_key, parsed_reference)
if not ok then
local retry_count = tonumber(SECRETS_CACHE:get(SECRETS_RETRY_KEY_PREFIX .. new_cache_key) or 0, 10)
-- secrets that are failed resolving for more than SECRETS_RETRY_COUNT_THRESHOLD
-- times will be removed from the cache and stop rotation
if retry_count >= SECRETS_RETRY_COUNT_THRESHOLD then
SECRETS_CACHE:delete(new_cache_key)
SECRETS_CACHE:delete(SECRETS_RETRY_KEY_PREFIX .. new_cache_key)
Expand All @@ -1290,6 +1292,9 @@ local function new(self)
SECRETS_CACHE:incr(SECRETS_RETRY_KEY_PREFIX .. new_cache_key, 1, 0)
end
return nil, fmt("could not retrieve value for reference %s (%s)", reference, err)

else
SECRETS_CACHE:delete(SECRETS_RETRY_KEY_PREFIX .. new_cache_key)
end

return true
Expand Down

0 comments on commit bf3b914

Please sign in to comment.