Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/aws: Requiretransform may be deprecated but still is in use #10660

Merged
merged 4 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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