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

feat(acme): add scan_count to redis storage schema #11532

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Changes from 1 commit
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
Next Next commit
feat(acme): add scan_count to redis storage schema
* bump lua-resty-acme plugin to 0.12.0
* expose scan_count in redis storage schema to configure
  the number of keys returned in redis scan calls
szesch committed Sep 21, 2023
commit 6a2cf8d0551f831513c7fb7f59ab2394482e9347
5 changes: 5 additions & 0 deletions CHANGELOG/unreleased/kong/11532.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
message: "add scan_count to redis storage schema"
type: feature
scope: Plugin
prs:
- 11532
2 changes: 1 addition & 1 deletion kong-3.5.0-0.rockspec
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ dependencies = {
"lua-resty-openssl == 0.8.25",
"lua-resty-counter == 0.2.1",
"lua-resty-ipmatcher == 0.6.1",
"lua-resty-acme == 0.11.0",
"lua-resty-acme == 0.12.0",
"lua-resty-session == 4.0.5",
"lua-resty-timer-ng == 0.2.5",
"lpeg == 1.0.2",
8 changes: 6 additions & 2 deletions kong/clustering/compat/removed_fields.lua
Original file line number Diff line number Diff line change
@@ -97,9 +97,13 @@ return {
},
},

-- Any dataplane older than 3.5.0
[3005000000] = {
acme = {
"storage_config.redis.scan_count",
},
cors = {
"private_network",
}
}
},
},
}
1 change: 1 addition & 0 deletions kong/plugins/acme/schema.lua
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@ local REDIS_STORAGE_SCHEMA = {
custom_validator = validate_namespace
}
},
{ scan_count = { type = "number", required = false, default = 10, description = "The number of keys to return in Redis SCAN calls." } },
}

local CONSUL_STORAGE_SCHEMA = {
31 changes: 31 additions & 0 deletions spec/03-plugins/29-acme/05-redis_storage_spec.lua
Original file line number Diff line number Diff line change
@@ -106,6 +106,37 @@ describe("Plugin: acme (storage.redis)", function()
assert.equal(0, #keys)
end)

it("redis namespace list with scan count", function()
local config1 = {
host = helpers.redis_host,
port = helpers.redis_port,
database = 0,
namespace = "namespace1",
scan_count = 20,
}

local storage1, err = redis_storage.new(config1)
assert.is_nil(err)
assert.not_nil(storage1)

for i=1,50 do
local err = storage1:set(string.format("scan-count:%02d", i), i, 10)
assert.is_nil(err)
end


local keys, err = storage1:list("scan-count")
assert.is_nil(err)
assert.is_table(keys)
assert.equal(50, #keys)

table.sort(keys)

for i=1,50 do
assert.equal(string.format("scan-count:%02d", i), keys[i])
end
end)

it("redis namespace isolation", function()
local config0 = {
host = helpers.redis_host,