Skip to content

Commit 115fdb1

Browse files
committed
DirectResponse
Signed-off-by: zirain <[email protected]>
1 parent df0af7c commit 115fdb1

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

internal/gatewayapi/route.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ func (t *Translator) processGRPCRouteRules(grpcRoute *GRPCRouteContext, parentRe
516516

517517
// If the route has no valid backends then just use a direct response and don't fuss with weighted responses
518518
for _, ruleRoute := range ruleRoutes {
519-
if ruleRoute.Destination == nil && ruleRoute.Redirect == nil {
519+
noValidBackends := ruleRoute.Destination == nil || ruleRoute.Destination.ToBackendWeights().Valid == 0
520+
if noValidBackends && ruleRoute.Redirect == nil {
520521
ruleRoute.DirectResponse = &ir.DirectResponse{
521522
StatusCode: 500,
522523
}

internal/gatewayapi/testdata/backendtrafficpolicy-status-conditions.out.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ xdsIR:
576576
name: grpcroute/envoy-gateway/grpcroute-1/rule/0
577577
settings:
578578
- weight: 1
579+
directResponse:
580+
statusCode: 500
579581
headerMatches:
580582
- distinct: false
581583
exact: foo

internal/gatewayapi/testdata/envoyextensionpolicy-status-conditions.out.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,8 @@ xdsIR:
575575
name: grpcroute/envoy-gateway/grpcroute-1/rule/0
576576
settings:
577577
- weight: 1
578+
directResponse:
579+
statusCode: 500
578580
headerMatches:
579581
- distinct: false
580582
exact: foo

internal/gatewayapi/testdata/securitypolicy-status-conditions.out.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ xdsIR:
447447
name: grpcroute/envoy-gateway/grpcroute-1/rule/0
448448
settings:
449449
- weight: 1
450+
directResponse:
451+
statusCode: 500
450452
headerMatches:
451453
- distinct: false
452454
exact: foo

0 commit comments

Comments
 (0)