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

fix(hybrid): opentelemetry and zipkin header_type #11686

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 68 additions & 0 deletions kong/clustering/compat/checkers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,74 @@ end


local compatible_checkers = {
{ 3005000000, --[[ 3.5.0.0 ]]
function(config_table, dp_version, log_suffix)
local has_update

for _, plugin in ipairs(config_table.plugins or {}) do
if plugin.name == 'opentelemetry' or plugin.name == 'zipkin' then
local config = plugin.config
if config.header_type == 'gcp' then
config.header_type = 'preserve'
log_warn_message('configures ' .. plugin.name .. ' plugin with:' ..
' header_type == gcp',
'overwritten with default value `preserve`',
dp_version, log_suffix)
has_update = true
end
end

if plugin.name == 'zipkin' then
local config = plugin.config
if config.default_header_type == 'gcp' then
config.default_header_type = 'b3'
log_warn_message('configures ' .. plugin.name .. ' plugin with:' ..
' default_header_type == gcp',
'overwritten with default value `b3`',
dp_version, log_suffix)
has_update = true
end
end
end

return has_update
end,
},

{ 3004000000, --[[ 3.4.0.0 ]]
function(config_table, dp_version, log_suffix)
local has_update

for _, plugin in ipairs(config_table.plugins or {}) do
if plugin.name == 'opentelemetry' or plugin.name == 'zipkin' then
local config = plugin.config
if config.header_type == 'aws' then
config.header_type = 'preserve'
log_warn_message('configures ' .. plugin.name .. ' plugin with:' ..
' header_type == aws',
'overwritten with default value `preserve`',
dp_version, log_suffix)
has_update = true
end
end

if plugin.name == 'zipkin' then
local config = plugin.config
if config.default_header_type == 'aws' then
config.default_header_type = 'b3'
log_warn_message('configures ' .. plugin.name .. ' plugin with:' ..
' default_header_type == aws',
'overwritten with default value `b3`',
dp_version, log_suffix)
has_update = true
end
end
end

return has_update
end,
},

{ 3003000000, --[[ 3.3.0.0 ]]
function(config_table, dp_version, log_suffix)
local has_update
Expand Down
89 changes: 88 additions & 1 deletion spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe("CP/DP config compat transformations #" .. strategy, function()
end)

describe("plugin config fields", function()
local rate_limit, cors
local rate_limit, cors, opentelemetry, zipkin

lazy_setup(function()
rate_limit = admin.plugins:insert {
Expand Down Expand Up @@ -195,6 +195,93 @@ describe("CP/DP config compat transformations #" .. strategy, function()
do_assert(utils.uuid(), "3.5.0", cors)
end)
end)

describe("compatibility tests for opentelemetry plugin", function()
it("replaces `aws` values of `header_type` property with default `preserve`", function()
-- [[ 3.5.x ]] --
opentelemetry = admin.plugins:insert {
name = "opentelemetry",
enabled = true,
config = {
endpoint = "http://1.1.1.1:12345/v1/trace",
-- [[ new value 3.5.0
header_type = "gcp"
-- ]]
}
}

local expected_otel_prior_35 = utils.cycle_aware_deep_copy(opentelemetry)
expected_otel_prior_35.config.header_type = "preserve"
do_assert(utils.uuid(), "3.4.0", expected_otel_prior_35)

-- cleanup
admin.plugins:remove({ id = opentelemetry.id })

-- [[ 3.4.x ]] --
opentelemetry = admin.plugins:insert {
name = "opentelemetry",
enabled = true,
config = {
endpoint = "http://1.1.1.1:12345/v1/trace",
-- [[ new value 3.4.0
header_type = "aws"
-- ]]
}
}

local expected_otel_prior_34 = utils.cycle_aware_deep_copy(opentelemetry)
expected_otel_prior_34.config.header_type = "preserve"
do_assert(utils.uuid(), "3.3.0", expected_otel_prior_34)

-- cleanup
admin.plugins:remove({ id = opentelemetry.id })
end)

end)

describe("compatibility tests for zipkin plugin", function()
it("replaces `aws` and `gcp` values of `header_type` property with default `preserve`", function()
-- [[ 3.5.x ]] --
zipkin = admin.plugins:insert {
name = "zipkin",
enabled = true,
config = {
http_endpoint = "http://1.1.1.1:12345/v1/trace",
-- [[ new value 3.5.0
header_type = "gcp"
-- ]]
}
}

local expected_zipkin_prior_35 = utils.cycle_aware_deep_copy(zipkin)
expected_zipkin_prior_35.config.header_type = "preserve"
expected_zipkin_prior_35.config.default_header_type = "b3"
do_assert(utils.uuid(), "3.4.0", expected_zipkin_prior_35)

-- cleanup
admin.plugins:remove({ id = zipkin.id })

-- [[ 3.4.x ]] --
zipkin = admin.plugins:insert {
name = "zipkin",
enabled = true,
config = {
http_endpoint = "http://1.1.1.1:12345/v1/trace",
-- [[ new value 3.4.0
header_type = "aws"
-- ]]
}
}

local expected_zipkin_prior_34 = utils.cycle_aware_deep_copy(zipkin)
expected_zipkin_prior_34.config.header_type = "preserve"
expected_zipkin_prior_34.config.default_header_type = "b3"
do_assert(utils.uuid(), "3.3.0", expected_zipkin_prior_34)

-- cleanup
admin.plugins:remove({ id = zipkin.id })
end)
end)
end)
end)

Expand Down