Skip to content

Commit

Permalink
Merge branch 'main' into zh-developer-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonwu authored May 15, 2024
2 parents c9bb057 + a2fbbad commit 8ece7ac
Show file tree
Hide file tree
Showing 200 changed files with 996 additions and 1,247 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
with:
results_file: results.sarif
results_format: sarif
Expand Down
9 changes: 9 additions & 0 deletions api/v1alpha1/loadbalancer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ type ConsistentHash struct {
//
// +optional
Header *Header `json:"header,omitempty"`

// The table size for consistent hashing, must be prime number limited to 5000011.
//
// +kubebuilder:validation:Minimum=2
// +kubebuilder:validation:Maximum=5000011
// +kubebuilder:default=65537
// +optional
// +notImplementedHide
TableSize *uint64 `json:"tableSize,omitempty"`
}

// Header defines the header hashing configuration for consistent hash based
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@ spec:
required:
- name
type: object
tableSize:
default: 65537
description: The table size for consistent hashing, must be
prime number limited to 5000011.
format: int64
maximum: 5000011
minimum: 2
type: integer
type:
description: ConsistentHashType defines the type of input
to hash on. Valid Type values are "SourceIP" or "Header".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ xds:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: udproute/default/backend/rule/-1
statPrefix: service
name: default/eg/udp/backend
name: default/eg/udp
- '@type': type.googleapis.com/envoy.admin.v3.RoutesConfigDump
dynamicRouteConfigs:
- routeConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@
}
}
],
"name": "default/eg/udp/backend"
"name": "default/eg/udp"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ xds:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: udproute/default/backend/rule/-1
statPrefix: service
name: default/eg/udp/backend
name: default/eg/udp
- '@type': type.googleapis.com/envoy.admin.v3.RoutesConfigDump
dynamicRouteConfigs:
- routeConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,4 @@ xds:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: udproute/default/backend/rule/-1
statPrefix: service
name: default/eg/udp/backend
name: default/eg/udp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ xdsIR:
mergeSlashes: true
port: 10080
routes:
- backendWeights:
invalid: 0
valid: 0
destination:
- destination:
name: httproute/envoy-gateway-system/backend/rule/0
settings:
- endpoints:
Expand Down
24 changes: 17 additions & 7 deletions internal/gatewayapi/backendtrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,13 @@ func (t *Translator) translateBackendTrafficPolicyForRoute(policy *egv1a1.Backen
}

for _, udp := range x.UDP {
if strings.HasPrefix(udp.Destination.Name, prefix) {
udp.LoadBalancer = lb
udp.Timeout = to
if udp.Route != nil {
route := udp.Route

if strings.HasPrefix(route.Destination.Name, prefix) {
route.LoadBalancer = lb
route.Timeout = to
}
}
}

Expand Down Expand Up @@ -490,14 +494,20 @@ func (t *Translator) translateBackendTrafficPolicyForGateway(policy *egv1a1.Back
continue
}

if udp.Route == nil {
continue
}

route := udp.Route

// policy(targeting xRoute) has already set it, so we skip it.
if udp.LoadBalancer != nil || udp.Timeout != nil {
if route.LoadBalancer != nil || route.Timeout != nil {
continue
}

udp.LoadBalancer = lb
if udp.Timeout == nil {
udp.Timeout = ct
route.LoadBalancer = lb
if route.Timeout == nil {
route.Timeout = ct
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ func (t *Translator) processRequestMirrorFilter(
return
}

ds, _ := t.processDestination(mirrorBackendRef, filterContext.ParentRef, filterContext.Route, resources)
ds := t.processDestination(mirrorBackendRef, filterContext.ParentRef, filterContext.Route, resources)

newMirror := &ir.RouteDestination{
Name: fmt.Sprintf("%s-mirror-%d", irRouteDestinationName(filterContext.Route, filterContext.RuleIdx), filterIdx),
Expand Down
8 changes: 4 additions & 4 deletions internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,6 @@ func irListenerName(listener *ListenerContext) string {
return fmt.Sprintf("%s/%s/%s", listener.gateway.Namespace, listener.gateway.Name, listener.Name)
}

func irUDPListenerName(listener *ListenerContext, udpRoute *UDPRouteContext) string {
return fmt.Sprintf("%s/%s/%s/%s", listener.gateway.Namespace, listener.gateway.Name, listener.Name, udpRoute.Name)
}

func irListenerPortName(proto ir.ProtocolType, port int32) string {
return strings.ToLower(fmt.Sprintf("%s-%d", proto, port))
}
Expand All @@ -369,6 +365,10 @@ func irTCPRouteName(route RouteContext) string {
return fmt.Sprintf("%s/%s/%s", strings.ToLower(string(GetRouteType(route))), route.GetNamespace(), route.GetName())
}

func irUDPRouteName(route RouteContext) string {
return irTCPRouteName(route)
}

func irRouteDestinationName(route RouteContext, ruleIdx int) string {
return fmt.Sprintf("%srule/%d", irRoutePrefix(route), ruleIdx)
}
Expand Down
7 changes: 7 additions & 0 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR XdsIRMap
Port: uint32(containerPort),
}
xdsIR[irKey].TCP = append(xdsIR[irKey].TCP, irListener)
case gwapiv1.UDPProtocolType:
irListener := &ir.UDPListener{
Name: irListenerName(listener),
Address: "0.0.0.0",
Port: uint32(containerPort),
}
xdsIR[irKey].UDP = append(xdsIR[irKey].UDP, irListener)
}

// Add the listener to the Infra IR. Infra IR ports must have a unique port number per layer-4 protocol
Expand Down
Loading

0 comments on commit 8ece7ac

Please sign in to comment.