Skip to content

Commit

Permalink
more validations
Browse files Browse the repository at this point in the history
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
  • Loading branch information
arkodg committed Jan 30, 2025
1 parent 98f4ce7 commit 5d08c17
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 5 deletions.
14 changes: 10 additions & 4 deletions internal/gatewayapi/clustersettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,16 +521,22 @@ func buildRetry(r *egv1a1.Retry) (*ir.Retry, error) {
if r.PerRetry.BackOff != nil {
if r.PerRetry.BackOff.MaxInterval != nil || r.PerRetry.BackOff.BaseInterval != nil {
bop := &ir.BackOffPolicy{}
if r.PerRetry.BackOff.MaxInterval != nil {
bop.MaxInterval = r.PerRetry.BackOff.MaxInterval
}

if r.PerRetry.BackOff.BaseInterval != nil {
bop.BaseInterval = r.PerRetry.BackOff.BaseInterval
if bop.BaseInterval.Duration == 0 {
return nil, fmt.Errorf("baseInterval cannot be set to 0s")
}
}
if r.PerRetry.BackOff.MaxInterval != nil {
bop.MaxInterval = r.PerRetry.BackOff.MaxInterval
if bop.MaxInterval.Duration == 0 {
return nil, fmt.Errorf("maxInterval cannot be set to 0s")
}

Check warning on line 534 in internal/gatewayapi/clustersettings.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/clustersettings.go#L533-L534

Added lines #L533 - L534 were not covered by tests
if bop.BaseInterval != nil && bop.BaseInterval.Duration > bop.MaxInterval.Duration {
return nil, fmt.Errorf("maxInterval cannot be less than baseInterval")
}
}

pr.BackOff = bop
bpr = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ httpRoutes:
backendRefs:
- name: service-1
port: 8080
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
namespace: default
name: httproute-3
spec:
hostnames:
- gateway.envoyproxy.io
parentRefs:
- namespace: envoy-gateway
name: gateway-2
sectionName: http
rules:
- matches:
- path:
value: "/route3"
backendRefs:
- name: service-1
port: 8080
backendTrafficPolicies:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
Expand Down Expand Up @@ -139,3 +158,18 @@ backendTrafficPolicies:
perRetry:
backoff:
baseInterval: 0s
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
namespace: default
name: policy-for-route-3
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: httproute-3
retry:
perRetry:
backoff:
baseInterval: 2s
maxInterval: 1s
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,37 @@ backendTrafficPolicies:
status: "False"
type: Accepted
controllerName: gateway.envoyproxy.io/gatewayclass-controller
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
creationTimestamp: null
name: policy-for-route-3
namespace: default
spec:
retry:
perRetry:
backOff:
baseInterval: 2s
maxInterval: 1s
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: httproute-3
status:
ancestors:
- ancestorRef:
group: gateway.networking.k8s.io
kind: Gateway
name: gateway-2
namespace: envoy-gateway
sectionName: http
conditions:
- lastTransitionTime: null
message: 'Retry: maxInterval cannot be less than baseInterval.'
reason: Invalid
status: "False"
type: Accepted
controllerName: gateway.envoyproxy.io/gatewayclass-controller
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
Expand Down Expand Up @@ -161,7 +192,7 @@ gateways:
protocol: HTTP
status:
listeners:
- attachedRoutes: 2
- attachedRoutes: 3
conditions:
- lastTransitionTime: null
message: Sending translated listener configuration to the data plane
Expand Down Expand Up @@ -295,6 +326,44 @@ httpRoutes:
name: gateway-2
namespace: envoy-gateway
sectionName: http
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
creationTimestamp: null
name: httproute-3
namespace: default
spec:
hostnames:
- gateway.envoyproxy.io
parentRefs:
- name: gateway-2
namespace: envoy-gateway
sectionName: http
rules:
- backendRefs:
- name: service-1
port: 8080
matches:
- path:
value: /route3
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 @@ -415,6 +484,28 @@ xdsIR:
distinct: false
name: ""
prefix: /route2
- destination:
name: httproute/default/httproute-3/rule/0
settings:
- addressType: IP
endpoints:
- host: 7.7.7.7
port: 8080
protocol: HTTP
weight: 1
directResponse:
statusCode: 500
hostname: gateway.envoyproxy.io
isHTTP2: false
metadata:
kind: HTTPRoute
name: httproute-3
namespace: default
name: httproute/default/httproute-3/rule/0/match/0/gateway_envoyproxy_io
pathMatch:
distinct: false
name: ""
prefix: /route3
- destination:
name: httproute/default/httproute-1/rule/0
settings:
Expand Down

0 comments on commit 5d08c17

Please sign in to comment.