From bfa48a5c943e4251ef4c99cc11ab55af274aa969 Mon Sep 17 00:00:00 2001 From: Lawrence G Date: Fri, 3 Nov 2023 11:16:29 -0500 Subject: [PATCH] fix empty backedRef with filters (#107) --- .../gateway_http_route_translator.go | 27 ++++++++++++------- projects/gateway2/xds/xds_syncer.go | 6 ++--- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/projects/gateway2/translator/httproute/gateway_http_route_translator.go b/projects/gateway2/translator/httproute/gateway_http_route_translator.go index 4a0b0664a3e..e834d0ac5dd 100644 --- a/projects/gateway2/translator/httproute/gateway_http_route_translator.go +++ b/projects/gateway2/translator/httproute/gateway_http_route_translator.go @@ -3,6 +3,7 @@ package httproute import ( "context" "errors" + "net/http" "github.com/golang/protobuf/ptypes/wrappers" "github.com/solo-io/gloo/projects/gateway2/query" @@ -60,13 +61,15 @@ func translateGatewayHTTPRouteRule( Action: nil, Options: &v1.RouteOptions{}, } - setAction( - queries, - gwroute, - rule.BackendRefs, - outputRoute, - reporter, - ) + if len(rule.BackendRefs) > 0 { + setRouteAction( + queries, + gwroute, + rule.BackendRefs, + outputRoute, + reporter, + ) + } if err := applyFilters( ctx, plugins, @@ -78,8 +81,12 @@ func translateGatewayHTTPRouteRule( // return nil } if outputRoute.Action == nil { - // TODO: report error - // return nil + // TODO: maybe? report error + outputRoute.Action = &v1.Route_DirectResponseAction{ + DirectResponseAction: &v1.DirectResponseAction{ + Status: http.StatusInternalServerError, + }, + } } routes = append(routes, outputRoute) } @@ -166,7 +173,7 @@ func parsePath(path *gwv1.HTTPPathMatch) (gwv1.PathMatchType, string) { return pathType, pathValue } -func setAction( +func setRouteAction( queries query.GatewayQueries, gwroute *gwv1.HTTPRoute, backendRefs []gwv1.HTTPBackendRef, diff --git a/projects/gateway2/xds/xds_syncer.go b/projects/gateway2/xds/xds_syncer.go index 814bd878fe8..6179ff8c529 100644 --- a/projects/gateway2/xds/xds_syncer.go +++ b/projects/gateway2/xds/xds_syncer.go @@ -266,9 +266,9 @@ func (s *XdsSyncer) syncEnvoy(ctx context.Context, snap *v1snap.ApiSnapshot) rep reports.AddMessages(proxy, messages...) } - if validateErr := reports.ValidateStrict(); validateErr != nil { - logger.Warnw("Proxy had invalid config", zap.Any("proxy", proxy.GetMetadata().Ref()), zap.Error(validateErr)) - } + // if validateErr := reports.ValidateStrict(); validateErr != nil { + // logger.Warnw("Proxy had invalid config", zap.Any("proxy", proxy.GetMetadata().Ref()), zap.Error(validateErr)) + // } sanitizedSnapshot := s.sanitizer.SanitizeSnapshot(ctx, snap, xdsSnapshot, reports) // if the snapshot is not consistent, make it so