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

Fix S3HttpHandler chunked-encoding handling #72378

Conversation

DaveCTurner
Copy link
Contributor

@DaveCTurner DaveCTurner commented Apr 28, 2021

The S3HttpHandler reads the contents of the uploaded blob, but if the
upload used chunked encoding then the reader would skip one or more
\r\n sequences if they appeared at the start of a chunk.

This commit reworks the reader to be stricter about its interpretation
of chunks, and removes some indirection via streams since we can work
pretty much entirely on the underlying BytesReference instead.

Closes #72358

@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v8.0.0 v7.12.2 v7.14.0 v7.13.1 labels Apr 28, 2021
@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Apr 28, 2021
@elasticmachine
Copy link
Collaborator

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

The `S3HttpHandler` reads the contents of the uploaded blob, but if the
upload used chunked encoding then the reader would skip one or more
`\r\n` sequences if they appeared at the start of a chunk.

This commit reworks the reader to be stricter about its interpretation
of chunks, and removes some indirection via streams since we can work
pretty much entirely on the underlying `BytesReference` instead.

Closes elastic#72358
@DaveCTurner DaveCTurner force-pushed the 2021-04-28-fix-s3-fixture-chunk-handling branch from 16d96ca to 845e03e Compare April 28, 2021 11:57
Copy link
Member

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

I think #72365 is the simpler option, but this one LGTM as well.
If we want to go with this one, can we add https://github.com/elastic/elasticsearch/pull/72365/files#diff-47fd5429e7187cd1b173e53b38a5896c3810c6b89890b84e89334536288c6b84R124 to it to get more (and easier to debug) coverage on this though? :)

@DaveCTurner
Copy link
Contributor Author

Ok I shamelessly pinched some of your ideas from #72365.

Copy link
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing this David

@DaveCTurner DaveCTurner merged commit f72fa49 into elastic:master Apr 28, 2021
@DaveCTurner DaveCTurner deleted the 2021-04-28-fix-s3-fixture-chunk-handling branch April 28, 2021 14:13
DaveCTurner added a commit that referenced this pull request Apr 28, 2021
The `S3HttpHandler` reads the contents of the uploaded blob, but if the
upload used chunked encoding then the reader would skip one or more
`\r\n` sequences if they appeared at the start of a chunk.

This commit reworks the reader to be stricter about its interpretation
of chunks, and removes some indirection via streams since we can work
pretty much entirely on the underlying `BytesReference` instead.

Closes #72358
DaveCTurner added a commit that referenced this pull request Apr 28, 2021
The `S3HttpHandler` reads the contents of the uploaded blob, but if the
upload used chunked encoding then the reader would skip one or more
`\r\n` sequences if they appeared at the start of a chunk.

This commit reworks the reader to be stricter about its interpretation
of chunks, and removes some indirection via streams since we can work
pretty much entirely on the underlying `BytesReference` instead.

Closes #72358
@DaveCTurner
Copy link
Contributor Author

Thanks both 🚀

DaveCTurner added a commit that referenced this pull request Apr 28, 2021
The `S3HttpHandler` reads the contents of the uploaded blob, but if the
upload used chunked encoding then the reader would skip one or more
`\r\n` sequences if they appeared at the start of a chunk.

This commit reworks the reader to be stricter about its interpretation
of chunks, and removes some indirection via streams since we can work
pretty much entirely on the underlying `BytesReference` instead.

Closes #72358
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 (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. >test Issues or PRs that are addressing/adding tests v7.12.2 v7.13.0 v7.14.0 v8.0.0-alpha1
Projects
None yet
6 participants