Skip to content
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

[release/v1.1] Cherry-pick commits for v1.1.1 #4173

Merged
merged 12 commits into from
Sep 10, 2024
Merged
2 changes: 1 addition & 1 deletion examples/extension-server/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/exampleorg/envoygateway-extension

go 1.22.5
go 1.22.7

require (
github.com/envoyproxy/gateway v1.0.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module local

go 1.22.5
go 1.22.7

require sigs.k8s.io/controller-tools v0.15.0

Expand Down
2 changes: 1 addition & 1 deletion examples/kubernetes/ext-proc-grpc-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ spec:
- sh
- "-c"
- "cp -a /app /app-live && cd /app-live && go run . --certPath=/app-live/certs/ "
image: golang:1.22.5-alpine
image: golang:1.22.7-alpine
ports:
- containerPort: 8000
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/envoyproxy/gateway

go 1.22.5
go 1.22.7

replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16

Expand Down
7 changes: 7 additions & 0 deletions internal/gatewayapi/backendtrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"math"
"math/big"
"net/http"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -962,6 +963,12 @@ func (t *Translator) buildHTTPActiveHealthChecker(h *egv1a1.HTTPActiveHealthChec
for _, r := range h.ExpectedStatuses {
statusSet.Insert(int(r))
}

// If no ExpectedStatus was set, use the default value (200)
if statusSet.Len() == 0 {
statusSet.Insert(http.StatusOK)
}

irStatuses := make([]ir.HTTPStatus, 0, statusSet.Len())

for _, r := range statusSet.List() {
Expand Down
1 change: 0 additions & 1 deletion internal/gatewayapi/conformance/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
// SkipTests is a list of tests that are skipped in the conformance suite.
var SkipTests = []suite.ConformanceTest{
tests.GatewayStaticAddresses,
tests.GatewayHTTPListenerIsolation, // https://github.com/envoyproxy/gateway/issues/3352
}

func skipTestsShortNames(skipTests []suite.ConformanceTest) []string {
Expand Down
8 changes: 4 additions & 4 deletions internal/gatewayapi/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func (t *Translator) processRequestHeaderModifierFilter(
newHeader := ir.AddHeader{
Name: headerKey,
Append: true,
Value: addHeader.Value,
Value: strings.Split(addHeader.Value, ","),
}

filterContext.AddRequestHeaders = append(filterContext.AddRequestHeaders, newHeader)
Expand Down Expand Up @@ -500,7 +500,7 @@ func (t *Translator) processRequestHeaderModifierFilter(
newHeader := ir.AddHeader{
Name: string(setHeader.Name),
Append: false,
Value: setHeader.Value,
Value: strings.Split(setHeader.Value, ","),
}

filterContext.AddRequestHeaders = append(filterContext.AddRequestHeaders, newHeader)
Expand Down Expand Up @@ -617,7 +617,7 @@ func (t *Translator) processResponseHeaderModifierFilter(
newHeader := ir.AddHeader{
Name: headerKey,
Append: true,
Value: addHeader.Value,
Value: strings.Split(addHeader.Value, ","),
}

filterContext.AddResponseHeaders = append(filterContext.AddResponseHeaders, newHeader)
Expand Down Expand Up @@ -672,7 +672,7 @@ func (t *Translator) processResponseHeaderModifierFilter(
newHeader := ir.AddHeader{
Name: string(setHeader.Name),
Append: false,
Value: setHeader.Value,
Value: strings.Split(setHeader.Value, ","),
}

filterContext.AddResponseHeaders = append(filterContext.AddResponseHeaders, newHeader)
Expand Down
42 changes: 31 additions & 11 deletions internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@
return servicePort
}

// computeHosts returns a list of the intersecting hostnames between the route
// and the listener.
func computeHosts(routeHostnames []string, listenerHostname *gwapiv1.Hostname) []string {
// computeHosts returns a list of intersecting listener hostnames and route hostnames
// that don't intersect with other listener hostnames.
func computeHosts(routeHostnames []string, listenerContext *ListenerContext) []string {
var listenerHostnameVal string
if listenerHostname != nil {
listenerHostnameVal = string(*listenerHostname)
if listenerContext != nil && listenerContext.Hostname != nil {
listenerHostnameVal = string(*listenerContext.Hostname)
}

// No route hostnames specified: use the listener hostname if specified,
Expand All @@ -280,8 +280,9 @@
return []string{"*"}
}

var hostnames []string
hostnamesSet := sets.NewString()

// Find intersecting hostnames
for i := range routeHostnames {
routeHostname := routeHostnames[i]

Expand All @@ -290,28 +291,47 @@
switch {
// No listener hostname: use the route hostname.
case len(listenerHostnameVal) == 0:
hostnames = append(hostnames, routeHostname)
hostnamesSet.Insert(routeHostname)

// Listener hostname matches the route hostname: use it.
case listenerHostnameVal == routeHostname:
hostnames = append(hostnames, routeHostname)
hostnamesSet.Insert(routeHostname)

// Listener has a wildcard hostname: check if the route hostname matches.
case strings.HasPrefix(listenerHostnameVal, "*"):
if hostnameMatchesWildcardHostname(routeHostname, listenerHostnameVal) {
hostnames = append(hostnames, routeHostname)
hostnamesSet.Insert(routeHostname)
}

// Route has a wildcard hostname: check if the listener hostname matches.
case strings.HasPrefix(routeHostname, "*"):
if hostnameMatchesWildcardHostname(listenerHostnameVal, routeHostname) {
hostnames = append(hostnames, listenerHostnameVal)
hostnamesSet.Insert(listenerHostnameVal)
}

}
}

return hostnames
// Filter out route hostnames that intersect with other listener hostnames
var listeners []*ListenerContext
if listenerContext != nil && listenerContext.gateway != nil {
listeners = listenerContext.gateway.listeners
}

for _, listener := range listeners {
if listenerContext == listener {
continue
}
if listenerContext != nil && listenerContext.Port != listener.Port {
continue

Check warning on line 326 in internal/gatewayapi/helpers.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/helpers.go#L326

Added line #L326 was not covered by tests
}
if listener.Hostname == nil {
continue
}
hostnamesSet.Delete(string(*listener.Hostname))
}

return hostnamesSet.List()
}

// hostnameMatchesWildcardHostname returns true if hostname has the non-wildcard
Expand Down
4 changes: 2 additions & 2 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ func (t *Translator) processHTTPRouteParentRefListener(route RouteContext, route
var hasHostnameIntersection bool

for _, listener := range parentRef.listeners {
hosts := computeHosts(GetHostnames(route), listener.Hostname)
hosts := computeHosts(GetHostnames(route), listener)
if len(hosts) == 0 {
continue
}
Expand Down Expand Up @@ -818,7 +818,7 @@ func (t *Translator) processTLSRouteParentRefs(tlsRoute *TLSRouteContext, resour

var hasHostnameIntersection bool
for _, listener := range parentRef.listeners {
hosts := computeHosts(GetHostnames(tlsRoute), listener.Hostname)
hosts := computeHosts(GetHostnames(tlsRoute), listener)
if len(hosts) == 0 {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,25 @@ httpRoutes:
backendRefs:
- name: service-3
port: 8080
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
namespace: default
name: httproute-4
spec:
hostnames:
- gateway.envoyproxy.io
parentRefs:
- namespace: envoy-gateway
name: gateway-2
sectionName: http
rules:
- matches:
- path:
value: "/v2"
backendRefs:
- name: service-2
port: 8080
backendTrafficPolicies:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
Expand Down Expand Up @@ -169,6 +188,29 @@ backendTrafficPolicies:
consecutiveGatewayErrors: 0
consecutiveLocalOriginFailures: 5
splitExternalLocalOriginErrors: false
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
namespace: default
name: policy-for-route-4
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: httproute-4
healthCheck:
active:
timeout: "1s"
interval: "5s"
unhealthyThreshold: 3
healthyThreshold: 3
type: HTTP
http:
path: "/healthz"
method: "GET"
expectedResponse:
type: Text
text: pong
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,45 @@ backendTrafficPolicies:
status: "True"
type: Accepted
controllerName: gateway.envoyproxy.io/gatewayclass-controller
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
creationTimestamp: null
name: policy-for-route-4
namespace: default
spec:
healthCheck:
active:
healthyThreshold: 3
http:
expectedResponse:
text: pong
type: Text
method: GET
path: /healthz
interval: 5s
timeout: 1s
type: HTTP
unhealthyThreshold: 3
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: httproute-4
status:
ancestors:
- ancestorRef:
group: gateway.networking.k8s.io
kind: Gateway
name: gateway-2
namespace: envoy-gateway
sectionName: http
conditions:
- lastTransitionTime: null
message: Policy has been accepted.
reason: Accepted
status: "True"
type: Accepted
controllerName: gateway.envoyproxy.io/gatewayclass-controller
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
Expand Down Expand Up @@ -252,7 +291,7 @@ gateways:
protocol: HTTP
status:
listeners:
- attachedRoutes: 3
- attachedRoutes: 4
conditions:
- lastTransitionTime: null
message: Sending translated listener configuration to the data plane
Expand Down Expand Up @@ -424,6 +463,44 @@ httpRoutes:
name: gateway-2
namespace: envoy-gateway
sectionName: http
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
creationTimestamp: null
name: httproute-4
namespace: default
spec:
hostnames:
- gateway.envoyproxy.io
parentRefs:
- name: gateway-2
namespace: envoy-gateway
sectionName: http
rules:
- backendRefs:
- name: service-2
port: 8080
matches:
- path:
value: /v2
status:
parents:
- conditions:
- lastTransitionTime: null
message: Route is accepted
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: null
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
name: gateway-2
namespace: envoy-gateway
sectionName: http
infraIR:
envoy-gateway/gateway-1:
proxy:
Expand Down Expand Up @@ -616,6 +693,41 @@ xdsIR:
interval: 8ms
maxEjectionPercent: 11
splitExternalLocalOriginErrors: false
- destination:
name: httproute/default/httproute-4/rule/0
settings:
- addressType: IP
endpoints:
- host: 7.7.7.7
port: 8080
protocol: HTTP
weight: 1
hostname: gateway.envoyproxy.io
isHTTP2: false
metadata:
kind: HTTPRoute
name: httproute-4
namespace: default
name: httproute/default/httproute-4/rule/0/match/0/gateway_envoyproxy_io
pathMatch:
distinct: false
name: ""
prefix: /v2
traffic:
healthCheck:
active:
healthyThreshold: 3
http:
expectedResponse:
text: pong
expectedStatuses:
- 200
host: gateway.envoyproxy.io
method: GET
path: /healthz
interval: 5s
timeout: 1s
unhealthyThreshold: 3
- destination:
name: httproute/default/httproute-1/rule/0
settings:
Expand Down
Loading
Loading