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

Cherry-pick #16349 to 7.10: Fix leaks with metadata processors #21740

Merged
merged 2 commits into from
Oct 13, 2020

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Oct 13, 2020

Cherry-pick of PR #16349 to 7.10 branch. Original message:

What does this PR do?

Add a closer interface for processors so their resources can be released when the processor is not needed anymore.

Explicitly close publisher pipelines so their processors are closed.

Add closers for add_docker_metadata, add_kubernetes_metadata and add_process_metadata.

Why is it important?

Processors can be defined in dynamic configurations, as in autodiscover templates. Some processors open connections, files, or start goroutines that need to be closed or stopped.

Processors can be dynamically created at least when using autodiscover and when used in the script processor. When this issue appears it can be usually solved by configuration (as described in #14389). So this case is probably not so serious.

Processors can include an on-disk cache since #20775, files open by this cache should be properly closed on shutdown.

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

Author's Checklist

Check that resources are released in:

  • Filebeat
  • Metricbeat
    • Processors at the module level are open multiple times? (One per metricset, to be reviewed as a different issue, only a real problem when a processor cannnot be instantiated twice with the same config, what only happens with add_cloudfoundry_metadata)
  • Autodiscover
  • Config reload
  • Check if there are other different pipelines that use processors in other beats (Everything using libbeat publisher pipeline should be covered, to open new issues if something that is not covered by this assumption should be covered).
  • Processors used in the script processor. Options to solve this:
    • Somehow call close on all the instantiated processors once the script is finished.
    • Avoid registering processors implementing Closer for the script processor.

Add tests:

  • Native processors with closer in script processor.
  • Processing pipelines created by supporters don't close the global processors.

Related issues

Use cases

  • Add processors in dynamic configuration and release its resources when not needed anymore.
  • Use processors that make use of files that should be closed (as cache on disk used by add_cloudfoundry_metadata).

Add a closer interface for processors so their resources can be released
when the processor is not needed anymore.
Explicitly close publisher pipelines so their processors are closed.
Add closers for add_docker_metadata, add_kubernetes_metadata and add_process_metadata.
Script processor will fail if a processor that needs to be closed is used.

(cherry picked from commit a3fe796)
@jsoriano jsoriano added [zube]: In Review backport Team:Platforms Label for the Integrations - Platforms team Team:Services (Deprecated) Label for the former Integrations-Services team labels Oct 13, 2020
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 13, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-platforms (Team:Platforms)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Oct 13, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Oct 13, 2020

💔 Tests 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: [jsoriano commented: jenkins run the tests please]

  • Start Time: 2020-10-13T13:18:26.877+0000

  • Duration: 96 min 46 sec

Test stats 🧪

Test Results
Failed 2
Passed 16220
Skipped 1357
Total 17579

Test errors 2

Expand to view the tests failures

  • Name: Build&Test / libbeat-build / TestOutputReload – pipeline

    • Age: 1
    • Duration: 67.99
    • Error Details: Failed
  • Name: Build&Test / libbeat-build / TestOutputReload/network_client – pipeline

    • Age: 1
    • Duration: 39.24
    • Error Details: Failed

Steps errors 1

Expand to view the steps failures

  • Name: mage build test
    • Description: mage build test

    • Duration: 21 min 31 sec

    • Start Time: 2020-10-13T13:47:36.019+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-10-13T14:53:11.959Z]   Version:          1.0.0-rc10
[2020-10-13T14:53:11.959Z]   GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
[2020-10-13T14:53:11.959Z]  docker-init:
[2020-10-13T14:53:11.959Z]   Version:          0.18.0
[2020-10-13T14:53:11.959Z]   GitCommit:        fec3683
[2020-10-13T14:53:20.057Z] [INFO] unstashV2: JOB_GCS_BUCKET is set. bucket param got precedency instead.
[2020-10-13T14:53:20.071Z] [INFO] unstashV2: JOB_GCS_CREDENTIALS is set. credentialsId param got precedency instead.
[2020-10-13T14:53:20.138Z] [Google Cloud Storage Plugin] Found 1 files to download from pattern: gs://beats-ci-temp/Beats/beats/PR-21740-2/source/source.tgz
[2020-10-13T14:53:20.160Z] [Google Cloud Storage Plugin] Downloading: Beats/beats/PR-21740-2/source/source.tgz to local path: /var/lib/jenkins/workspace/Beats_beats_PR-21740/source.tgz
[2020-10-13T14:53:35.082Z] + tar --version
[2020-10-13T14:53:35.388Z] + tar -xpf source.tgz
[2020-10-13T14:53:47.975Z] + rm source.tgz
[2020-10-13T14:53:48.046Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats
[2020-10-13T14:53:48.057Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/lint-1602596645794
[2020-10-13T14:53:48.094Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/libbeat-stress-tests-1602596872999
[2020-10-13T14:53:48.136Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/auditbeat-crosscompile-1602596987532
[2020-10-13T14:53:48.174Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/winlogbeat-crosscompile-1602596994451
[2020-10-13T14:53:48.218Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/journalbeat-unitTest-1602597049222
[2020-10-13T14:53:48.265Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/libbeat-crosscompile-1602597148303
[2020-10-13T14:53:48.305Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-dockerlogbeat-build-1602597150225
[2020-10-13T14:53:48.344Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-elastic-agent-build-1602597168117
[2020-10-13T14:53:48.384Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-functionbeat-build-1602597288629
[2020-10-13T14:53:48.421Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/packetbeat-build-1602597289749
[2020-10-13T14:53:48.461Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/metricbeat-unitTest-1602597396649
[2020-10-13T14:53:48.506Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/auditbeat-windows-windows-2019-1602597401197
[2020-10-13T14:53:48.545Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/heartbeat-windows-windows-2019-1602597467658
[2020-10-13T14:53:48.585Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-elastic-agent-windows-windows-2019-1602597471414
[2020-10-13T14:53:48.626Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/auditbeat-build-1602597482584
[2020-10-13T14:53:48.667Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/heartbeat-build-1602597492962
[2020-10-13T14:53:48.709Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/metricbeat-crosscompile-1602597526443
[2020-10-13T14:53:48.749Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/generator-beat-test-1602597574918
[2020-10-13T14:53:48.786Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-auditbeat-windows-windows-2019-1602597639181
[2020-10-13T14:53:48.822Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-auditbeat-build-1602597650639
[2020-10-13T14:53:48.866Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/generator-metricbeat-test-1602597662100
[2020-10-13T14:53:48.902Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-functionbeat-windows-windows-2019-1602597667744
[2020-10-13T14:53:48.942Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/filebeat-windows-windows-2019-1602597702143
[2020-10-13T14:53:48.980Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/winlogbeat-windows-windows-2019-1602597735432
[2020-10-13T14:53:49.022Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/packetbeat-windows-windows-2019-1602597735244
[2020-10-13T14:53:49.073Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-winlogbeat-build-windows-2019-1602597739327
[2020-10-13T14:53:49.141Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-filebeat-windows-windows-2019-1602597844446
[2020-10-13T14:53:49.193Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-libbeat-build-1602597844737
[2020-10-13T14:53:49.232Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/metricbeat-windows-windows-2019-1602597882555
[2020-10-13T14:53:49.279Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-metricbeat-windows-windows-2019-1602597951536
[2020-10-13T14:53:49.320Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/libbeat-build-1602598095124
[2020-10-13T14:53:49.371Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/filebeat-build-1602598232765
[2020-10-13T14:53:49.417Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/metricbeat-pythonIntegTest-1602598907393
[2020-10-13T14:53:49.456Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/metricbeat-goIntegTest-1602598915662
[2020-10-13T14:53:49.514Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-filebeat-build-1602599308459
[2020-10-13T14:53:49.559Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-metricbeat-build-1602600510069
[2020-10-13T14:53:49.926Z] + cat
[2020-10-13T14:53:49.926Z] + /usr/local/bin/runbld ./runbld-test-reports --job-name elastic+beats+pull-request
[2020-10-13T14:53:49.926Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-10-13T14:53:56.690Z] runbld>>> runbld started
[2020-10-13T14:53:56.690Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-10-13T14:53:58.089Z] runbld>>> The following profiles matched the job 'elastic+beats+pull-request' in order of occurrence in the config (last value wins).
[2020-10-13T14:53:58.352Z] runbld>>> Matches in the system config:
[2020-10-13T14:53:58.352Z] runbld>>> - Matched ^elastic\+beats
[2020-10-13T14:53:58.352Z] runbld>>> - Matched ^elastic\+beats\+pull-request
[2020-10-13T14:53:59.744Z] runbld>>> Debug logging enabled.
[2020-10-13T14:53:59.744Z] runbld>>> Storing result
[2020-10-13T14:53:59.744Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-10-13T14:53:59.744Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20201013145359-F62743ED
[2020-10-13T14:53:59.744Z] runbld>>> Adding system facts.
[2020-10-13T14:54:00.698Z] runbld>>> Adding vcs info for the latest commit:  ba1060f5f10816a462cf6413370d40d473b9495a
[2020-10-13T14:54:00.698Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-10-13T14:54:00.960Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-10-13T14:54:00.960Z] Processing JUnit reports with runbld...
[2020-10-13T14:54:00.960Z] + echo 'Processing JUnit reports with runbld...'
[2020-10-13T14:54:01.223Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-10-13T14:54:01.223Z] runbld>>> DURATION: 36ms
[2020-10-13T14:54:01.223Z] runbld>>> STDOUT: 40 bytes
[2020-10-13T14:54:01.223Z] runbld>>> STDERR: 49 bytes
[2020-10-13T14:54:01.223Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-10-13T14:54:01.223Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-21740
[2020-10-13T14:54:02.617Z] runbld>>> Storing build metadata: 
[2020-10-13T14:54:02.618Z] runbld>>> Adding test report.
[2020-10-13T14:54:02.618Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats
[2020-10-13T14:54:03.194Z] runbld>>> Found 122 test output files
[2020-10-13T14:54:05.131Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-metricbeat-build-1602600510069/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-10-13T14:54:05.131Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-metricbeat-build-1602600510069/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-10-13T14:54:05.131Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-metricbeat-build-1602600510069/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-10-13T14:54:05.131Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-metricbeat-build-1602600510069/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-10-13T14:54:05.131Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/x-pack-metricbeat-build-1602600510069/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-10-13T14:54:05.394Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/metricbeat-goIntegTest-1602598915662/metricbeat/build/TEST-go-integration-graphite.xml
[2020-10-13T14:54:05.394Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21740/src/github.com/elastic/beats/metricbeat-goIntegTest-1602598915662/metricbeat/build/TEST-go-integration-windows.xml
[2020-10-13T14:54:05.970Z] runbld>>> Test output logs contained: Errors: 0 Failures: 2 Tests: 17579 Skipped: 1083
[2020-10-13T14:54:06.239Z] runbld>>> Storing result
[2020-10-13T14:54:06.239Z] runbld>>> FAILURES: 2
[2020-10-13T14:54:06.816Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-10-13T14:54:06.816Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20201013145359-F62743ED
[2020-10-13T14:54:07.079Z] runbld>>> Email notification disabled by environment variable.
[2020-10-13T14:54:07.079Z] runbld>>> Slack notification disabled by environment variable.
[2020-10-13T14:54:12.659Z] Running on worker-1244230 in /var/lib/jenkins/workspace/Beats_beats_PR-21740
[2020-10-13T14:54:12.696Z] [INFO] getVaultSecret: Getting secrets
[2020-10-13T14:54:12.750Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-10-13T14:54:14.633Z] + chmod 755 generate-build-data.sh
[2020-10-13T14:54:14.633Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21740/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21740/runs/2 FAILURE 5746354
[2020-10-13T14:54:14.633Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21740/runs/2/steps/?limit=10000 -o steps-info.json
[2020-10-13T14:54:18.749Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21740/runs/2/tests/?status=FAILED -o tests-errors.json
[2020-10-13T14:54:20.204Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21740/runs/2/log/ -o pipeline-log.txt

@jsoriano
Copy link
Member Author

jenkins run the tests please

@jsoriano jsoriano self-assigned this Oct 13, 2020
@jsoriano jsoriano merged commit 452c50f into elastic:7.10 Oct 13, 2020
@jsoriano jsoriano deleted the backport_16349_7.10 branch October 13, 2020 16:55
@zube zube bot removed the [zube]: Done label Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Platforms Label for the Integrations - Platforms team Team:Services (Deprecated) Label for the former Integrations-Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants