Skip to content

Handle data returned with io.EOF in LineReader#26260

Merged
andrewkroh merged 1 commit intoelastic:masterfrom
andrewkroh:bugfix/fb/aws-s3-gzip-line-reader-eof
Jun 14, 2021
Merged

Handle data returned with io.EOF in LineReader#26260
andrewkroh merged 1 commit intoelastic:masterfrom
andrewkroh:bugfix/fb/aws-s3-gzip-line-reader-eof

Conversation

@andrewkroh
Copy link
Copy Markdown
Member

What does this PR do?

The libbeat LineReader implementation did not handle the case where the underlying io.Reader
it was reading from returns bytes and io.EOF. It was discarding the data in this case.

As per the io.Reader contract:

a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil.

This occurs often with the gzip.Reader. It returns a large chunk of data at the end of the file and io.EOF at the same time.

Why is it important?

This bug can result in data loss in Filebeat.

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.

@andrewkroh andrewkroh added bug review Filebeat Filebeat libbeat Team:Security-External Integrations Team:Elastic-Agent Label for the Agent team backport-v7.13.0 Automated backport with mergify backport-v7.14.0 Automated backport with mergify labels Jun 11, 2021
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/agent (Team:Agent)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jun 11, 2021
@andrewkroh andrewkroh force-pushed the bugfix/fb/aws-s3-gzip-line-reader-eof branch from 556a489 to 4abf9f7 Compare June 11, 2021 13:59
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Jun 11, 2021

💔 Build Failed

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: andrewkroh commented: run tests

  • Start Time: 2021-06-14T14:27:52.549+0000

  • Duration: 56 min 54 sec

  • Commit: dca5564

Test stats 🧪

Test Results
Failed 0
Passed 327
Skipped 9
Total 336

Trends 🧪

Image of Build Times

Image of Tests

Steps errors 2

Expand to view the steps failures

x-pack/elastic-agent-packaging-arm-arm - mage package
  • Took 10 min 5 sec . View more details on here
  • Description: mage package
Error signal
  • Took 0 min 0 sec . View more details on here
  • Description: Error 'hudson.AbortException: script returned exit code 1'

Log output

Expand to view the last 100 lines of log output

[2021-06-14T15:22:29.782Z]  API version:       1.41
[2021-06-14T15:22:29.782Z]  Go version:        go1.13.15
[2021-06-14T15:22:29.782Z]  Git commit:        48d30b5
[2021-06-14T15:22:29.782Z]  Built:             Fri Jan 29 14:33:13 2021
[2021-06-14T15:22:29.782Z]  OS/Arch:           linux/amd64
[2021-06-14T15:22:29.782Z]  Context:           default
[2021-06-14T15:22:29.782Z]  Experimental:      true
[2021-06-14T15:22:29.782Z] 
[2021-06-14T15:22:29.782Z] Server: Docker Engine - Community
[2021-06-14T15:22:29.782Z]  Engine:
[2021-06-14T15:22:29.782Z]   Version:          20.10.3
[2021-06-14T15:22:29.782Z]   API version:      1.41 (minimum version 1.12)
[2021-06-14T15:22:29.782Z]   Go version:       go1.13.15
[2021-06-14T15:22:29.782Z]   Git commit:       46229ca
[2021-06-14T15:22:29.782Z]   Built:            Fri Jan 29 14:31:25 2021
[2021-06-14T15:22:29.782Z]   OS/Arch:          linux/amd64
[2021-06-14T15:22:29.782Z]   Experimental:     false
[2021-06-14T15:22:29.782Z]  containerd:
[2021-06-14T15:22:29.782Z]   Version:          1.4.3
[2021-06-14T15:22:29.782Z]   GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
[2021-06-14T15:22:29.782Z]  runc:
[2021-06-14T15:22:29.782Z]   Version:          1.0.0-rc92
[2021-06-14T15:22:29.782Z]   GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
[2021-06-14T15:22:29.782Z]  docker-init:
[2021-06-14T15:22:29.782Z]   Version:          0.19.0
[2021-06-14T15:22:29.782Z]   GitCommit:        de40ad0
[2021-06-14T15:22:29.782Z] Change ownership of all files inside the specific folder from root/root to current user/group
[2021-06-14T15:22:29.782Z] Unable to find image 'alpine:3.4' locally
[2021-06-14T15:22:30.354Z] 3.4: Pulling from library/alpine
[2021-06-14T15:22:30.617Z] c1e54eec4b57: Pulling fs layer
[2021-06-14T15:22:30.879Z] c1e54eec4b57: Download complete
[2021-06-14T15:22:31.141Z] c1e54eec4b57: Pull complete
[2021-06-14T15:22:31.141Z] Digest: sha256:b733d4a32c4da6a00a84df2ca32791bb03df95400243648d8c539e7b4cce329c
[2021-06-14T15:22:31.141Z] Status: Downloaded newer image for alpine:3.4
[2021-06-14T15:22:33.062Z] Change permissions with write access of all files inside the specific folder
[2021-06-14T15:22:33.661Z] Running in /var/lib/jenkins/workspace/PR-26260-4-a7216075-15df-4f21-8874-4595b0cf5464/src/github.com/elastic/beats/build
[2021-06-14T15:22:33.964Z] + rm -rf ve
[2021-06-14T15:22:33.964Z] + find . -type d -name vendor -exec rm -r {} ;
[2021-06-14T15:22:34.285Z] + python .ci/scripts/pre_archive_test.py
[2021-06-14T15:22:44.372Z] Copy ./x-pack/elastic-agent/build into build/x-pack/elastic-agent/build
[2021-06-14T15:22:44.372Z] Copy ./x-pack/elastic-agent/build/golang-crossbuild into build/x-pack/elastic-agent/build/golang-crossbuild
[2021-06-14T15:22:44.372Z] Copy ./x-pack/elastic-agent/build/package/elastic-agent/elastic-agent-linux-amd64.docker/docker-build into build/x-pack/elastic-agent/build/package/elastic-agent/elastic-agent-linux-amd64.docker/docker-build
[2021-06-14T15:22:44.372Z] Copy ./x-pack/elastic-agent/build/package/elastic-agent-ubi8/elastic-agent-linux-amd64.docker/docker-build into build/x-pack/elastic-agent/build/package/elastic-agent-ubi8/elastic-agent-linux-amd64.docker/docker-build
[2021-06-14T15:22:44.372Z] Copy ./x-pack/filebeat/build into build/x-pack/filebeat/build
[2021-06-14T15:22:44.372Z] Copy ./x-pack/filebeat/build/golang-crossbuild into build/x-pack/filebeat/build/golang-crossbuild
[2021-06-14T15:22:44.372Z] Copy ./x-pack/metricbeat/build into build/x-pack/metricbeat/build
[2021-06-14T15:22:44.372Z] Copy ./x-pack/metricbeat/build/golang-crossbuild into build/x-pack/metricbeat/build/golang-crossbuild
[2021-06-14T15:22:44.372Z] Copy ./x-pack/heartbeat/build into build/x-pack/heartbeat/build
[2021-06-14T15:22:44.372Z] Copy ./x-pack/heartbeat/build/golang-crossbuild into build/x-pack/heartbeat/build/golang-crossbuild
[2021-06-14T15:22:44.395Z] Running in /var/lib/jenkins/workspace/PR-26260-4-a7216075-15df-4f21-8874-4595b0cf5464/src/github.com/elastic/beats/build
[2021-06-14T15:22:44.417Z] Recording test results
[2021-06-14T15:22:44.952Z] None of the test reports contained any result
[2021-06-14T15:22:44.961Z] [Checks API] No suitable checks publisher found.
[2021-06-14T15:22:45.344Z] + go clean -modcache
[2021-06-14T15:22:48.313Z] Cleaning up /var/lib/jenkins/workspace/PR-26260-4-a7216075-15df-4f21-8874-4595b0cf5464
[2021-06-14T15:22:48.313Z] Client: Docker Engine - Community
[2021-06-14T15:22:48.313Z]  Version:           20.10.3
[2021-06-14T15:22:48.313Z]  API version:       1.41
[2021-06-14T15:22:48.313Z]  Go version:        go1.13.15
[2021-06-14T15:22:48.313Z]  Git commit:        48d30b5
[2021-06-14T15:22:48.313Z]  Built:             Fri Jan 29 14:33:13 2021
[2021-06-14T15:22:48.313Z]  OS/Arch:           linux/amd64
[2021-06-14T15:22:48.313Z]  Context:           default
[2021-06-14T15:22:48.313Z]  Experimental:      true
[2021-06-14T15:22:48.313Z] 
[2021-06-14T15:22:48.313Z] Server: Docker Engine - Community
[2021-06-14T15:22:48.313Z]  Engine:
[2021-06-14T15:22:48.313Z]   Version:          20.10.3
[2021-06-14T15:22:48.313Z]   API version:      1.41 (minimum version 1.12)
[2021-06-14T15:22:48.313Z]   Go version:       go1.13.15
[2021-06-14T15:22:48.313Z]   Git commit:       46229ca
[2021-06-14T15:22:48.313Z]   Built:            Fri Jan 29 14:31:25 2021
[2021-06-14T15:22:48.313Z]   OS/Arch:          linux/amd64
[2021-06-14T15:22:48.313Z]   Experimental:     false
[2021-06-14T15:22:48.313Z]  containerd:
[2021-06-14T15:22:48.313Z]   Version:          1.4.3
[2021-06-14T15:22:48.313Z]   GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
[2021-06-14T15:22:48.313Z]  runc:
[2021-06-14T15:22:48.313Z]   Version:          1.0.0-rc92
[2021-06-14T15:22:48.313Z]   GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
[2021-06-14T15:22:48.313Z]  docker-init:
[2021-06-14T15:22:48.313Z]   Version:          0.19.0
[2021-06-14T15:22:48.313Z]   GitCommit:        de40ad0
[2021-06-14T15:22:48.313Z] Change ownership of all files inside the specific folder from root/root to current user/group
[2021-06-14T15:23:35.803Z] Change permissions with write access of all files inside the specific folder
[2021-06-14T15:23:35.859Z] Running in /var/lib/jenkins/workspace/PR-26260-4-a7216075-15df-4f21-8874-4595b0cf5464
[2021-06-14T15:23:40.290Z] + gsutil --version
[2021-06-14T15:23:42.024Z] Masking supported pattern matches of $FILE_CREDENTIAL
[2021-06-14T15:23:42.419Z] + gcloud auth activate-service-account --key-file ****
[2021-06-14T15:23:43.008Z] Activated service account credentials for: [beats-ci-gcs-plugin@elastic-ci-prod.iam.gserviceaccount.com]
[2021-06-14T15:23:43.344Z] + gsutil -m -q cp -a public-read eC1wYWNrL2VsYXN0aWMtYWdlbnQtcGFja2FnaW5nLWxpbnV4ZGNhNTU2NDY1ZWNlMjVlOTg3MDdhN2NjNmJhY2I3NWFiZDk5NTQwMQ gs://beats-ci-temp/ci/cache/
[2021-06-14T15:23:45.571Z] Stage "Packaging-Pipeline" skipped due to earlier failure(s)
[2021-06-14T15:23:45.652Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-26260/src/github.com/elastic/beats
[2021-06-14T15:23:46.082Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-26260
[2021-06-14T15:23:46.123Z] [INFO] getVaultSecret: Getting secrets
[2021-06-14T15:23:46.162Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2021-06-14T15:23:46.915Z] + chmod 755 generate-build-data.sh
[2021-06-14T15:23:46.915Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-26260/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-26260/runs/4 FAILURE 3354104
[2021-06-14T15:23:46.915Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-26260/runs/4/steps/?limit=10000 -o steps-info.json
[2021-06-14T15:23:52.235Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-26260/runs/4/tests/?status=FAILED -o tests-errors.json

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 327
Skipped 9
Total 336

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jun 14, 2021

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b bugfix/fb/aws-s3-gzip-line-reader-eof upstream/bugfix/fb/aws-s3-gzip-line-reader-eof
git merge upstream/master
git push upstream bugfix/fb/aws-s3-gzip-line-reader-eof

The libbeat LineReader implementation did not handle the case where the underlying io.Reader
it was reading from returns bytes and io.EOF. It was discarding the data in this case.

As per the io.Reader contract:

    a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil.

This occurs often with the gzip.Reader. It returns a large chunk of data at the end of the file and io.EOF at the same time.
@andrewkroh andrewkroh force-pushed the bugfix/fb/aws-s3-gzip-line-reader-eof branch from 4abf9f7 to dca5564 Compare June 14, 2021 12:28
@andrewkroh
Copy link
Copy Markdown
Member Author

run tests

@andrewkroh andrewkroh merged commit 6896e77 into elastic:master Jun 14, 2021
mergify bot pushed a commit that referenced this pull request Jun 14, 2021
The libbeat LineReader implementation did not handle the case where the underlying io.Reader
it was reading from returns bytes and io.EOF. It was discarding the data in this case.

As per the io.Reader contract:

    a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil.

This occurs often with the gzip.Reader. It returns a large chunk of data at the end of the file and io.EOF at the same time.

(cherry picked from commit 6896e77)
mergify bot pushed a commit that referenced this pull request Jun 14, 2021
The libbeat LineReader implementation did not handle the case where the underlying io.Reader
it was reading from returns bytes and io.EOF. It was discarding the data in this case.

As per the io.Reader contract:

    a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil.

This occurs often with the gzip.Reader. It returns a large chunk of data at the end of the file and io.EOF at the same time.

(cherry picked from commit 6896e77)
andrewkroh added a commit that referenced this pull request Jun 14, 2021
The libbeat LineReader implementation did not handle the case where the underlying io.Reader
it was reading from returns bytes and io.EOF. It was discarding the data in this case.

As per the io.Reader contract:

    a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil.

This occurs often with the gzip.Reader. It returns a large chunk of data at the end of the file and io.EOF at the same time.

(cherry picked from commit 6896e77)

Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
andrewkroh added a commit that referenced this pull request Jun 15, 2021
#26300)

* Handle data returned with io.EOF in LineReader (#26260)

The libbeat LineReader implementation did not handle the case where the underlying io.Reader
it was reading from returns bytes and io.EOF. It was discarding the data in this case.

As per the io.Reader contract:

    a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil.

This occurs often with the gzip.Reader. It returns a large chunk of data at the end of the file and io.EOF at the same time.

(cherry picked from commit 6896e77)

* Update CHANGELOG.next.asciidoc

Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
michalpristas pushed a commit to michalpristas/beats that referenced this pull request Jun 17, 2021
The libbeat LineReader implementation did not handle the case where the underlying io.Reader
it was reading from returns bytes and io.EOF. It was discarding the data in this case.

As per the io.Reader contract:

    a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil.

This occurs often with the gzip.Reader. It returns a large chunk of data at the end of the file and io.EOF at the same time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v7.13.0 Automated backport with mergify backport-v7.14.0 Automated backport with mergify bug Filebeat Filebeat libbeat review Team:Elastic-Agent Label for the Agent team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants