Skip to content

Conversation

@DaveCTurner
Copy link
Contributor

The pattern-matching in S3HttpHandler is overly specific and carefully
crafted to handle the exact requests that the AWS SDK v1 makes. It turns
out that the AWS SDK v2 makes requests that are slightly different. This
commit generalizes the pattern-matching to handle both SDKs.

The pattern-matching in `S3HttpHandler` is overly specific and carefully
crafted to handle the exact requests that the AWS SDK v1 makes. It turns
out that the AWS SDK v2 makes requests that are slightly different. This
commit generalizes the pattern-matching to handle both SDKs.
@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs auto-backport Automatically create backport pull requests when merged v8.19.0 v9.1.0 labels Mar 26, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Coordination Meta label for Distributed Coordination team label Mar 26, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

Copy link
Contributor

@mhl-b mhl-b left a comment

Choose a reason for hiding this comment

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

lgtm

|| Regex.simpleMatch("GET /" + bucket + "/?uploads&max-uploads=*&prefix=*", request);
|| Regex.simpleMatch("GET /" + bucket + "/?uploads&max-uploads=*&prefix=*", request)
|| Regex.simpleMatch("GET /" + bucket + "?uploads&prefix=*", request)
|| Regex.simpleMatch("GET /" + bucket + "?uploads&max-uploads=*&prefix=*", request);
Copy link
Contributor

@mhl-b mhl-b Mar 26, 2025

Choose a reason for hiding this comment

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

A duplicate match for /?uploads&max-uploads=*&prefix=*? line 358.
Pattern.compile("GET \/bucket(\/)?\?uploads&(max-uploads=.*&)?prefix=.*")? Who needs simpleMatch when you can do complex match?:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not a duplicate, one has an extra / :)

Copy link
Contributor

@DiannaHohensee DiannaHohensee left a comment

Choose a reason for hiding this comment

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

lgtm


private boolean isUploadPartRequest(String request) {
return Regex.simpleMatch("PUT /" + path + "/*?uploadId=*&partNumber=*", request)
|| Regex.simpleMatch("PUT /" + path + "/*?partNumber=*&uploadId=*", request);
Copy link
Contributor

@DiannaHohensee DiannaHohensee Mar 26, 2025

Choose a reason for hiding this comment

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

Could you distinguish between the V1 vs V2 request formats in the methods, and add a todo someplace? I'm imagining that we should clean up and remove the V1 formats after the upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opened ES-11379. Honestly this is all hideous, we should be parsing the request properly, but it's only a test fixture...

@DaveCTurner DaveCTurner merged commit 60bd75d into elastic:main Mar 26, 2025
17 checks passed
@DaveCTurner DaveCTurner deleted the 2025/03/26/S3HttpHandler-pattern-matching branch March 26, 2025 21:41
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Mar 26, 2025
The pattern-matching in `S3HttpHandler` is overly specific and carefully
crafted to handle the exact requests that the AWS SDK v1 makes. It turns
out that the AWS SDK v2 makes requests that are slightly different. This
commit generalizes the pattern-matching to handle both SDKs.
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x

elasticsearchmachine pushed a commit that referenced this pull request Mar 26, 2025
The pattern-matching in `S3HttpHandler` is overly specific and carefully
crafted to handle the exact requests that the AWS SDK v1 makes. It turns
out that the AWS SDK v2 makes requests that are slightly different. This
commit generalizes the pattern-matching to handle both SDKs.
omricohenn pushed a commit to omricohenn/elasticsearch that referenced this pull request Mar 28, 2025
The pattern-matching in `S3HttpHandler` is overly specific and carefully
crafted to handle the exact requests that the AWS SDK v1 makes. It turns
out that the AWS SDK v2 makes requests that are slightly different. This
commit generalizes the pattern-matching to handle both SDKs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed Coordination Meta label for Distributed Coordination team >test Issues or PRs that are addressing/adding tests v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants