Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,22 @@ httpRoutes:
backendRefs:
- name: service-4
port: 8080
- group: gateway.envoyproxy.io
kind: Backend
name: backend-1
backends:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
name: backend-1
namespace: default
spec:
endpoints:
- hostname: "example.com"
ip:
address: 1.1.1.1
port: 3001
zone: zone1
backendTrafficPolicies:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,26 @@ backendTrafficPolicies:
status: "True"
type: Overridden
controllerName: gateway.envoyproxy.io/gatewayclass-controller
backends:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
name: backend-1
namespace: default
spec:
endpoints:
- hostname: example.com
ip:
address: 1.1.1.1
port: 3001
zone: zone1
status:
conditions:
- lastTransitionTime: null
message: The Backend was accepted
reason: Accepted
status: "True"
type: Accepted
gateways:
- apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
Expand Down Expand Up @@ -719,6 +739,9 @@ httpRoutes:
- backendRefs:
- name: service-4
port: 8080
- group: gateway.envoyproxy.io
kind: Backend
name: backend-1
matches:
- path:
value: /v5
Expand Down Expand Up @@ -1175,6 +1198,19 @@ xdsIR:
name: httproute/default/httproute-5/rule/0/backend/0
protocol: HTTP
weight: 1
- addressType: IP
endpoints:
- host: 1.1.1.1
hostname: example.com
port: 3001
zone: zone1
metadata:
kind: Backend
name: backend-1
namespace: default
name: httproute/default/httproute-5/rule/0/backend/1
protocol: HTTP
weight: 1
hostname: gateway.envoyproxy.io
isHTTP2: false
metadata:
Expand Down
47 changes: 40 additions & 7 deletions internal/xds/translator/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ func buildZonalLocalities(metadata *corev3.Metadata, ds *ir.DestinationSetting,
Endpoint: &endpointv3.Endpoint{
Hostname: ptr.Deref(irEp.Hostname, ""),
Address: buildAddress(irEp),
HealthCheckConfig: buildHealthCheckConfig(hc),
HealthCheckConfig: buildHealthCheckConfig(hc, irEp),
},
},
LoadBalancingWeight: wrapperspb.UInt32(1),
Expand Down Expand Up @@ -868,7 +868,7 @@ func buildWeightedZonalLocalities(metadata *corev3.Metadata, ds *ir.DestinationS
Endpoint: &endpointv3.Endpoint{
Hostname: ptr.Deref(irEp.Hostname, ""),
Address: buildAddress(irEp),
HealthCheckConfig: buildHealthCheckConfig(hc),
HealthCheckConfig: buildHealthCheckConfig(hc, irEp),
},
},
LoadBalancingWeight: wrapperspb.UInt32(1),
Expand Down Expand Up @@ -919,7 +919,7 @@ func buildWeightedLocalities(metadata *corev3.Metadata, ds *ir.DestinationSettin
Endpoint: &endpointv3.Endpoint{
Hostname: ptr.Deref(irEp.Hostname, ""),
Address: buildAddress(irEp),
HealthCheckConfig: buildHealthCheckConfig(hc),
HealthCheckConfig: buildHealthCheckConfig(hc, irEp),
},
},
HealthStatus: healthStatus,
Expand Down Expand Up @@ -949,14 +949,47 @@ func buildWeightedLocalities(metadata *corev3.Metadata, ds *ir.DestinationSettin
return locality
}

func buildHealthCheckConfig(hc *ir.HealthCheck) *endpointv3.Endpoint_HealthCheckConfig {
if hc == nil || hc.Active == nil || hc.Active.Overrides == nil {
func buildHealthCheckConfig(hc *ir.HealthCheck, ep *ir.DestinationEndpoint) *endpointv3.Endpoint_HealthCheckConfig {
if hc == nil || hc.Active == nil {
return nil
}
hostname := getHealthCheckOverridesHostname(hc, ep)
port := getHealthCheckOverridesPort(hc)

return &endpointv3.Endpoint_HealthCheckConfig{
PortValue: hc.Active.Overrides.Port,
if hostname == "" && port == nil {
return nil
}
epHC := &endpointv3.Endpoint_HealthCheckConfig{}
if hostname != "" {
epHC.Hostname = hostname
}

if port != nil {
epHC.PortValue = *port
}

return epHC
}

func getHealthCheckOverridesPort(hc *ir.HealthCheck) *uint32 {
if hc.Active.Overrides == nil {
return nil
}

return ptr.To(hc.Active.Overrides.Port)
}

func getHealthCheckOverridesHostname(hc *ir.HealthCheck, ep *ir.DestinationEndpoint) string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are 3 cases

  • hc hostname unset
  • hc hostname set in BTP
  • hostname from Backend to be used as hc hostname
    (most specific wins over least specific)

can we make sure this is true, and a test case captures this precedence

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there're coverd by:

  • first-route-dest
  • third-route-dest
    with no change in this patch.

I copied the yaml from the gateway api, but it make this patch hard to review as @zhaohuabing mentioned.

// If Active Health Check has an explicit hostname override, it will be used on Cluster.
// Otherwise, if the endpoint has a hostname, set the hostname on the EndpointHealthCheckConfig
// so that Envoy can use it for health checking.
if hc.Active.HTTP != nil && hc.Active.HTTP.Host != "" {
return ""
}
if ep == nil || ep.Hostname == nil {
return ""
}
return *ep.Hostname
}

func buildTypedExtensionProtocolOptions(args *xdsClusterArgs, requiresAutoHTTPConfig, requiresHTTP2Options, requiresAutoSNI bool) (map[string]*anypb.Any, []*tlsv3.Secret, error) {
Expand Down
Comment thread
zirain marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ http:
settings:
- endpoints:
- host: "1.2.3.4"
hostname: example.com
port: 50000
protocol: GRPC
name: "fifth-route-dest/backend/0"
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
socketAddress:
address: 1.2.3.4
portValue: 50000
healthCheckConfig:
hostname: example.com
Comment thread
zirain marked this conversation as resolved.
hostname: example.com
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
Expand Down
1 change: 1 addition & 0 deletions release-notes/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bug fixes: |
Fixed xPolicy resources being processed from all namespaces when NamespaceSelector watch mode is configured in the Kubernetes provider.
Fixed route and policy status aggregation across multiple GatewayClasses managed by the same controller, so resources preserve status from all relevant parents and ancestors instead of being overwritten by the last processed GatewayClass.
Made ConnectionLimit.Value optional so users can configure MaxConnectionDuration, MaxRequestsPerConnection, or MaxStreamDuration without setting a max connections value.
Fixed endpoint hostname is not respected when doing active health check.

# Enhancements that improve performance.
performance improvements: |
Expand Down
Loading