-
Notifications
You must be signed in to change notification settings - Fork 132
feat: migration utility for converting configuration from 2.8 to 3.4 #1610
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
Conversation
Codecov ReportAttention: Patch coverage is
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. 🚀 New features to boost your workflow:
|
28x.yaml
Outdated
@@ -0,0 +1,145 @@ | |||
_format_version: "1.1" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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-
?
convert/plugin_updates.go
Outdated
changes++ | ||
} | ||
if changes > 0 { | ||
cprint.UpdatePrintf("Automatically converted legacy configuration field \"%s\" to the new field %s in plugin %s\n", |
There was a problem hiding this comment.
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?
convert/plugin_updates.go
Outdated
if plugin != nil && plugin.Config != nil { | ||
config := plugin.Config.DeepCopy() | ||
|
||
config = updateLegacyFieldToNewField(config, "blacklist", "deny", "") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/Kong/kong-lts-migration-preflight/blob/main/deck-rulesets/28-to-34/rules/plugins.yaml
We are using the same rules that the TSE teams use.
convert/plugin_updates.go
Outdated
|
||
config = updateLegacyFieldToNewField(config, "whitelist", "allow", "") | ||
|
||
if plugin.Name != nil { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
convert/plugin_updates.go
Outdated
} | ||
|
||
func removeDeprecatedFields3x(pluginConfig kong.Configuration, fieldName, pluginName string) kong.Configuration { | ||
var changes int |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
LGTM, one suggestion for tests |
Internal Reference: https://konghq.atlassian.net/wiki/spaces/A/pages/4476502132/decK+config+migration+utility
For #1554