Skip to content

Commit

Permalink
feat: add default-true FillIDs feature gate
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed May 24, 2023
1 parent 28995cc commit 2807467
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ Adding a new version? You'll need three changes:
[#3883](https://github.com/Kong/kubernetes-ingress-controller/pull/3883)
- `Service`, `Route` and `Consumer` Kong entities now get assigned deterministic
IDs based on their unique properties (name, username, etc.) instead of random
UUIDs.
UUIDs. It is possible to opt out of this behavior by setting `FillIDs` feature
gate to `false`.
[#3933](https://github.com/Kong/kubernetes-ingress-controller/pull/3933)
[#4075](https://github.com/Kong/kubernetes-ingress-controller/pull/4075)
- Added translator to translate ingresses under `networking.k8s.io/v1` to
expression based Kong routes. The translator is enabled when feature gate
`ExpressionRoutes` is turned on and the managed Kong gateway runs in router
Expand Down
1 change: 1 addition & 0 deletions FEATURE_GATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Features that reach GA and over time become stable will be removed from this tab
| GatewayAlpha | `false` | Alpha | 2.6.0 | TBD |
| ExpressionRoutes | `false` | Alpha | 2.10.0 | TBD |
| CombinedServices | `false` | Alpha | 2.10.0 | TBD |
| FillIDs | `true` | Beta | 2.10.0 | 3.0.0 |

**NOTE**: The `Gateway` feature gate refers to [Gateway
API](https://github.com/kubernetes-sigs/gateway-api) APIs which are in
Expand Down
11 changes: 9 additions & 2 deletions internal/dataplane/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ type FeatureFlags struct {
// CombinedServices enables parser to create a single Kong Service when a Kubernetes Service is referenced
// by multiple Ingresses. This is effective only when EnableCombinedServiceRoutes is enabled.
CombinedServices bool

// FillIDs enables the parser to fill in the IDs fields of Kong entities - Services, Routes, and Consumers - based
// on their names. It ensures that IDs remain stable across restarts of the controller.
FillIDs bool
}

func NewFeatureFlags(
Expand All @@ -93,6 +97,7 @@ func NewFeatureFlags(
RegexPathPrefix: kongVersion.MajorMinorOnly().GTE(versions.ExplicitRegexPathVersionCutoff),
ExpressionRoutes: expressionRoutesEnabled,
CombinedServices: combinedRoutesEnabled && featureGates.Enabled(featuregates.CombinedServicesFeature),
FillIDs: featureGates.Enabled(featuregates.FillIDsFeature),
}
}

Expand Down Expand Up @@ -233,8 +238,10 @@ func (p *Parser) BuildKongConfig() KongConfigBuildingResult {
result.Licenses = append(result.Licenses, p.licenseGetter.GetLicense())
}

// generate IDs for Kong entities
result.FillIDs(p.logger)
if p.featureFlags.FillIDs {
// generate IDs for Kong entities
result.FillIDs(p.logger)
}

return KongConfigBuildingResult{
KongState: &result,
Expand Down
13 changes: 12 additions & 1 deletion internal/dataplane/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5321,6 +5321,15 @@ func TestNewFeatureFlags(t *testing.T) {
CombinedServices: false,
},
},
{
name: "fill ids enabled",
featureGates: map[string]bool{
featuregates.FillIDsFeature: true,
},
expectedFeatureFlags: FeatureFlags{
FillIDs: true,
},
},
}

for _, tc := range testCases {
Expand All @@ -5341,7 +5350,9 @@ func TestNewFeatureFlags(t *testing.T) {
}

func mustNewParser(t *testing.T, storer store.Storer) *Parser {
p, err := NewParser(logrus.New(), storer, FeatureFlags{})
p, err := NewParser(logrus.New(), storer, FeatureFlags{
FillIDs: featuregates.GetFeatureGatesDefaults()[featuregates.FillIDsFeature],
})
require.NoError(t, err)
return p
}
5 changes: 5 additions & 0 deletions internal/manager/featuregates/feature_gates.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const (
// a Kubernetes Service is referenced by multiple netv1.Ingresses. It's effective only when CombinedRoutesFeature is enabled.
CombinedServicesFeature = "CombinedServices"

// FillIDsFeature is the name of the feature-gate that makes KIC fill in the ID fields of Kong entities (Services,
// Routes, and Consumers). It ensures that IDs remain stable across restarts of the controller.
FillIDsFeature = "FillIDs"

// DocsURL provides a link to the documentation for feature gates in the KIC repository.
DocsURL = "https://github.com/Kong/kubernetes-ingress-controller/blob/main/FEATURE_GATES.md"
)
Expand Down Expand Up @@ -78,5 +82,6 @@ func GetFeatureGatesDefaults() map[string]bool {
CombinedRoutesFeature: true,
ExpressionRoutesFeature: false,
CombinedServicesFeature: false,
FillIDsFeature: true,
}
}

0 comments on commit 2807467

Please sign in to comment.