Skip to content

Conversation

Prashansa-K
Copy link
Contributor

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2025

Codecov Report

Attention: Patch coverage is 7.75194% with 119 lines in your changes missing coverage. Please review.

Project coverage is 29.07%. Comparing base (ef4c758) to head (499ba40).

Files with missing lines Patch % Lines
convert/plugin_updates.go 0.00% 67 Missing ⚠️
convert/convert.go 21.73% 36 Missing ⚠️
cmd/file_convert.go 0.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1610      +/-   ##
==========================================
+ Coverage   28.82%   29.07%   +0.24%     
==========================================
  Files          67       67              
  Lines        6785     6903     +118     
==========================================
+ Hits         1956     2007      +51     
- Misses       4687     4746      +59     
- Partials      142      150       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

28x.yaml Outdated
@@ -0,0 +1,145 @@
_format_version: "1.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

this and check.yaml - are they used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh! Bad commits. I will remove them.

@@ -27,6 +28,10 @@ const (
FormatKongGateway2x Format = "kong-gateway-2.x"
// FormatKongGateway3x represents the Kong gateway 3.x format.
FormatKongGateway3x Format = "kong-gateway-3.x"

// Adding LTS version strings
FormatKongGatewayVersion28x Format = "2.8"
Copy link
Contributor

Choose a reason for hiding this comment

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

We dont want to prefix these with kong-gateway-?

changes++
}
if changes > 0 {
cprint.UpdatePrintf("Automatically converted legacy configuration field \"%s\" to the new field %s in plugin %s\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add quotes for the new field as well?

if plugin != nil && plugin.Config != nil {
config := plugin.Config.DeepCopy()

config = updateLegacyFieldToNewField(config, "blacklist", "deny", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to print plugin name to console here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Many plugins require these updates. So, I left it out.
I have added changes so that pluginName gets printed now.

@@ -0,0 +1,98 @@
rules:
Copy link
Contributor

Choose a reason for hiding this comment

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

@Prashansa-K what would our source of truth be to come up with these rules - ie, how do we know what has changed for each entity from gateway version a to b?
I can think of /schemas/{entity} endpoint on admin API, is there anything else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


config = updateLegacyFieldToNewField(config, "whitelist", "allow", "")

if plugin.Name != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was pluginName not a required property in 2.8x?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would rather have a check here then let my code panic in-case of a schema change.

}

func removeDeprecatedFields3x(pluginConfig kong.Configuration, fieldName, pluginName string) kong.Configuration {
var changes int
Copy link
Contributor

Choose a reason for hiding this comment

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

If removing one field at a time, this function can be simplified, no? changes and the if condition based on it can be removed?

name: "auto-fixes route configuration for 2.8x",
inputFile: "testdata/file-convert/002-kong-gateway-28x-to-34x-migration/28x-routes.yaml",
errorExpected: false,
expectedOutputFile: "testdata/file-convert/002-kong-gateway-28x-to-34x-migration/34x-expected-routes.yaml",
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets add consumer and consumer group scoped plugins in the tests too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The plugins that we are auto-fixing right now aren't supported for consumer-group scoping as checked from here:
https://docs.konghq.com/hub/plugins/compatibility/#scopes

I have added a possible one for consumer-scoping. Also, expanded the tests for route-scoped and service+route scoped plugin.

@harshadixit12
Copy link
Contributor

LGTM, one suggestion for tests

@Prashansa-K Prashansa-K merged commit faec607 into main Apr 29, 2025
24 checks passed
@Prashansa-K Prashansa-K deleted the feat/migration-utility branch April 29, 2025 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants