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 #20898 to 7.x: Avoid generating incomplete configurations in autodiscover #20919

Merged
merged 2 commits into from
Sep 3, 2020

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Sep 2, 2020

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

What does this PR do?

Handle errors when configuration unpacking fails. In principle this can
only happen when some variable is missing, because configuration has
been previously parsed as YAML. Errors on unpacking were previously
ignored.

When a variable is missing, this is clearly logged at the debug level.

This changes the behaviour, previously an incomplete configuration was
generated on this case.

Why is it important?

To detect problems with incomplete configuration earlier and improve feedback in logs
when a variable is missing in event.

Since #18979 this error is more frequent, as a legit configuration for containers produces
errors with pod events that don't contain container fields.

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

Logs

For example the following configuration includes an incorrect field container.id.

filebeat.autodiscover:
  providers:
    - type: docker
      hints.enabled: true
      hints.default_config:
        type: container
        paths:
          - /var/lib/docker/containers/${container.id}/*.log

Before this change, an incomplete configuration is generated, and errors like these ones are logged:

2020-09-01T16:52:50.094+0200	ERROR	[autodiscover]	autodiscover/autodiscover.go:209	Auto discover config check failed for config '{
  "docker-json": {
    "cri_flags": true,
    "format": "auto",
    "partial": true,
    "stream": "all"
  },
  "symlinks": true,
  "type": "container"
}', won't start runner: each input must have at least one path defined

After this change, the cause of the problem is more clear, and it is only logged at the debug level:

2020-09-02T11:57:08.225+0200	DEBUG	[autodiscover]	template/config.go:156	Configuration template cannot be resolved: field 'container.id' not available in event or environment accessing 'paths' (source:'/home/jaime/tmp/filebeat-autodiscover-docker-hints.yml')

…0898)

Handle errors when configuration unpacking fails. In principle this can
only happen when some variable is missing, because configuration has
been previously parsed as YAML. Errors on unpacking were previously
ignored.

When a variable is missing, this is clearly logged at the debug level.

This changes the behaviour, previously an incomplete configuration was
generated on this case.

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

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

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

elasticmachine commented Sep 2, 2020

💔 Tests Failed

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-09-02T13:38:20.317+0000

  • Duration: 75 min 31 sec

Test stats 🧪

Test Results
Failed 1
Passed 15688
Skipped 1333
Total 17022

Test errors

Expand to view the tests failures

  • Name: Build and Test / Metricbeat OSS Python Integration tests / test_remote_write – metricbeat.module.prometheus.test_prometheus.TestRemoteWrite

    • Age: 1
    • Duration: 63.116
    • Error Details: beat.beat.TimeoutError: Timeout waiting for 'cond' to be true. Waited 60 seconds.

Steps errors

Expand to view the steps failures

  • Name: Mage pythonIntegTest
    • Description: mage pythonIntegTest

    • Duration: 34 min 10 sec

    • Start Time: 2020-09-02T14:02:57.526+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-09-02T14:51:55.380Z] + git config user.name beatsmachine
[2020-09-02T14:51:55.762Z] + .ci/scripts/terraform-cleanup.sh x-pack/metricbeat
[2020-09-02T14:51:55.763Z] + DIRECTORY=x-pack/metricbeat
[2020-09-02T14:51:55.763Z] + FAILED=0
[2020-09-02T14:51:55.763Z] ++ find x-pack/metricbeat -name terraform.tfstate
[2020-09-02T14:51:55.763Z] + exit 0
[2020-09-02T14:52:05.072Z] [INFO] unstashV2: JOB_GCS_BUCKET is set. bucket param got precedency instead.
[2020-09-02T14:52:05.094Z] [INFO] unstashV2: JOB_GCS_CREDENTIALS is set. credentialsId param got precedency instead.
[2020-09-02T14:52:05.157Z] [Google Cloud Storage Plugin] Found 1 files to download from pattern: gs://beats-ci-temp/Beats/beats/PR-20919-3/source/source.tgz
[2020-09-02T14:52:05.175Z] [Google Cloud Storage Plugin] Downloading: Beats/beats/PR-20919-3/source/source.tgz to local path: /var/lib/jenkins/workspace/Beats_beats_PR-20919/source.tgz
[2020-09-02T14:52:14.103Z] + tar --version
[2020-09-02T14:52:14.402Z] + tar -xpf source.tgz
[2020-09-02T14:52:24.721Z] + rm source.tgz
[2020-09-02T14:52:24.736Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats
[2020-09-02T14:52:24.770Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Lint
[2020-09-02T14:52:24.862Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Winlogbeat-oss
[2020-09-02T14:52:24.947Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-09-02T14:52:25.031Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Auditbeat-crosscompile
[2020-09-02T14:52:25.128Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/dockerlogbeat
[2020-09-02T14:52:25.219Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Journalbeat
[2020-09-02T14:52:25.301Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-09-02T14:52:25.397Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Packetbeat-Linux
[2020-09-02T14:52:25.478Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Generators-Metricbeat-Linux
[2020-09-02T14:52:25.566Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-09-02T14:52:25.659Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-OSS-Unit-tests
[2020-09-02T14:52:25.744Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Heartbeat-Windows
[2020-09-02T14:52:25.839Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Heartbeat-oss
[2020-09-02T14:52:25.933Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Auditbeat-oss-Windows
[2020-09-02T14:52:26.027Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-09-02T14:52:26.116Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-crosscompile
[2020-09-02T14:52:26.202Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-09-02T14:52:26.286Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-09-02T14:52:26.369Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Auditbeat-oss-Linux
[2020-09-02T14:52:26.452Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Packetbeat-Windows
[2020-09-02T14:52:26.536Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Winlogbeat-Windows
[2020-09-02T14:52:26.627Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-09-02T14:52:26.710Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Libbeat-x-pack
[2020-09-02T14:52:26.827Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Filebeat-Windows
[2020-09-02T14:52:26.931Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Functionbeat-Windows
[2020-09-02T14:52:27.026Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-09-02T14:52:27.108Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-Windows
[2020-09-02T14:52:27.197Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Generators-Beat-Linux
[2020-09-02T14:52:27.279Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Filebeat-x-pack
[2020-09-02T14:52:27.361Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Filebeat-oss
[2020-09-02T14:52:27.445Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests
[2020-09-02T14:52:27.530Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-OSS-Python-Integration-tests
[2020-09-02T14:52:27.613Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Libbeat-oss
[2020-09-02T14:52:27.694Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Libbeat-crosscompile
[2020-09-02T14:52:27.775Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Libbeat-stress-tests
[2020-09-02T14:52:27.859Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-09-02T14:52:28.261Z] + cat
[2020-09-02T14:52:28.262Z] + /usr/local/bin/runbld ./runbld-script --job-name elastic+beats+pull-request
[2020-09-02T14:52:28.262Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-09-02T14:52:34.846Z] runbld>>> runbld started
[2020-09-02T14:52:34.846Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-09-02T14:52:36.760Z] runbld>>> The following profiles matched the job 'elastic+beats+pull-request' in order of occurrence in the config (last value wins).
[2020-09-02T14:52:36.760Z] runbld>>> Matches in the system config:
[2020-09-02T14:52:36.760Z] runbld>>> - Matched ^elastic\+beats
[2020-09-02T14:52:36.760Z] runbld>>> - Matched ^elastic\+beats\+pull-request
[2020-09-02T14:52:38.144Z] runbld>>> Debug logging enabled.
[2020-09-02T14:52:38.144Z] runbld>>> Storing result
[2020-09-02T14:52:38.144Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-09-02T14:52:38.144Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20200902145237-60A73E86
[2020-09-02T14:52:38.144Z] runbld>>> Adding system facts.
[2020-09-02T14:52:39.087Z] runbld>>> Adding vcs info for the latest commit:  3f8bab194152c08e09570ecab4c505b7737ca4c5
[2020-09-02T14:52:39.087Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-09-02T14:52:39.087Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-09-02T14:52:39.348Z] Processing JUnit reports with runbld...
[2020-09-02T14:52:39.348Z] + echo 'Processing JUnit reports with runbld...'
[2020-09-02T14:52:39.609Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-09-02T14:52:39.609Z] runbld>>> DURATION: 37ms
[2020-09-02T14:52:39.609Z] runbld>>> STDOUT: 40 bytes
[2020-09-02T14:52:39.609Z] runbld>>> STDERR: 49 bytes
[2020-09-02T14:52:39.609Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-09-02T14:52:39.609Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-20919
[2020-09-02T14:52:40.550Z] runbld>>> Storing build metadata: 
[2020-09-02T14:52:40.550Z] runbld>>> Adding test report.
[2020-09-02T14:52:40.550Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats
[2020-09-02T14:52:41.490Z] runbld>>> Found 121 test output files
[2020-09-02T14:52:43.405Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-09-02T14:52:43.406Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-09-02T14:52:43.406Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-09-02T14:52:43.406Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-09-02T14:52:43.406Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-09-02T14:52:43.667Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests/metricbeat/build/TEST-go-integration-graphite.xml
[2020-09-02T14:52:43.667Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20919/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests/metricbeat/build/TEST-go-integration-windows.xml
[2020-09-02T14:52:44.242Z] runbld>>> Test output logs contained: Errors: 0 Failures: 1 Tests: 16871 Skipped: 1087
[2020-09-02T14:52:44.242Z] runbld>>> Storing result
[2020-09-02T14:52:44.242Z] runbld>>> FAILURES: 1
[2020-09-02T14:52:44.813Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-09-02T14:52:44.813Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20200902145237-60A73E86
[2020-09-02T14:52:44.813Z] runbld>>> Email notification disabled by environment variable.
[2020-09-02T14:52:44.813Z] runbld>>> Slack notification disabled by environment variable.
[2020-09-02T14:52:50.360Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-20919
[2020-09-02T14:52:50.473Z] [INFO] getVaultSecret: Getting secrets
[2020-09-02T14:52:50.553Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-09-02T14:52:51.324Z] + chmod 755 generate-build-data.sh
[2020-09-02T14:52:51.324Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20919/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20919/runs/3 FAILURE 4470745
[2020-09-02T14:52:51.324Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20919/runs/3/steps/?limit=10000 -o steps-info.json
[2020-09-02T14:52:53.186Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20919/runs/3/tests/?status=FAILED -o tests-errors.json

@jsoriano
Copy link
Member Author

jsoriano commented Sep 2, 2020

jenkins run the tests please

@jsoriano jsoriano merged commit 19a650f into elastic:7.x Sep 3, 2020
@jsoriano jsoriano deleted the backport_20898_7.x branch September 3, 2020 10:07
@zube zube bot removed the [zube]: Done label Dec 2, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants