Skip to content

Commit

Permalink
feat(acme): add scan_count to redis storage schema
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
szesch committed Sep 21, 2023
1 parent 02cd600 commit 6a2cf8d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
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
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions kong/clustering/compat/removed_fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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 = {
Expand Down
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
Expand Up @@ -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,
Expand Down

0 comments on commit 6a2cf8d

Please sign in to comment.