Repository navigation
feat(gateway): realm-prefixed Kong entity names with legacy migration #816
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
Changes from 8 commits
f2278a6
06282c8
a39d82c
2fe1e40
e6eacf2
aff25f0
54aca7f
c7ea2da
17c0f92
f021e14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,8 @@ func createGateway(ctx context.Context, hc *HandlingContext, config *adminapi.Ga | |
| IssuerUrl: issuerURL, | ||
| Url: config.Admin.Url, | ||
| }, | ||
| TLS: hc.managedTLS(), | ||
| NamePrefix: gatewayNamePrefix(gateway.Spec.NamePrefix, hc.Zone.Status.RealmName), | ||
| TLS: hc.managedTLS(), | ||
| } | ||
|
|
||
| if hc.Zone.Spec.Redis != nil { | ||
|
|
@@ -108,6 +109,15 @@ func createGateway(ctx context.Context, hc *HandlingContext, config *adminapi.Ga | |
| return gateway, nil | ||
| } | ||
|
|
||
| // gatewayNamePrefix returns the Kong name prefix of a Gateway: the zone's realm name, or the | ||
| // current prefix if the realm name is empty, because a set prefix cannot be removed. | ||
| func gatewayNamePrefix(current, realmName string) string { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want a new feature-flag called LEGACY_GATEWAY_NAMING. If its true then we will omit the namePrefix if realmName=="default". Otherwise, we will use the use the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done in 17c0f92:
|
||
| if realmName == "" { | ||
| return current | ||
| } | ||
| return realmName | ||
| } | ||
|
|
||
| // createGatewayConsumer creates the default gateway consumer for the zone. | ||
| func createGatewayConsumer(ctx context.Context, hc *HandlingContext, gatewayName string, gateway *gatewayapi.Gateway) (*gatewayapi.Consumer, error) { | ||
| c := cclient.ClientFromContextOrDie(ctx) | ||
|
|
||
Large diffs are not rendered by default.
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.
Valid, fixed in f021e14, with a compatibility path rather than an admission change:
gatewayv1.IsValidNamePrefixmatches the CRD pattern and the 63-character limit.qa--blue), the admin operator keeps the Gateway's current prefix (usually none) and logs it, instead of failing every Gateway update. Such environments keep their pre-PR unprefixed Kong names.metadata.namewould also run on updates and could break existing Environments, and the fallback already keeps them working. The docs (environments-and-zones.md,admin.mdx) describe the limitation.Tests:
gatewayNamePrefixtable entries for a double hyphen, too long a name, and keeping an existing prefix.