Skip to content

move parse_service_name after serve_edge_router_rules #11800

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

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented Nov 6, 2024

Motivation

This PR moves our ServiceNameParser to be executed after our Edge Router.

Note: this will break upstream until #11801 and its companion are merged, so should be reviewed together.

For historical reasons, we needed the service name for our security handling (we talk about CORS, but it is not about CORS, CORS is a "response" part, this is about our CRSF/firewall? security where we reject a request if not in our allowed hosts).

It however lead to some issues because every route would be considered as an S3 request, as our service name could not parse the request.

As S3 now properly manages its own CORS via a special handler executed very early in the request chain, we already know before the service name parser if an S3 request that needs to have its CORS managed is an S3 request or not via some heuristics.

I believe the burden to find solutions for CORS is on the self-managed CORS services, and not for every edge route to have to find a way not to be an S3 request via the localstack.aws.protocol.service_router.legacy_rules or custom_path_addressing_rules.

Currently we do have solutions for both S3 and API Gateway, so I think now is the time to finally jump the gun so we don't have CORS issues with any of external routes: they will all be managed by our default CORS/security handling.

As a side effect, we also will see less issues where the stream of a route would have been consumed by our ServiceNameParser 😄

Follow-up would be to clean the service_router.legacy_rules because most of them are there because of CORS/security issues.

Changes

  • move the ServiceNameParser handler to be execute after our Edge Router
    • this changes means that we won't parse the request as an AWS request if an edge route was matched before

Testing

run #/13565727990 (failing due to APIGW, fixed with #11801 and upstream PR)

@bentsku bentsku added area: asf semver: patch Non-breaking changes which can be included in patch releases labels Nov 6, 2024
@bentsku bentsku added this to the Playground milestone Nov 6, 2024
@bentsku bentsku self-assigned this Nov 6, 2024
Copy link

github-actions bot commented Nov 7, 2024

S3 Image Test Results (AMD64 / ARM64)

  2 files  ±0    2 suites  ±0   8m 34s ⏱️ -31s
478 tests ±0  426 ✅ ±0   52 💤 ±0  0 ❌ ±0 
956 runs  ±0  852 ✅ ±0  104 💤 ±0  0 ❌ ±0 

Results for commit 1e89601. ± Comparison against base commit b4c4eb9.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Nov 7, 2024

LocalStack Community integration with Pro

    2 files      2 suites   1h 54m 44s ⏱️
4 104 tests 3 772 ✅ 332 💤 0 ❌
4 106 runs  3 772 ✅ 334 💤 0 ❌

Results for commit 1e89601.

♻️ This comment has been updated with latest results.

@bentsku bentsku changed the title DNM: move parse_service_name after serve_edge_router_rules move parse_service_name after serve_edge_router_rules Feb 27, 2025
@bentsku bentsku modified the milestones: Playground, 4.3 Feb 27, 2025
@bentsku bentsku force-pushed the move-service-name-parser branch from 7254b0c to 1e89601 Compare February 27, 2025 11:34
@bentsku bentsku requested a review from alexrashed February 27, 2025 19:31
@bentsku bentsku marked this pull request as ready for review February 27, 2025 19:31
@bentsku bentsku requested a review from thrau as a code owner February 27, 2025 19:31
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely great to see this change finally happening 😍 🦸🏽
Thanks a lot for keeping an eye on this, and bringing this up again! 💯

handlers.validate_request_schema, # validate request schema for public LS endpoints
handlers.serve_localstack_resources, # try to serve endpoints in /_localstack
handlers.serve_edge_router_rules,
# start aws handler chain
handlers.parse_service_name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: This absolutely minimal change is the result of a lot of work. Thanks for staying at it, absolutely fantastic to see this moving down! 💯 🥳 ‏

@bentsku bentsku merged commit 94e024a into master Mar 6, 2025
56 checks passed
@bentsku bentsku deleted the move-service-name-parser branch March 6, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: asf semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants