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.x: Fix leaks with metadata processors #21739

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.x 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
@elasticmachine
Copy link
Collaborator

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

@elasticmachine
Copy link
Collaborator

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

@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 Oct 13, 2020
@elasticmachine
Copy link
Collaborator

💔 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: [Pull request #21739 opened]

  • Start Time: 2020-10-13T11:10:19.755+0000

  • Duration: 101 min 57 sec

Test stats 🧪

Test Results
Failed 4
Passed 15487
Skipped 1119
Total 16610

Test errors 4

Expand to view the tests failures

  • Name: Build&Test / x-pack/filebeat-build / TestConfigOauth2Validation – httpjson

    • Age: 1
    • Duration: 0.05
    • Error Details: Failed
  • Name: Build&Test / x-pack/filebeat-build / TestConfigOauth2Validation/date_cursor.date_format_will_fail_if_invalid – httpjson

    • Age: 1
    • Duration: 0
    • Error Details: Failed
  • Name: Build&Test / x-pack/filebeat-windows-windows-2019 / TestConfigOauth2Validation – httpjson

    • Age: 1
    • Duration: 0.05
    • Error Details: Failed
  • Name: Build&Test / x-pack/filebeat-windows-windows-2019 / TestConfigOauth2Validation/date_cursor.date_format_will_fail_if_invalid – httpjson

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

Steps errors 2

Expand to view the steps failures

  • Name: mage build test

    • Description: mage build test

    • Duration: 5 min 47 sec

    • Start Time: 2020-10-13T11:38:41.177+0000

    • log

  • Name: mage build unitTest

    • Description: mage build unitTest

    • Duration: 9 min 38 sec

    • Start Time: 2020-10-13T11:42:37.438+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-10-13T12:50:12.122Z]   Version:          1.0.0-rc10
[2020-10-13T12:50:12.123Z]   GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
[2020-10-13T12:50:12.123Z]  docker-init:
[2020-10-13T12:50:12.123Z]   Version:          0.18.0
[2020-10-13T12:50:12.123Z]   GitCommit:        fec3683
[2020-10-13T12:50:21.178Z] [INFO] unstashV2: JOB_GCS_BUCKET is set. bucket param got precedency instead.
[2020-10-13T12:50:21.206Z] [INFO] unstashV2: JOB_GCS_CREDENTIALS is set. credentialsId param got precedency instead.
[2020-10-13T12:50:21.294Z] [Google Cloud Storage Plugin] Found 1 files to download from pattern: gs://beats-ci-temp/Beats/beats/PR-21739-1/source/source.tgz
[2020-10-13T12:50:21.314Z] [Google Cloud Storage Plugin] Downloading: Beats/beats/PR-21739-1/source/source.tgz to local path: /var/lib/jenkins/workspace/Beats_beats_PR-21739/source.tgz
[2020-10-13T12:50:35.174Z] + tar --version
[2020-10-13T12:50:35.506Z] + tar -xpf source.tgz
[2020-10-13T12:50:48.123Z] + rm source.tgz
[2020-10-13T12:50:48.228Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats
[2020-10-13T12:50:48.259Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/lint-1602588829198
[2020-10-13T12:50:48.352Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/libbeat-stress-tests-1602589114760
[2020-10-13T12:50:48.445Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/winlogbeat-crosscompile-1602589195586
[2020-10-13T12:50:48.541Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/auditbeat-crosscompile-1602589226424
[2020-10-13T12:50:48.634Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-dockerlogbeat-build-1602589287151
[2020-10-13T12:50:48.730Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-elastic-agent-build-1602589297170
[2020-10-13T12:50:48.823Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/journalbeat-unitTest-1602589300135
[2020-10-13T12:50:48.919Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/libbeat-crosscompile-1602589384354
[2020-10-13T12:50:49.016Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-filebeat-build-1602589413411
[2020-10-13T12:50:49.112Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-functionbeat-build-1602589425519
[2020-10-13T12:50:49.213Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/packetbeat-build-1602589502559
[2020-10-13T12:50:49.313Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-elastic-agent-windows-windows-2019-1602589570373
[2020-10-13T12:50:49.415Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/metricbeat-unitTest-1602589627160
[2020-10-13T12:50:49.520Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/heartbeat-build-1602589678682
[2020-10-13T12:50:49.629Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/metricbeat-crosscompile-1602589707036
[2020-10-13T12:50:49.733Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/auditbeat-build-1602589722478
[2020-10-13T12:50:49.835Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/auditbeat-windows-windows-2019-1602589758236
[2020-10-13T12:50:49.941Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/generator-beat-test-1602589769102
[2020-10-13T12:50:50.041Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/heartbeat-windows-windows-2019-1602589793766
[2020-10-13T12:50:50.143Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/generator-metricbeat-test-1602589875128
[2020-10-13T12:50:50.252Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-filebeat-windows-windows-2019-1602589878695
[2020-10-13T12:50:50.356Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-auditbeat-build-1602589886942
[2020-10-13T12:50:50.456Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/packetbeat-windows-windows-2019-1602589901865
[2020-10-13T12:50:50.569Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-auditbeat-windows-windows-2019-1602589908793
[2020-10-13T12:50:50.665Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-libbeat-build-1602589923410
[2020-10-13T12:50:50.760Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-functionbeat-windows-windows-2019-1602589925237
[2020-10-13T12:50:50.858Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/winlogbeat-windows-windows-2019-1602589929684
[2020-10-13T12:50:50.953Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-winlogbeat-build-windows-2019-1602589954783
[2020-10-13T12:50:51.047Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/filebeat-windows-windows-2019-1602589963258
[2020-10-13T12:50:51.142Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/metricbeat-windows-windows-2019-1602590077139
[2020-10-13T12:50:51.239Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-metricbeat-windows-windows-2019-1602590237983
[2020-10-13T12:50:51.341Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/filebeat-build-1602590772099
[2020-10-13T12:50:51.439Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/libbeat-build-1602590985924
[2020-10-13T12:50:51.565Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/metricbeat-pythonIntegTest-1602591134180
[2020-10-13T12:50:51.661Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/metricbeat-goIntegTest-1602591135331
[2020-10-13T12:50:51.759Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-metricbeat-build-1602593005303
[2020-10-13T12:50:52.184Z] + cat
[2020-10-13T12:50:52.184Z] + /usr/local/bin/runbld ./runbld-test-reports --job-name elastic+beats+pull-request
[2020-10-13T12:50:52.184Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-10-13T12:50:58.815Z] runbld>>> runbld started
[2020-10-13T12:50:58.816Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-10-13T12:51:00.737Z] runbld>>> The following profiles matched the job 'elastic+beats+pull-request' in order of occurrence in the config (last value wins).
[2020-10-13T12:51:00.737Z] runbld>>> Matches in the system config:
[2020-10-13T12:51:00.737Z] runbld>>> - Matched ^elastic\+beats
[2020-10-13T12:51:00.737Z] runbld>>> - Matched ^elastic\+beats\+pull-request
[2020-10-13T12:51:01.683Z] runbld>>> Debug logging enabled.
[2020-10-13T12:51:01.946Z] runbld>>> Storing result
[2020-10-13T12:51:01.946Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-10-13T12:51:01.946Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20201013125101-35CFD4AE
[2020-10-13T12:51:01.946Z] runbld>>> Adding system facts.
[2020-10-13T12:51:03.373Z] runbld>>> Adding vcs info for the latest commit:  42f1673e130eb37325a2954b72b8529fe73cf5ae
[2020-10-13T12:51:03.373Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-10-13T12:51:03.373Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-10-13T12:51:03.373Z] Processing JUnit reports with runbld...
[2020-10-13T12:51:03.373Z] + echo 'Processing JUnit reports with runbld...'
[2020-10-13T12:51:03.634Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-10-13T12:51:03.634Z] runbld>>> DURATION: 31ms
[2020-10-13T12:51:03.635Z] runbld>>> STDOUT: 40 bytes
[2020-10-13T12:51:03.635Z] runbld>>> STDERR: 49 bytes
[2020-10-13T12:51:03.635Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-10-13T12:51:03.635Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-21739
[2020-10-13T12:51:04.583Z] runbld>>> Storing build metadata: 
[2020-10-13T12:51:04.584Z] runbld>>> Adding test report.
[2020-10-13T12:51:04.584Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats
[2020-10-13T12:51:05.531Z] runbld>>> Found 119 test output files
[2020-10-13T12:51:05.794Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/metricbeat-goIntegTest-1602591135331/metricbeat/build/TEST-go-integration-graphite.xml
[2020-10-13T12:51:05.794Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/metricbeat-goIntegTest-1602591135331/metricbeat/build/TEST-go-integration-windows.xml
[2020-10-13T12:51:08.352Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-metricbeat-build-1602593005303/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-10-13T12:51:08.352Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-metricbeat-build-1602593005303/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-10-13T12:51:08.352Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-metricbeat-build-1602593005303/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-10-13T12:51:08.352Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-metricbeat-build-1602593005303/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-10-13T12:51:08.352Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-21739/src/github.com/elastic/beats/x-pack-metricbeat-build-1602593005303/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-10-13T12:51:08.352Z] runbld>>> Test output logs contained: Errors: 0 Failures: 4 Tests: 16610 Skipped: 844
[2020-10-13T12:51:08.352Z] runbld>>> Storing result
[2020-10-13T12:51:08.352Z] runbld>>> FAILURES: 4
[2020-10-13T12:51:09.299Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-10-13T12:51:09.299Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20201013125101-35CFD4AE
[2020-10-13T12:51:09.567Z] runbld>>> Email notification disabled by environment variable.
[2020-10-13T12:51:09.567Z] runbld>>> Slack notification disabled by environment variable.
[2020-10-13T12:51:15.934Z] Running on worker-1244230 in /var/lib/jenkins/workspace/Beats_beats_PR-21739
[2020-10-13T12:51:16.007Z] [INFO] getVaultSecret: Getting secrets
[2020-10-13T12:51:16.070Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-10-13T12:51:18.179Z] + chmod 755 generate-build-data.sh
[2020-10-13T12:51:18.179Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21739/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21739/runs/1 FAILURE 6057008
[2020-10-13T12:51:18.179Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21739/runs/1/steps/?limit=10000 -o steps-info.json
[2020-10-13T12:51:24.600Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21739/runs/1/tests/?status=FAILED -o tests-errors.json
[2020-10-13T12:51:24.600Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21739/runs/1/log/ -o pipeline-log.txt

@jsoriano
Copy link
Member Author

Failing tests are #21748

@jsoriano jsoriano self-assigned this Oct 13, 2020
@jsoriano jsoriano merged commit 5eb45d9 into elastic:7.x Oct 13, 2020
@jsoriano jsoriano deleted the backport_16349_7.x branch October 13, 2020 16:54
@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