diff --git a/apis/projectcontour/v1alpha1/contourconfig.go b/apis/projectcontour/v1alpha1/contourconfig.go index 015bcb8b6e2..e2b7e0275e3 100644 --- a/apis/projectcontour/v1alpha1/contourconfig.go +++ b/apis/projectcontour/v1alpha1/contourconfig.go @@ -707,6 +707,11 @@ type HTTPProxyConfig struct { // use as fallback when a non-SNI request is received. // +optional FallbackCertificate *NamespacedName `json:"fallbackCertificate,omitempty"` + + // OmitRouteSorting determines if routes will be sorted by Contour before + // being sent to Envoy or the original order will be determined. + // Defaults to routing being sorted. + OmitRouteSorting bool `json:"omitRouteSorting,omitempty"` } // NetworkParameters hold various configurable network values. diff --git a/apis/projectcontour/v1alpha1/contourconfig_helpers.go b/apis/projectcontour/v1alpha1/contourconfig_helpers.go index 33de5f4e243..03e7be080f6 100644 --- a/apis/projectcontour/v1alpha1/contourconfig_helpers.go +++ b/apis/projectcontour/v1alpha1/contourconfig_helpers.go @@ -22,13 +22,11 @@ import ( ) const ( - featureFlagRouteSorting string = "omitRouteSorting" featureFlagUseEndpointSlices string = "useEndpointSlices" ) var featureFlagsMap = map[string]bool{ featureFlagUseEndpointSlices: true, - featureFlagRouteSorting: true, } // Validate configuration that is not already covered by CRD validation. @@ -257,10 +255,6 @@ func (g *GatewayConfig) Validate() error { return nil } -func (f FeatureFlags) RouteSortingEnabled() bool { - return !slices.Contains(f, featureFlagUseEndpointSlices) -} - func (e *EnvoyLogging) Validate() error { if e == nil { return nil diff --git a/changelogs/unreleased/5772-davinci26-small.md b/changelogs/unreleased/5772-davinci26-small.md index 54122a65aa0..402373eedb1 100644 --- a/changelogs/unreleased/5772-davinci26-small.md +++ b/changelogs/unreleased/5772-davinci26-small.md @@ -1,5 +1,3 @@ ## Allow cluster operators to disable route sorting with `HTTPProxy` -This change allows cluster admins to turn on a `feature-flag` that disables route sorting. When this feature flag is turned on routes are sent to Envoy in the same -order as they are described in the `HTTPProxy` CRD. This allows operators to build more complex routing tables but they need to be careful with changes since now order -becomes important. Includes are resolved in a depth first fashion. +This change allows contour administrators to turn on a `flag`, `OmitRouteSorting` that disables route sorting. When this configuration flag is turned on routes are sent to Envoy in the same order as they are described in the `HTTPProxy` CRD. This allows operators to build more complex routing tables but they need to be careful with changes since now order becomes important. Includes are resolved in a depth first fashion. diff --git a/cmd/contour/serve.go b/cmd/contour/serve.go index 8461df3e17d..bed898bbb20 100644 --- a/cmd/contour/serve.go +++ b/cmd/contour/serve.go @@ -551,7 +551,7 @@ func (s *Server) doServe() error { globalRateLimitService: contourConfiguration.RateLimitService, maxRequestsPerConnection: contourConfiguration.Envoy.Cluster.MaxRequestsPerConnection, perConnectionBufferLimitBytes: contourConfiguration.Envoy.Cluster.PerConnectionBufferLimitBytes, - sortHTTProxyRoutes: contourConfiguration.FeatureFlags.RouteSortingEnabled(), + sortHTTProxyRoutes: !contourConfiguration.HTTPProxy.OmitRouteSorting, }) // Build the core Kubernetes event handler. diff --git a/examples/contour/01-crds.yaml b/examples/contour/01-crds.yaml index 783ff7574f5..25d799097d7 100644 --- a/examples/contour/01-crds.yaml +++ b/examples/contour/01-crds.yaml @@ -619,6 +619,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be sorted + by Contour before being sent to Envoy or the original order + will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. @@ -4102,6 +4107,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be + sorted by Contour before being sent to Envoy or the original + order will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index 2020135a384..52f02937f5a 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -838,6 +838,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be sorted + by Contour before being sent to Envoy or the original order + will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. @@ -4321,6 +4326,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be + sorted by Contour before being sent to Envoy or the original + order will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. diff --git a/examples/render/contour-gateway-provisioner.yaml b/examples/render/contour-gateway-provisioner.yaml index 4dc8215d1cb..180a92dc1cb 100644 --- a/examples/render/contour-gateway-provisioner.yaml +++ b/examples/render/contour-gateway-provisioner.yaml @@ -630,6 +630,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be sorted + by Contour before being sent to Envoy or the original order + will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. @@ -4113,6 +4118,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be + sorted by Contour before being sent to Envoy or the original + order will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index 089e75b887d..11ac023ffd2 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -841,6 +841,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be sorted + by Contour before being sent to Envoy or the original order + will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. @@ -4324,6 +4329,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be + sorted by Contour before being sent to Envoy or the original + order will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. diff --git a/examples/render/contour.yaml b/examples/render/contour.yaml index 3f24568201b..8354538a739 100644 --- a/examples/render/contour.yaml +++ b/examples/render/contour.yaml @@ -838,6 +838,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be sorted + by Contour before being sent to Envoy or the original order + will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. @@ -4321,6 +4326,11 @@ spec: - name - namespace type: object + omitRouteSorting: + description: OmitRouteSorting determines if routes will be + sorted by Contour before being sent to Envoy or the original + order will be determined. Defaults to routing being sorted. + type: boolean rootNamespaces: description: Restrict Contour to searching these namespaces for root ingress routes. diff --git a/site/content/docs/main/config/api-reference.html b/site/content/docs/main/config/api-reference.html index 2c5bc508f24..1f88ae32bad 100644 --- a/site/content/docs/main/config/api-reference.html +++ b/site/content/docs/main/config/api-reference.html @@ -7625,6 +7625,20 @@
omitRouteSorting
+OmitRouteSorting determines if routes will be sorted by Contour before +being sent to Envoy or the original order will be determined. +Defaults to routing being sorted.
+