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 #18483 to 7.x: Add a file lock to the data directory on startup to prevent multiple agents. #18529

Merged
merged 1 commit into from
May 14, 2020

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented May 14, 2020

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

What does this PR do?

Adds an agent.lock to the path.data directory.

Why is it important?

Prevents the ability to run multiple agents on the same host.

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

  • Multiple agents cannot be started at the same time.

How to test this PR locally

Try to start two elastic-agent at the same time on the same host and see that the second one started errors out with another elastic-agent is already running.

Related issues

…agents. (elastic#18483)

* Add a file lock to the data directory on startup to prevent multiple agents.

* Add export comments to AppLocker.

* Fix periodic to not block startup.

(cherry picked from commit e1a4741)
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 14, 2020
@blakerouse blakerouse added Team:Ingest Management and removed needs_team Indicates that the issue/PR needs a Team:* label labels May 14, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Team:Ingest Management)

@blakerouse blakerouse self-assigned this May 14, 2020
@elasticmachine
Copy link
Collaborator

💔 Build Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

Steps errors

Expand to view the steps failures

  • Name: Notifies GitHub of the status of a Pull Request

    • Description:

    • Result: FAILURE

    • Duration: 0 min 1 sec

    • Start Time: 2020-05-14T16:23:00.222+0000

    • log

  • Name: Notifies GitHub of the status of a Pull Request

    • Description:

    • Result: FAILURE

    • Duration: 0 min 1 sec

    • Start Time: 2020-05-14T16:23:01.096+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-05-14T16:29:03.873Z]     --- PASS: TestTokenBucket/when_way_below_the_bucket_size_it_should_not_block (0.00s)
[2020-05-14T16:29:03.873Z]     --- PASS: TestTokenBucket/when_below_the_bucket_size_it_should_not_block (0.00s)
[2020-05-14T16:29:03.873Z]     --- PASS: TestTokenBucket/when_we_hit_the_bucket_size_it_should_block (2.00s)
[2020-05-14T16:29:03.873Z]     --- PASS: TestTokenBucket/When_we_use_a_timer_scheduler_we_can_unblock (0.00s)
[2020-05-14T16:29:03.873Z] PASS
[2020-05-14T16:29:03.873Z] coverage: 64.7% of statements
[2020-05-14T16:29:03.873Z] ok  	github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/tokenbucket	3.152s	coverage: 64.7% of statements
[2020-05-14T16:29:04.014Z] Recording test results
[2020-05-14T16:29:06.393Z] None of the test reports contained any result
[2020-05-14T16:29:07.633Z] Stashed 0 file(s)
[2020-05-14T16:29:07.655Z] Archiving artifacts
[2020-05-14T16:29:08.834Z] java.lang.InterruptedException: no matches found within 10000
[2020-05-14T16:29:08.834Z] 	at hudson.FilePath$ValidateAntFileMask.hasMatch(FilePath.java:2826)
[2020-05-14T16:29:08.834Z] 	at hudson.FilePath$ValidateAntFileMask.invoke(FilePath.java:2705)
[2020-05-14T16:29:08.834Z] 	at hudson.FilePath$ValidateAntFileMask.invoke(FilePath.java:2686)
[2020-05-14T16:29:08.834Z] 	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3073)
[2020-05-14T16:29:08.834Z] Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from beats-ci-immutable-windows-2019-1589473187689683922.c.elastic-ci-prod.internal/10.224.0.181:49718
[2020-05-14T16:29:08.834Z] 		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1788)
[2020-05-14T16:29:08.834Z] 		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
[2020-05-14T16:29:08.834Z] 		at hudson.remoting.Channel.call(Channel.java:998)
[2020-05-14T16:29:08.834Z] 		at hudson.FilePath.act(FilePath.java:1069)
[2020-05-14T16:29:08.834Z] 		at hudson.FilePath.act(FilePath.java:1058)
[2020-05-14T16:29:08.834Z] 		at hudson.FilePath.validateAntFileMask(FilePath.java:2684)
[2020-05-14T16:29:08.834Z] 		at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:265)
[2020-05-14T16:29:08.834Z] 		at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
[2020-05-14T16:29:08.834Z] 		at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
[2020-05-14T16:29:08.834Z] 		at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
[2020-05-14T16:29:08.834Z] 		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[2020-05-14T16:29:08.834Z] 		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2020-05-14T16:29:08.834Z] 		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[2020-05-14T16:29:08.834Z] 		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[2020-05-14T16:29:08.835Z] Caused: hudson.FilePath$TunneledInterruptedException
[2020-05-14T16:29:08.835Z] 	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3075)
[2020-05-14T16:29:08.835Z] 	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
[2020-05-14T16:29:08.835Z] 	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
[2020-05-14T16:29:08.835Z] 	at hudson.remoting.Request$2.run(Request.java:369)
[2020-05-14T16:29:08.835Z] 	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
[2020-05-14T16:29:08.835Z] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2020-05-14T16:29:08.835Z] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[2020-05-14T16:29:08.835Z] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[2020-05-14T16:29:08.835Z] 	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
[2020-05-14T16:29:08.835Z] Caused: java.lang.InterruptedException: java.lang.InterruptedException: no matches found within 10000
[2020-05-14T16:29:08.835Z] 	at hudson.FilePath.act(FilePath.java:1071)
[2020-05-14T16:29:08.835Z] 	at hudson.FilePath.act(FilePath.java:1058)
[2020-05-14T16:29:08.835Z] 	at hudson.FilePath.validateAntFileMask(FilePath.java:2684)
[2020-05-14T16:29:08.835Z] 	at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:265)
[2020-05-14T16:29:08.835Z] 	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
[2020-05-14T16:29:08.835Z] 	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
[2020-05-14T16:29:08.835Z] 	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
[2020-05-14T16:29:08.835Z] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[2020-05-14T16:29:08.835Z] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2020-05-14T16:29:08.835Z] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[2020-05-14T16:29:08.835Z] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[2020-05-14T16:29:08.835Z] 	at java.lang.Thread.run(Thread.java:748)
[2020-05-14T16:29:08.835Z] No artifacts found that match the file pattern "**\build\TEST*.out". Configuration error?
[2020-05-14T16:29:11.669Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18529/src/github.com/elastic/beats
[2020-05-14T16:29:12.016Z] + find . -type f -name TEST*.xml -path */build/* -delete
[2020-05-14T16:29:12.042Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18529/src/github.com/elastic/beats/Lint
[2020-05-14T16:29:12.198Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18529/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-05-14T16:29:12.344Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18529/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-05-14T16:29:12.788Z] + cat
[2020-05-14T16:29:12.788Z] + /usr/local/bin/runbld ./runbld-script
[2020-05-14T16:29:12.788Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-05-14T16:29:19.395Z] runbld>>> runbld started
[2020-05-14T16:29:19.395Z] runbld>>> 1.6.11/a66728ff8f4356963772e6e6d2069392fa06acbe
[2020-05-14T16:29:21.317Z] runbld>>> The following profiles matched the job 'Beats/beats-beats-mbp/PR-18529' in order of occurrence in the config (last value wins).
[2020-05-14T16:29:22.708Z] runbld>>> Debug logging enabled.
[2020-05-14T16:29:22.708Z] runbld>>> Storing result
[2020-05-14T16:29:22.708Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-05-14T16:29:22.708Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200514162922-BB08F366
[2020-05-14T16:29:22.708Z] runbld>>> Adding system facts.
[2020-05-14T16:29:23.653Z] runbld>>> Adding vcs info for the latest commit:  92019b2f242fce57d3aa74bfc4e4b28f8abd815b
[2020-05-14T16:29:24.226Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-05-14T16:29:24.226Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-05-14T16:29:24.226Z] Processing JUnit reports with runbld...
[2020-05-14T16:29:24.226Z] + echo 'Processing JUnit reports with runbld...'
[2020-05-14T16:29:24.488Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-05-14T16:29:24.488Z] runbld>>> DURATION: 10ms
[2020-05-14T16:29:24.488Z] runbld>>> STDOUT: 40 bytes
[2020-05-14T16:29:24.488Z] runbld>>> STDERR: 49 bytes
[2020-05-14T16:29:24.488Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-05-14T16:29:24.488Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18529/src/github.com/elastic/beats
[2020-05-14T16:29:25.880Z] runbld>>> Storing build metadata: 
[2020-05-14T16:29:25.880Z] runbld>>> Adding test report.
[2020-05-14T16:29:25.880Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18529/src/github.com/elastic/beats
[2020-05-14T16:29:26.829Z] runbld>>> Found 0 test output files
[2020-05-14T16:29:26.829Z] runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 0 Skipped: 0
[2020-05-14T16:29:27.091Z] runbld>>> Storing result
[2020-05-14T16:29:27.091Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-05-14T16:29:27.091Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200514162922-BB08F366
[2020-05-14T16:29:27.353Z] runbld>>> Email notification disabled by environment variable.
[2020-05-14T16:29:27.353Z] runbld>>> Slack notification disabled by environment variable.
[2020-05-14T16:29:34.007Z] Running on worker-395930 in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18529
[2020-05-14T16:29:34.139Z] [INFO] getVaultSecret: Getting secrets
[2020-05-14T16:29:34.200Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-05-14T16:29:36.709Z] + chmod 755 generate-build-data.sh
[2020-05-14T16:29:36.710Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18529/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18529/runs/1 FAILURE 1916074
[2020-05-14T16:29:36.710Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18529/runs/1/steps/?limit=10000 -o steps-info.json
[2020-05-14T16:29:40.835Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18529/runs/1/tests/?status=FAILED -o tests-errors.json
[2020-05-14T16:29:40.835Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18529/runs/1/log/ -o pipeline-log.txt

Copy link
Contributor

@michalpristas michalpristas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@blakerouse blakerouse merged commit 06cf975 into elastic:7.x May 14, 2020
@blakerouse blakerouse deleted the backport_18483_7.x branch May 14, 2020 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants