Skip to content

Commit

Permalink
plugins/aws: Requiretransform may be deprecated but still is in use (#…
Browse files Browse the repository at this point in the history
…10660)

Co-authored-by: Nathan Fudenberg <nathan.fudenberg@solo.io>
  • Loading branch information
davidjumani and nfuden authored Feb 26, 2025
1 parent e68f4bf commit 7f648f0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
5 changes: 5 additions & 0 deletions changelog/v1.19.0-beta13/requesttransformordering.yaml
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 2 additions & 7 deletions projects/gloo/pkg/plugins/aws/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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,
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions projects/gloo/pkg/plugins/aws/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})
})

Expand Down

0 comments on commit 7f648f0

Please sign in to comment.