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

Cache error responses for cloudfoundry apps metadata #19181

Merged

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Jun 13, 2020

What does this PR do?

Cache error responses when requesting Cloud Foundry apps metadata to
avoid hitting continuously the API when there are failures.

The original motivation for this change was to handle AppNotFound errors,
but the truth is that continuously retrying on any error is not very good, so
this change effectively introduces a delay between retries on any error from
the API. It looks safer by now. We can reconsider this in the future if we see
that some other error should be handled in a different way.

An specific flag cache_retry_delay is also added to configure how long Beats
should wait before retrying again in case of error.

Why is it important?

Sometimes events are received for apps that cannot be found on the API, on
these cases Beats continuously hit the API to try to get the metadata. This
provokes unnecessary load on API servers of big deployments.

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.

@jsoriano jsoriano added in progress Pull request is currently in progress. [zube]: In Progress Team:Platforms Label for the Integrations - Platforms team labels Jun 13, 2020
@jsoriano jsoriano self-assigned this Jun 13, 2020
@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 13, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 13, 2020

❕ Build Aborted

Either there was a build timeout or someone aborted the build.'}

Pipeline View Test View Changes Artifacts

Expand to view the summary

Build stats

  • Build Cause: [Branch indexing]

  • Start Time: 2020-07-03T08:06:16.948+0000

  • Duration: 123 min 2 sec

Test stats 🧪

Test Results
Failed 0
Passed 2890
Skipped 352
Total 3242

Steps errors

Expand to view the steps failures

Log output

Expand to view the last 100 lines of log output

[2020-07-03T10:08:51.854Z]  API version:       1.40
[2020-07-03T10:08:51.854Z]  Go version:        go1.12.5
[2020-07-03T10:08:51.854Z]  Git commit:        74b1e89
[2020-07-03T10:08:51.854Z]  Built:             Thu Jul 25 21:18:17 2019
[2020-07-03T10:08:51.854Z]  OS/Arch:           darwin/amd64
[2020-07-03T10:08:51.854Z]  Experimental:      false
[2020-07-03T10:08:51.854Z] 
[2020-07-03T10:08:51.854Z] Server: Docker Engine - Community
[2020-07-03T10:08:51.854Z]  Engine:
[2020-07-03T10:08:51.854Z]   Version:          19.03.5
[2020-07-03T10:08:51.854Z]   API version:      1.40 (minimum version 1.12)
[2020-07-03T10:08:51.854Z]   Go version:       go1.12.12
[2020-07-03T10:08:51.854Z]   Git commit:       633a0ea838
[2020-07-03T10:08:51.854Z]   Built:            Wed Nov 13 07:28:45 2019
[2020-07-03T10:08:51.854Z]   OS/Arch:          linux/amd64
[2020-07-03T10:08:51.854Z]   Experimental:     false
[2020-07-03T10:08:51.854Z]  containerd:
[2020-07-03T10:08:51.854Z]   Version:          v1.2.10
[2020-07-03T10:08:51.854Z]   GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
[2020-07-03T10:08:51.854Z]  runc:
[2020-07-03T10:08:51.854Z]   Version:          1.0.0-rc8+dev
[2020-07-03T10:08:51.855Z]   GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
[2020-07-03T10:08:51.855Z]  docker-init:
[2020-07-03T10:08:51.855Z]   Version:          0.18.0
[2020-07-03T10:08:51.855Z]   GitCommit:        fec3683
[2020-07-03T10:08:55.179Z] Body did not finish within grace period; terminating with extreme prejudice
[2020-07-03T10:08:55.298Z] Error when executing always post condition:
[2020-07-03T10:08:55.299Z] org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
[2020-07-03T10:08:55.299Z] 	at org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution.cancel(TimeoutStepExecution.java:165)
[2020-07-03T10:08:55.299Z] 	at org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution.access$100(TimeoutStepExecution.java:38)
[2020-07-03T10:08:55.299Z] 	at org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution$1.run(TimeoutStepExecution.java:139)
[2020-07-03T10:08:55.299Z] 	at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
[2020-07-03T10:08:55.299Z] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[2020-07-03T10:08:55.299Z] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2020-07-03T10:08:55.299Z] 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
[2020-07-03T10:08:55.299Z] 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[2020-07-03T10:08:55.299Z] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[2020-07-03T10:08:55.299Z] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[2020-07-03T10:08:55.299Z] 	at java.lang.Thread.run(Thread.java:748)
[2020-07-03T10:08:55.299Z] 
[2020-07-03T10:08:55.397Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats
[2020-07-03T10:08:55.728Z] + find . -type f -name TEST*.xml -path */build/* -delete
[2020-07-03T10:08:55.741Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Lint
[2020-07-03T10:08:55.847Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-07-03T10:08:55.968Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-07-03T10:08:56.076Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Dockerlogbeat
[2020-07-03T10:08:56.175Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-07-03T10:08:56.274Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-07-03T10:08:56.366Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-07-03T10:08:56.468Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Libbeat-x-pack
[2020-07-03T10:08:56.572Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Filebeat-x-pack
[2020-07-03T10:08:56.665Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-07-03T10:08:56.855Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-07-03T10:08:56.935Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-07-03T10:08:57.042Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-07-03T10:08:57.423Z] + cat
[2020-07-03T10:08:57.423Z] + /usr/local/bin/runbld ./runbld-script
[2020-07-03T10:08:57.423Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-07-03T10:09:04.038Z] runbld>>> runbld started
[2020-07-03T10:09:04.039Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-07-03T10:09:04.466Z] [Google Cloud Storage Plugin] Downloading: Beats/beats-beats-mbp/PR-19181-16/source/source.tgz to local path: /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/source.tgz
[2020-07-03T10:09:05.964Z] runbld>>> The following profiles matched the job 'Beats/beats-beats-mbp/PR-19181' in order of occurrence in the config (last value wins).
[2020-07-03T10:09:07.360Z] runbld>>> Debug logging enabled.
[2020-07-03T10:09:07.360Z] runbld>>> Storing result
[2020-07-03T10:09:07.629Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-07-03T10:09:07.629Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200703100907-A1E7DA66
[2020-07-03T10:09:07.629Z] runbld>>> Adding system facts.
[2020-07-03T10:09:08.579Z] runbld>>> Adding vcs info for the latest commit:  23981255d0ebc54f2e8bbe3f7c208b3ebf9be942
[2020-07-03T10:09:08.579Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-07-03T10:09:08.579Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-07-03T10:09:08.579Z] + echo 'Processing JUnit reports with runbld...'
[2020-07-03T10:09:08.579Z] Processing JUnit reports with runbld...
[2020-07-03T10:09:09.155Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-07-03T10:09:09.155Z] runbld>>> DURATION: 23ms
[2020-07-03T10:09:09.155Z] runbld>>> STDOUT: 40 bytes
[2020-07-03T10:09:09.155Z] runbld>>> STDERR: 49 bytes
[2020-07-03T10:09:09.155Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-07-03T10:09:09.155Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats
[2020-07-03T10:09:10.209Z] runbld>>> Storing build metadata: 
[2020-07-03T10:09:10.209Z] runbld>>> Adding test report.
[2020-07-03T10:09:10.209Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats
[2020-07-03T10:09:10.845Z] runbld>>> Found 36 test output files
[2020-07-03T10:09:11.506Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-07-03T10:09:11.506Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-07-03T10:09:11.506Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-07-03T10:09:11.506Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-07-03T10:09:11.767Z] runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 3092 Skipped: 315
[2020-07-03T10:09:11.767Z] runbld>>> Storing result
[2020-07-03T10:09:11.768Z] runbld>>> FAILURES: 0
[2020-07-03T10:09:12.099Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-07-03T10:09:12.099Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200703100907-A1E7DA66
[2020-07-03T10:09:12.099Z] runbld>>> Email notification disabled by environment variable.
[2020-07-03T10:09:12.368Z] runbld>>> Slack notification disabled by environment variable.
[2020-07-03T10:09:17.889Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-19181
[2020-07-03T10:09:18.018Z] [INFO] getVaultSecret: Getting secrets
[2020-07-03T10:09:18.100Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-07-03T10:09:18.893Z] + chmod 755 generate-build-data.sh
[2020-07-03T10:09:18.894Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19181/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19181/runs/16 ABORTED 7381686
[2020-07-03T10:09:18.894Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19181/runs/16/steps/?limit=10000 -o steps-info.json
[2020-07-03T10:09:20.237Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-19181/runs/16/tests/?status=FAILED -o tests-errors.json

Cache error responses when requesting Cloud Foundry apps metadata to
avoid hitting continuously the API when there are missing applications.
@jsoriano jsoriano force-pushed the cloudfoundry-metadata-ignore-missing-apps branch from 6ef177a to a783612 Compare June 30, 2020 10:40
@jsoriano jsoriano added [zube]: In Review needs_backport PR is waiting to be backported to other branches. review v7.9.0 and removed [zube]: In Progress in progress Pull request is currently in progress. labels Jun 30, 2020
@jsoriano jsoriano marked this pull request as ready for review June 30, 2020 11:00
@elasticmachine
Copy link
Collaborator

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

@jsoriano
Copy link
Member Author

jsoriano commented Jul 1, 2020

jenkins run the tests please

@jsoriano
Copy link
Member Author

jsoriano commented Jul 3, 2020

Merging as there was a green build of the same changeset two days ago and current failures seem to be related to hitting some limit on GH APIs 🤞

@jsoriano jsoriano merged commit 9c0b63d into elastic:master Jul 3, 2020
jsoriano added a commit to jsoriano/beats that referenced this pull request Jul 3, 2020
Cache error responses when requesting Cloud Foundry apps metadata to
avoid hitting continuously the API when there are missing applications.

(cherry picked from commit 9c0b63d)
@jsoriano jsoriano removed the needs_backport PR is waiting to be backported to other branches. label Jul 3, 2020
v1v added a commit to v1v/beats that referenced this pull request Jul 3, 2020
…ne-beats

* upstream/master: (35 commits)
  [ci] fix env variable name for xpack filebeats (elastic#19617)
  Cache error responses for cloudfoundry apps metadata (elastic#19181)
  ci: user fixed type of agent (elastic#19625)
  Input v2 cursor testing (elastic#19573)
  Update Jenkinsfile to not inspect removed vendor (elastic#19610)
  Fix ordering and duplicate configs on autodiscover (elastic#19317)
  Prepare input/file for changes in the registrar (elastic#19516)
  Cursor input and manager implementation (elastic#19571)
  [Filebeat] Fix tls mapping in suricata module (elastic#19494)
  [Ingest Manager] Make Agent beta and Constraints experimental (elastic#19586)
  Accept prefix as metric_types for stackdriver metricset in GCP (elastic#19345)
  Implement memlog store operations (elastic#19533)
  introduce journalbeat/pkg in order to provide reusable shared code (elastic#19581)
  Add descriptions to HAProxy fields in Metricbeat (elastic#19561)
  ci: apm-server-update trigered only on upstream, comments, and manual triggered (elastic#19590)
  ci: enable upstream triggering on the packaging job (elastic#19589)
  ci: some jjbb improvements (elastic#19588)
  [MetricBeat] set tags correctly if the dimension value is ARN (elastic#19433)
  [Filebeat] Add default_fields: false to fields.yml in aws module (elastic#19568)
  Add publisher implementation for stateful inputs (elastic#19530)
  ...
jsoriano added a commit that referenced this pull request Jul 6, 2020
Cache error responses when requesting Cloud Foundry apps metadata to
avoid hitting continuously the API when there are missing applications.

(cherry picked from commit 9c0b63d)
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
Cache error responses when requesting Cloud Foundry apps metadata to
avoid hitting continuously the API when there are missing applications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Platforms Label for the Integrations - Platforms team v7.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants