Skip to content

Commit

Permalink
style(clustering/compat): style clean for checkers array (#10858)
Browse files Browse the repository at this point in the history
* style(clustering/compat): style clean

* remove clustering_data_planes
  • Loading branch information
chronolaw authored May 24, 2023
1 parent 48942ad commit 2d0f380
Showing 1 changed file with 57 additions and 30 deletions.
87 changes: 57 additions & 30 deletions kong/clustering/compat/checkers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,91 +25,82 @@ end
local compatible_checkers = {
{ 3003000000, --[[ 3.3.0.0 ]]
function(config_table, dp_version, log_suffix)
-- remove updated_at field for core entities ca_certificates, certificates, consumers,
-- targets, upstreams, plugins, workspaces, clustering_data_planes and snis
local entity_names = {
"ca_certificates", "certificates", "consumers", "targets", "upstreams",
"plugins", "workspaces", "clustering_data_planes", "snis",
}

local has_update
local updated_entities = {}

for _, name in ipairs(entity_names) do
for _, config_entity in ipairs(config_table[name] or {}) do
if config_entity["updated_at"] then

config_entity["updated_at"] = nil

has_update = true

if not updated_entities[name] then
log_warn_message("contains configuration '" .. name .. ".updated_at'",
"be removed",
dp_version,
log_suffix)

updated_entities[name] = true
end
end
end
end

-- Support legacy queueing parameters for plugins that used queues prior to 3.3. `retry_count` has been
-- completely removed, so we always supply the default of 10 as that provides the same behavior as with a
-- pre 3.3 CP. The other queueing related legacy parameters can be determined from the new queue
-- configuration table.
for _, plugin in ipairs(config_table.plugins or {}) do
local config = plugin.config

if plugin.name == 'statsd' or plugin.name == 'datadog' then
if type(config.retry_count) ~= "number" then
config.retry_count = 10
has_update = true
end

if type(config.queue_size) ~= "number" then
if config.queue and type(config.queue.max_batch_size) == "number" then
config.queue_size = config.queue.max_batch_size
has_update = true

else
config.queue_size = 1
has_update = true
end
end

if type(config.flush_timeout) ~= "number" then
if config.queue and type(config.queue.max_coalescing_delay) == "number" then
config.flush_timeout = config.queue.max_coalescing_delay
has_update = true

else
config.flush_timeout = 2
has_update = true
end
end

elseif plugin.name == 'opentelemetry' then

if type(config.batch_span_count) ~= "number" then
if config.queue and type(config.queue.max_batch_size) == "number" then
config.batch_span_count = config.queue.max_batch_size
has_update = true

else
config.batch_span_count = 200
has_update = true
end
end

if type(config.batch_flush_delay) ~= "number" then
if config.queue and type(config.queue.max_coalescing_delay) == "number" then
config.batch_flush_delay = config.queue.max_coalescing_delay
has_update = true

else
config.batch_flush_delay = 3
has_update = true
end
end
end
end
end -- if plugin.name
end -- for

return has_update
end,
},

{ 3003000000, --[[ 3.3.0.0 ]]
function(config_table, dp_version, log_suffix)
local has_update

for _, config_entity in ipairs(config_table.vaults or {}) do
if config_entity.name == "env" and type(config_entity.config) == "table" then
local config = config_entity.config
local prefix = config.prefix

if type(prefix) == "string" then
local new_prefix = prefix:gsub("-", "_")
if new_prefix ~= prefix then
Expand All @@ -118,6 +109,42 @@ local compatible_checkers = {
end
end
end
end -- for

return has_update
end,
},

{ 3003000000, --[[ 3.3.0.0 ]]
function(config_table, dp_version, log_suffix)
-- remove updated_at field for core entities ca_certificates, certificates, consumers,
-- targets, upstreams, plugins, workspaces, clustering_data_planes and snis
local entity_names = {
"ca_certificates", "certificates", "consumers", "targets", "upstreams",
"plugins", "workspaces", "snis",
}

local has_update
local updated_entities = {}

for _, name in ipairs(entity_names) do
for _, config_entity in ipairs(config_table[name] or {}) do
if config_entity["updated_at"] then

config_entity["updated_at"] = nil

has_update = true

if not updated_entities[name] then
log_warn_message("contains configuration '" .. name .. ".updated_at'",
"be removed",
dp_version,
log_suffix)

updated_entities[name] = true
end
end
end
end

return has_update
Expand Down

1 comment on commit 2d0f380

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:2d0f380635bdf7b0de73cade7906b35f58151859
Artifacts available https://github.com/Kong/kong/actions/runs/5067016188

Please sign in to comment.