Skip to content

Commit

Permalink
change the configuration surface
Browse files Browse the repository at this point in the history
Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com>
  • Loading branch information
davinci26 committed Oct 26, 2023
1 parent 43326d8 commit 38e55c1
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 10 deletions.
5 changes: 5 additions & 0 deletions apis/projectcontour/v1alpha1/contourconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions apis/projectcontour/v1alpha1/contourconfig_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions changelogs/unreleased/5772-davinci26-small.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check warning on line 554 in cmd/contour/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/contour/serve.go#L554

Added line #L554 was not covered by tests
})

// Build the core Kubernetes event handler.
Expand Down
10 changes: 10 additions & 0 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions examples/render/contour-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions examples/render/contour-gateway-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions examples/render/contour-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions examples/render/contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions site/content/docs/main/config/api-reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -7625,6 +7625,20 @@ <h3 id="projectcontour.io/v1alpha1.HTTPProxyConfig">HTTPProxyConfig
use as fallback when a non-SNI request is received.</p>
</td>
</tr>
<tr>
<td style="white-space:nowrap">
<code>omitRouteSorting</code>
<br>
<em>
bool
</em>
</td>
<td>
<p>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.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="projectcontour.io/v1alpha1.HTTPVersionType">HTTPVersionType
Expand Down

0 comments on commit 38e55c1

Please sign in to comment.