diff --git a/changelog/v1.18.10/requesttransformordering.yaml b/changelog/v1.18.10/requesttransformordering.yaml new file mode 100644 index 00000000000..cef76c6ab67 --- /dev/null +++ b/changelog/v1.18.10/requesttransformordering.yaml @@ -0,0 +1,5 @@ +changelog: +- type: FIX + issueLink: https://github.com/solo-io/solo-projects/issues/7882 + resolvesIssue: false + description: Fixes a bug where the route ordering affects the deprecated aws requiretransform functionality. diff --git a/projects/gloo/pkg/plugins/aws/plugin.go b/projects/gloo/pkg/plugins/aws/plugin.go index 806dae33f3c..2f72be656b0 100644 --- a/projects/gloo/pkg/plugins/aws/plugin.go +++ b/projects/gloo/pkg/plugins/aws/plugin.go @@ -259,9 +259,8 @@ func (p *Plugin) ProcessRoute(params plugins.RouteParams, in *v1.Route, out *env return nil, nil } - p.requiresTransformationFilter = true - var reqTransform *envoy_transform.Transformation + var transform *envoy_transform.RouteTransformations_RouteTransformation if requiresRequestTransformation { reqTransform = &envoy_transform.Transformation{ TransformationType: &envoy_transform.Transformation_HeaderBodyTransform{ @@ -270,10 +269,7 @@ func (p *Plugin) ProcessRoute(params plugins.RouteParams, in *v1.Route, out *env }, }, } - } - var transform *envoy_transform.RouteTransformations_RouteTransformation - if requiresRequestTransformation { // Early stage transform: place all headers in the request body transform = &envoy_transform.RouteTransformations_RouteTransformation{ Stage: transformation.AwsStageNumber, @@ -283,8 +279,7 @@ func (p *Plugin) ProcessRoute(params plugins.RouteParams, in *v1.Route, out *env }, }, } - } else { - p.requiresTransformationFilter = false + p.requiresTransformationFilter = true } var transforms envoy_transform.RouteTransformations diff --git a/projects/gloo/pkg/plugins/aws/plugin_test.go b/projects/gloo/pkg/plugins/aws/plugin_test.go index 6fdf3a3eea8..3be1cbb32de 100644 --- a/projects/gloo/pkg/plugins/aws/plugin_test.go +++ b/projects/gloo/pkg/plugins/aws/plugin_test.go @@ -650,6 +650,22 @@ var _ = Describe("Plugin", func() { err = awsPlugin.(plugins.RoutePlugin).ProcessRoute(plugins.RouteParams{VirtualHostParams: vhostParams}, route, outroute) Expect(err).To(MatchError("only one of unwrapAsAlb and unwrapAsApiGateway/responseTransformation may be set")) }) + It("should respect RequestTransformation irrespective of route ordering", func() { + err := awsPlugin.(plugins.UpstreamPlugin).ProcessUpstream(params, upstream, out) + Expect(err).NotTo(HaveOccurred()) + route.GetRouteAction().GetSingle().GetDestinationSpec().GetAws().RequestTransformation = true + err = awsPlugin.(plugins.RoutePlugin).ProcessRoute(plugins.RouteParams{VirtualHostParams: vhostParams}, route, outroute) + Expect(err).NotTo(HaveOccurred()) + + route.GetRouteAction().GetSingle().GetDestinationSpec().GetAws().RequestTransformation = false + route.GetRouteAction().GetSingle().GetDestinationSpec().GetAws().UnwrapAsApiGateway = true + err = awsPlugin.(plugins.RoutePlugin).ProcessRoute(plugins.RouteParams{VirtualHostParams: vhostParams}, route, outroute) + Expect(err).NotTo(HaveOccurred()) + + filters, err := awsPlugin.(plugins.HttpFilterPlugin).HttpFilters(params, nil) + Expect(err).NotTo(HaveOccurred()) + Expect(filters).To(HaveLen(2)) + }) }) })