Skip to content

Conversation

@mhl-b
Copy link
Contributor

@mhl-b mhl-b commented Dec 6, 2025

This PR addresses various inconsistencies in GCS fixture for batch-delete. Source https://docs.cloud.google.com/storage/docs/batch#http.

It is a prerequisite for #138951 to handle retryable errors per batch item. And eventually fix #138364.

This PR addresses following issues:

  • Blindly copy irrelevant headers or their values from multipart request parts to response parts. Such headers are: Content-Length, Content-Type, Content-Transfer-Encoding. These are not required for batch delete responses.
  • Content-ID header does not align in responses. Responses should have a response- prefix with a Content-ID header value from request. For example request: Content-ID: 1, response: Content-ID: response-1.
  • Extra empty lines at the end of response parts

Future work will address remaining issues:

  • Deletes always return 204 No Content even if item is not found. In that case it should be 404 Not Found.
  • Fixture does not fail individual batch items, only whole batch. We should introduce retryable errors within batch.

Major change is taking out Multipart.Reader from MultipartUpload and reuse it for batch request. Also add Multipart.Writer for writing batch responses.

@mhl-b mhl-b added >test Issues or PRs that are addressing/adding tests :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed Coordination Meta label for Distributed Coordination team labels Dec 6, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Comment on lines 107 to +115
new TestHttpResponse(RestStatus.OK, """
--$boundary
Content-Length: 168
Content-Type: application/http
content-id: 1
content-transfer-encoding: binary
content-type: application/http
content-id: response-1
HTTP/1.1 204 NO_CONTENT
HTTP/1.1 204 No Content
--$boundary--
""".replace("\n", "\r\n").replace("$boundary", boundary)),
--$boundary--""".replace("\n", "\r\n").replace("$boundary", boundary)),
Copy link
Contributor Author

@mhl-b mhl-b Dec 6, 2025

Choose a reason for hiding this comment

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

Here is a complete example of inconsistencies.

  • Content-Length is redundant and wrong, it's 23 bytes + double CRLF.
  • content-transfer-encoding: binary is not true.
  • content-id: 1 does not have prefix response-.
  • There should be only 2(or even 1) empty lines after HTTP/1.1 204 No Content

example here https://docs.cloud.google.com/storage/docs/batch#batch-example-response

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM

var _bucket = matcher.group("bucket");
if (bucket.equals(_bucket) == false) {
throw new IllegalStateException("Bucket does not match expected: " + bucket + ", got: " + _bucket);
}
Copy link
Contributor

@nicktindall nicktindall Dec 7, 2025

Choose a reason for hiding this comment

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

I wonder if we should maybeDieOnAnotherThread if we see what we consider to be a malformed request here. If we just throw an exception here it might retry around the issue somehow and we don't know we've got some issue with our stub.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I will add it to the following PR.

Copy link
Contributor

@nicktindall nicktindall left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@joshua-adams-1 joshua-adams-1 left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

: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 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] GCSRepositoryAnalysisRestIT testRepositoryAnalysis failing

5 participants