Skip to content

Commit

Permalink
fix empty backedRef with filters (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgadban authored Nov 3, 2023
1 parent 96f50e8 commit ffc9e0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions projects/gateway2/xds/xds_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ffc9e0f

Please sign in to comment.