Skip to content

Conversation

@DaveCTurner
Copy link
Contributor

ListObjects and ListObjectsV2 only really differ in their approach
to pagination, but today S3HttpHandler does not simulate pagination
anyway so we can use the same handling code for both APIs. The only
practical difference is that the v2 SDK requires the <IsTruncated>
element in a ListObjectsV2 response, but this element is permitted in
both APIs so we add it here.

`ListObjects` and `ListObjectsV2` only really differ in their approach
to pagination, but today `S3HttpHandler` does not simulate pagination
anyway so we can use the same handling code for both APIs. The only
practical difference is that the v2 SDK requires the `<IsTruncated>`
element in a `ListObjectsV2` response, but this element is permitted in
both APIs so we add it here.
@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v8.19.0 v9.1.0 labels Apr 3, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Coordination Meta label for Distributed Coordination team label Apr 3, 2025
@elasticsearchmachine
Copy link
Collaborator

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

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.

Clarification nits, otherwise LGTM

} else if (request.isListObjectsRequest()) {
if (request.queryParameters().containsKey("list-type")) {
throw new AssertionError("Test must be adapted for GET Bucket (List Objects) Version 2");
final var listType = request.queryParameters().getOrDefault("list-type", List.of("1")).get(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify with a comment that V2 requests newly have this extra version (?) field, so we're adding the check in case the version unexpectedly changes in future? That's my understanding, anyway, from looking around on the internet.

Copy link
Member

Choose a reason for hiding this comment

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

I think we can replace it something like

final var listType = request.getOptionalQueryParam("list-type");
assert listType.isEmpty() || "2".equals(listType.get());

Seems more explicit with the intention and also ensures the parameter has a single value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All fair points. Previously I was doing something with the listType value so it was useful to distinguish "1" from "2", but we don't need this right now so we can just drop this check entirely -> 5974795

list.append("<Delimiter>").append(delimiter).append("</Delimiter>");
}
// Would be good to test pagination here (the only real difference between ListObjects and ListObjectsV2) but for now
// we return all the results at once.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this explanation be partly phrased as a TODO?

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 hold no hope that we'll actually do it so I'm going to just leave it as a comment.

} else if (request.isListObjectsRequest()) {
if (request.queryParameters().containsKey("list-type")) {
throw new AssertionError("Test must be adapted for GET Bucket (List Objects) Version 2");
final var listType = request.queryParameters().getOrDefault("list-type", List.of("1")).get(0);
Copy link
Contributor

@DiannaHohensee DiannaHohensee Apr 3, 2025

Choose a reason for hiding this comment

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

Also, injecting "1" is a little misleading: it made me look around for what "1" could represent and it appears to be meaningless (since V1 doesn't have the field)?

Might it be better to add a not-null check to the middle of the if-statement (to avoid the mystery default number confusion)?

Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

LGTM

} else if (request.isListObjectsRequest()) {
if (request.queryParameters().containsKey("list-type")) {
throw new AssertionError("Test must be adapted for GET Bucket (List Objects) Version 2");
final var listType = request.queryParameters().getOrDefault("list-type", List.of("1")).get(0);
Copy link
Member

Choose a reason for hiding this comment

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

I think we can replace it something like

final var listType = request.getOptionalQueryParam("list-type");
assert listType.isEmpty() || "2".equals(listType.get());

Seems more explicit with the intention and also ensures the parameter has a single value?

@DaveCTurner DaveCTurner added auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) auto-backport Automatically create backport pull requests when merged labels Apr 4, 2025
@elasticsearchmachine elasticsearchmachine merged commit 24fa8ea into elastic:main Apr 4, 2025
17 checks passed
@DaveCTurner DaveCTurner deleted the 2025/04/03/S3HttpHandler-ListObjectsV2 branch April 4, 2025 07:40
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Apr 4, 2025
`ListObjects` and `ListObjectsV2` only really differ in their approach
to pagination, but today `S3HttpHandler` does not simulate pagination
anyway so we can use the same handling code for both APIs. The only
practical difference is that the v2 SDK requires the `<IsTruncated>`
element in a `ListObjectsV2` response, but this element is permitted in
both APIs so we add it here.
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x

elasticsearchmachine pushed a commit that referenced this pull request Apr 4, 2025
`ListObjects` and `ListObjectsV2` only really differ in their approach
to pagination, but today `S3HttpHandler` does not simulate pagination
anyway so we can use the same handling code for both APIs. The only
practical difference is that the v2 SDK requires the `<IsTruncated>`
element in a `ListObjectsV2` response, but this element is permitted in
both APIs so we add it here.
andreidan pushed a commit to andreidan/elasticsearch that referenced this pull request Apr 9, 2025
`ListObjects` and `ListObjectsV2` only really differ in their approach
to pagination, but today `S3HttpHandler` does not simulate pagination
anyway so we can use the same handling code for both APIs. The only
practical difference is that the v2 SDK requires the `<IsTruncated>`
element in a `ListObjectsV2` response, but this element is permitted in
both APIs so we add it here.
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 auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :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