Skip to content

fix: AWS S3 improve unexpected EOF detection#44813

Merged
Kavindu-Dodan merged 4 commits intoelastic:mainfrom
Kavindu-Dodan:fix/aws-s3-io-copy-usage
Jun 16, 2025
Merged

fix: AWS S3 improve unexpected EOF detection#44813
Kavindu-Dodan merged 4 commits intoelastic:mainfrom
Kavindu-Dodan:fix/aws-s3-io-copy-usage

Conversation

@Kavindu-Dodan
Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan commented Jun 13, 2025

Proposed commit message

This PR revisits the implementation introduced in #42420 and improves the detection of io.ErrUnexpectedEOF.

The io.ErrUnexpectedEOF error can occur while streaming the S3 object body. The previous approach relied on reading the entire body into memory using io.Copy which unfortunately led to increased memory usage in Beats deployments.

This change introduces a wrapper around io.Reader to catch and handle io.ErrUnexpectedEOF. This allows us to handle stream errors (retriable) and content parsing errors (non-retriable) separately.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

Fixes #44735

@Kavindu-Dodan Kavindu-Dodan requested a review from a team as a code owner June 13, 2025 17:12
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 13, 2025
@github-actions
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@Kavindu-Dodan Kavindu-Dodan changed the title improve unexpected EOF detection Jun 13, 2025
@Kavindu-Dodan Kavindu-Dodan added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label Jun 13, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 13, 2025
@elastic elastic deleted a comment from botelastic bot Jun 13, 2025
@Kavindu-Dodan Kavindu-Dodan added the backport-active-all Automated backport with mergify to all the active branches label Jun 13, 2025
@Kavindu-Dodan Kavindu-Dodan changed the title fix: improve unexpected EOF detection Jun 13, 2025
@Kavindu-Dodan Kavindu-Dodan force-pushed the fix/aws-s3-io-copy-usage branch 3 times, most recently from effda78 to 0c78399 Compare June 13, 2025 18:22
Copy link
Contributor

@gizas gizas left a comment

Choose a reason for hiding this comment

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

LGTM, you mainly removed the io.copy Thanks for that

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
@Kavindu-Dodan Kavindu-Dodan force-pushed the fix/aws-s3-io-copy-usage branch from 0c78399 to 7f07023 Compare June 16, 2025 13:39
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
@elastic elastic deleted a comment from mergify bot Jun 16, 2025
@MichaelKatsoulis MichaelKatsoulis self-requested a review June 16, 2025 14:31
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng left a comment

Choose a reason for hiding this comment

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

LGTM!

@Kavindu-Dodan
Copy link
Contributor Author

Merging by EOD 16.05.20205

@Kavindu-Dodan Kavindu-Dodan merged commit a75b4e7 into elastic:main Jun 16, 2025
34 checks passed
@github-actions
Copy link
Contributor

@Mergifyio backport 8.17 8.18 8.19 9.0

@mergify
Copy link
Contributor

mergify bot commented Jun 16, 2025

backport 8.17 8.18 8.19 9.0

✅ Backports have been created

Details
mergify bot pushed a commit that referenced this pull request Jun 16, 2025
* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)
mergify bot pushed a commit that referenced this pull request Jun 16, 2025
* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)
mergify bot pushed a commit that referenced this pull request Jun 16, 2025
* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)
mergify bot pushed a commit that referenced this pull request Jun 16, 2025
* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)
Kavindu-Dodan added a commit that referenced this pull request Jun 16, 2025
* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)
Kavindu-Dodan added a commit that referenced this pull request Jun 16, 2025
…44847)

* fix: AWS S3 improve unexpected EOF detection (#44813)

* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)

* Update CHANGELOG.next.asciidoc

* fix import

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Co-authored-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Kavindu-Dodan added a commit that referenced this pull request Jun 16, 2025
…44848)

* fix: AWS S3 improve unexpected EOF detection (#44813)

* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)

* Update CHANGELOG.next.asciidoc

* fix import

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Co-authored-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Kavindu-Dodan added a commit that referenced this pull request Jun 16, 2025
…44850)

* fix: AWS S3 improve unexpected EOF detection (#44813)

* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)

* Update CHANGELOG.next.asciidoc

* fix import

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Co-authored-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Kavindu-Dodan added a commit that referenced this pull request Jun 17, 2025
…44849)

* fix: AWS S3 improve unexpected EOF detection (#44813)

* improve unexpected EOF detection

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* add changelog entry

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* fix lint issues

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: receiver name

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit a75b4e7)

* Update CHANGELOG.next.asciidoc

* fix import

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Co-authored-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
@khushijain21 khushijain21 mentioned this pull request Jun 17, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches Team:obs-ds-hosted-services Label for the Observability Hosted Services team

4 participants