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 #19135 to 7.x: Apply Autodiscovery dynamic fields in autoreloading #19708

Merged
merged 2 commits into from
Jul 7, 2020

Conversation

urso
Copy link

@urso urso commented Jul 7, 2020

Cherry-pick of PR #19135 to 7.x branch. Original message:

  • Refactoring

What does this PR do?

Add a helper WithDynamicFields to pipetool package to configure dynamic fields added by Autodiscovery in a more consistent manner.

Instead of the Beats having to add dynamic fields, the addition will be handled in libbeat only now.

In order to ease testing without the full beats publishing pipeline a FakeConnector and FakeClient have been added to libbeat/pipeline/testing

Remove the configuration of dynamic fields from each filebeat input.

Why is it important?

Dynamic fields is a feature that was introduced to beats by autodiscovery. Instead of configuring fields a pointer to the fields to be added is shared. The autodiscovery provider can update the pointer to a new MapStr in order to reconfigure the fields without having to restart the input/module.

Currently each input needs to apply DynamicFields when connecting to the publisher pipeline. In Filebeat each Input has to add the fields when connecting, while Metricbeat and Heartbeat use custom wrappers.
With this change dynamic fields from autodiscovery are handled by libbeat in one single place only. This reduces duplication and sharing of responsibilities regarding autodiscovery specific code among the beats code base.

Note: responsibility for applying dynamic fields is still shared between autodiscovery and the cfgfile package. As the future of both package is somewhat in the flux I will not continue refactoring these two package for now (unless changes are required for the v2 input API).

This change is introduced to prepare for the input v2 API introduction in Beats. Moving common functionality up into more appropriate layers removes the need to reimplement the functionality in the new API.

Note: I didn't check in detail, but it looks like this changes fixes a bug in heartbeat not picking up dynamic field changes triggered by kuberenetes events.

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.

How to test this PR locally

The change should not be user visible. But in order to verify no regression is introduced some simple tests with kubernetes autodiscovery would be helpful (@exekias can you give details/instructions?)

Developer Docs

The cfgfile.RunnerFactory interface has been modified. The interface is used to integrate with AutoDiscovery or input configuration reloading. The last parameter of type common.MapStrPointer has been removed. The Processing.DynamicFields is not required to be set anymore when calling pipeline.ConnectWith.

Related issues

@urso urso requested a review from a team as a code owner July 7, 2020 16:12
@urso urso added [zube]: In Review backport Team:Services (Deprecated) Label for the former Integrations-Services team labels Jul 7, 2020
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 7, 2020
@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 Jul 7, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 7, 2020

💔 Build Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #19708 updated]

  • Start Time: 2020-07-07T17:24:15.748+0000

  • Duration: 122 min 15 sec

Test stats 🧪

Test Results
Failed 0
Passed 9063
Skipped 1580
Total 10643

Steps errors

Expand to view the steps failures

  • Name: Report to Codecov

    • Description: curl -sSLo codecov https://codecov.io/bash for i in auditbeat filebeat heartbeat libbeat metricbeat packetbeat winlogbeat journalbeat do FILE="${i}/build/coverage/full.cov" if [ -f "${FILE}" ]; then bash codecov -f "${FILE}" fi done

    • Duration: 2 min 22 sec

    • Start Time: 2020-07-07T18:02:08.831+0000

    • log

  • Name: Report to Codecov

    • Description: curl -sSLo codecov https://codecov.io/bash for i in auditbeat filebeat heartbeat libbeat metricbeat packetbeat winlogbeat journalbeat do FILE="${i}/build/coverage/full.cov" if [ -f "${FILE}" ]; then bash codecov -f "${FILE}" fi done

    • Duration: 2 min 22 sec

    • Start Time: 2020-07-07T18:22:58.658+0000

    • log

  • Name: Make -C generator/_templates/metricbeat test

    • Description: make -C generator/_templates/metricbeat test

    • Duration: 7 min 34 sec

    • Start Time: 2020-07-07T18:44:24.401+0000

    • log

  • Name: Recursively delete the current directory from the workspace

    • Description: script returned exit code 2

    • Duration: 2 min 0 sec

    • Start Time: 2020-07-07T18:51:15.441+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-07-07T19:26:04.538Z] + FILE=winlogbeat/build/coverage/full.cov
[2020-07-07T19:26:04.538Z] + [ -f winlogbeat/build/coverage/full.cov ]
[2020-07-07T19:26:04.538Z] + FILE=journalbeat/build/coverage/full.cov
[2020-07-07T19:26:04.538Z] + [ -f journalbeat/build/coverage/full.cov ]
[2020-07-07T19:26:05.688Z] Failed in branch Filebeat oss
[2020-07-07T19:26:05.809Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats
[2020-07-07T19:26:06.123Z] + find . -type f -name TEST*.xml -path */build/* -delete
[2020-07-07T19:26:06.135Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Lint
[2020-07-07T19:26:06.214Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Elastic-Agent-Mac-OS-X
[2020-07-07T19:26:06.288Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-07-07T19:26:06.360Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Filebeat-x-pack-Mac-OS-X
[2020-07-07T19:26:06.439Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Auditbeat-oss-Mac-OS-X
[2020-07-07T19:26:06.511Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Filebeat-Mac-OS-X
[2020-07-07T19:26:06.583Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-07-07T19:26:06.655Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Auditbeat-x-pack-Mac-OS-X
[2020-07-07T19:26:06.727Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-x-pack-Mac-OS-X
[2020-07-07T19:26:06.799Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Winlogbeat-oss
[2020-07-07T19:26:06.873Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Auditbeat-crosscompile
[2020-07-07T19:26:06.949Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Dockerlogbeat
[2020-07-07T19:26:07.021Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-Mac-OS-X
[2020-07-07T19:26:07.096Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Journalbeat-oss
[2020-07-07T19:26:07.168Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Generators-Metricbeat-Linux
[2020-07-07T19:26:07.241Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-07-07T19:26:07.315Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Filebeat-Windows
[2020-07-07T19:26:07.388Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-OSS-Unit-tests
[2020-07-07T19:26:07.461Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-07-07T19:26:07.534Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-crosscompile
[2020-07-07T19:26:07.606Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Heartbeat-oss
[2020-07-07T19:26:07.678Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-07-07T19:26:07.750Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Auditbeat-oss-Windows
[2020-07-07T19:26:07.822Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Functionbeat-Mac-OS-X-x-pack
[2020-07-07T19:26:07.895Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-07-07T19:26:07.967Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-07-07T19:26:08.040Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Libbeat-x-pack
[2020-07-07T19:26:08.114Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Auditbeat-oss-Linux
[2020-07-07T19:26:08.188Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Packetbeat-oss
[2020-07-07T19:26:08.262Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-Windows
[2020-07-07T19:26:08.336Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-07-07T19:26:08.409Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Generators-Beat-Linux
[2020-07-07T19:26:08.481Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Heartbeat-Mac-OS-X
[2020-07-07T19:26:08.553Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Winlogbeat-Windows
[2020-07-07T19:26:08.625Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Functionbeat-Windows
[2020-07-07T19:26:08.697Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-Python-integration-tests
[2020-07-07T19:26:08.780Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Heartbeat-Windows
[2020-07-07T19:26:08.852Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Libbeat-oss
[2020-07-07T19:26:08.928Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Libbeat-crosscompile
[2020-07-07T19:26:09.000Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Libbeat-stress-tests
[2020-07-07T19:26:09.079Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests
[2020-07-07T19:26:09.151Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Generators-Metricbeat-Mac-OS-X
[2020-07-07T19:26:09.223Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-07-07T19:26:09.297Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Filebeat-x-pack
[2020-07-07T19:26:09.371Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Filebeat-oss
[2020-07-07T19:26:09.726Z] + cat
[2020-07-07T19:26:09.726Z] + /usr/local/bin/runbld ./runbld-script
[2020-07-07T19:26:09.726Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-07-07T19:26:16.322Z] runbld>>> runbld started
[2020-07-07T19:26:16.322Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-07-07T19:26:17.264Z] runbld>>> The following profiles matched the job 'Beats/beats-beats-mbp/PR-19708' in order of occurrence in the config (last value wins).
[2020-07-07T19:26:18.651Z] runbld>>> Debug logging enabled.
[2020-07-07T19:26:18.651Z] runbld>>> Storing result
[2020-07-07T19:26:18.651Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-07-07T19:26:18.651Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200707192618-C21979EE
[2020-07-07T19:26:18.651Z] runbld>>> Adding system facts.
[2020-07-07T19:26:19.596Z] runbld>>> Adding vcs info for the latest commit:  af7cb8b72d9b1db27c549961fb4d45629f448d3a
[2020-07-07T19:26:19.596Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-07-07T19:26:19.596Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-07-07T19:26:19.596Z] + echo 'Processing JUnit reports with runbld...'
[2020-07-07T19:26:19.596Z] Processing JUnit reports with runbld...
[2020-07-07T19:26:19.857Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-07-07T19:26:19.857Z] runbld>>> DURATION: 24ms
[2020-07-07T19:26:19.857Z] runbld>>> STDOUT: 40 bytes
[2020-07-07T19:26:19.857Z] runbld>>> STDERR: 49 bytes
[2020-07-07T19:26:19.857Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-07-07T19:26:19.857Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats
[2020-07-07T19:26:20.801Z] runbld>>> Storing build metadata: 
[2020-07-07T19:26:20.802Z] runbld>>> Adding test report.
[2020-07-07T19:26:20.802Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats
[2020-07-07T19:26:21.744Z] runbld>>> Found 113 test output files
[2020-07-07T19:26:22.005Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-07-07T19:26:22.006Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-07-07T19:26:22.006Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-07-07T19:26:22.006Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-07-07T19:26:22.006Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-07-07T19:26:23.393Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests/metricbeat/build/TEST-go-integration-graphite.xml
[2020-07-07T19:26:23.393Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests/metricbeat/build/TEST-go-integration-windows.xml
[2020-07-07T19:26:23.653Z] runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 10493 Skipped: 1343
[2020-07-07T19:26:23.914Z] runbld>>> Storing result
[2020-07-07T19:26:23.914Z] runbld>>> FAILURES: 0
[2020-07-07T19:26:23.914Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-07-07T19:26:23.914Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200707192618-C21979EE
[2020-07-07T19:26:24.175Z] runbld>>> Email notification disabled by environment variable.
[2020-07-07T19:26:24.175Z] runbld>>> Slack notification disabled by environment variable.
[2020-07-07T19:26:29.687Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19708
[2020-07-07T19:26:29.788Z] [INFO] getVaultSecret: Getting secrets
[2020-07-07T19:26:29.848Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-07-07T19:26:30.703Z] + chmod 755 generate-build-data.sh
[2020-07-07T19:26:30.704Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19708/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19708/runs/2 FAILURE 7334696
[2020-07-07T19:26:30.704Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19708/runs/2/steps/?limit=10000 -o steps-info.json
[2020-07-07T19:26:33.187Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19708/runs/2/tests/?status=FAILED -o tests-errors.json
[2020-07-07T19:26:33.187Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19708/runs/2/log/ -o pipeline-log.txt

@urso
Copy link
Author

urso commented Jul 7, 2020

CI is all green. Uploading some results failed.

@urso urso merged commit 8f5355d into elastic:7.x Jul 7, 2020
@urso urso deleted the backport_19135_7.x branch July 7, 2020 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Services (Deprecated) Label for the former Integrations-Services team [zube]: Done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants