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(opentelemetry): migration exception when upgrading from below version 3.3 to 3.7 #13391

Merged
merged 2 commits into from
Jul 26, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/kong/fix-otel-migrations-exception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message: "**OpenTelemetry:** Fixed an issue where migration fails when upgrading from below version 3.3 to 3.7."
type: bugfix
scope: Plugin
4 changes: 4 additions & 0 deletions kong/plugins/opentelemetry/migrations/001_331_to_332.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ local operations = require "kong.db.migrations.operations.331_to_332"
local function ws_migration_teardown(ops)
return function(connector)
return ops:fixup_plugin_config(connector, "opentelemetry", function(config)
if not config.queue then
return false
end

if config.queue.max_batch_size == 1 then
config.queue.max_batch_size = 200
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,56 @@ local uh = require "spec.upgrade_helpers"


if uh.database_type() == 'postgres' then
local handler = uh.get_busted_handler("3.3.0", "3.6.0")
local handler = uh.get_busted_handler("3.0.0", "3.2.0")
handler("opentelemetry plugin migration", function()
lazy_setup(function()
assert(uh.start_kong())
end)

lazy_teardown(function ()
assert(uh.stop_kong())
end)

uh.setup(function ()
local admin_client = assert(uh.admin_client())

local res = assert(admin_client:send {
method = "POST",
path = "/plugins/",
body = {
name = "opentelemetry",
config = {
endpoint = "http://localhost:8080/v1/traces",
}
},
headers = {
["Content-Type"] = "application/json"
}
})
assert.res_status(201, res)
admin_client:close()
end)

uh.new_after_finish("has opentelemetry queue configuration", function ()
local admin_client = assert(uh.admin_client())
local res = assert(admin_client:send {
method = "GET",
path = "/plugins/"
})
local body = cjson.decode(assert.res_status(200, res))
assert.equal(1, #body.data)
assert.equal("opentelemetry", body.data[1].name)
local expected_config = {
queue = {
max_batch_size = 200
},
}
assert.partial_match(expected_config, body.data[1].config)
admin_client:close()
end)
end)

handler = uh.get_busted_handler("3.3.0", "3.6.0")
handler("opentelemetry plugin migration", function()
lazy_setup(function()
assert(uh.start_kong())
Expand Down
Loading