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 #21772 to 7.10: [Elastic Agent] Don't perform install until after enroll #21818

Merged
merged 2 commits into from
Oct 14, 2020

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Oct 14, 2020

Cherry-pick of PR #21772 to 7.10 branch. Original message:

What does this PR do?

This switches the installation to be based on successful enrollment. First agent is installed in the correct location (but is not started), then enrollment is performed. In the case that enrollment fails the installation directory is removed, if enrollment is successful then it starts the persistent service.

This also adds a check to ensure that an Elastic Agent is not already running from the extracted Elastic Agent directory. This is because an already running Elastic Agent in that directory will cause installation to fail because on Windows some of the files will not be able to be opened to be copied to there new location.

Why is it important?

It removes the need to restart an already running Elastic Agent that was just started. It removes the requirement to start Elastic Agent in standalone mode first then switching it to Fleet mode. It helps ensure that installation is only successful when enrollment is successful.

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

* Flip install and enroll.

* Update order.

* Always perform uninstall of service.

* Fix issue with no enrolling.

* Fix enrollment no.

* Add changelog.

(cherry picked from commit 34da9c9)
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 14, 2020
@elasticmachine
Copy link
Collaborator

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

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Oct 14, 2020
@blakerouse blakerouse self-assigned this Oct 14, 2020
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.

Backport looks ok

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

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 #21818 opened]

  • Start Time: 2020-10-14T17:47:40.101+0000

  • Duration: 46 min 23 sec

Test stats 🧪

Test Results
Failed 0
Passed 1390
Skipped 4
Total 1394

@blakerouse blakerouse merged commit dac1282 into elastic:7.10 Oct 14, 2020
@blakerouse blakerouse deleted the backport_21772_7.10 branch October 14, 2020 19:45
@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 #21818 updated]

  • Start Time: 2020-10-14T19:32:41.492+0000

  • Duration: 39 min 48 sec

Test stats 🧪

Test Results
Failed 4
Passed 1368
Skipped 4
Total 1376

Test errors 4

Expand to view the tests failures

  • Name: Build&Test / x-pack/elastic-agent-build / TestFleetGateway – application

    • Age: 1
    • Duration: 0
    • Error Details: Failed
  • Name: Build&Test / x-pack/elastic-agent-build / TestFleetGateway/send_no_event_and_receive_no_action – application

    • Age: 1
    • Duration: 0
    • Error Details: Failed
  • Name: Build&Test / x-pack/elastic-agent-build / TestFleetGateway/Successfully_connects_and_receives_a_series_of_actions – application

    • Age: 1
    • Duration: 0
    • Error Details: Failed
  • Name: Build&Test / x-pack/elastic-agent-build / TestFleetGateway/Periodically_communicates_with_Fleet – application

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

Steps errors 1

Expand to view the steps failures

  • Name: mage build test
    • Description: mage build test

    • Duration: 12 min 57 sec

    • Start Time: 2020-10-14T19:58:20.938+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-10-14T20:10:19.361Z] c1e54eec4b57: Download complete
[2020-10-14T20:10:19.637Z] c1e54eec4b57: Pull complete
[2020-10-14T20:10:19.637Z] Digest: sha256:b733d4a32c4da6a00a84df2ca32791bb03df95400243648d8c539e7b4cce329c
[2020-10-14T20:10:19.637Z] Status: Downloaded newer image for alpine:3.4
[2020-10-14T20:10:21.496Z] + python .ci/scripts/pre_archive_test.py
[2020-10-14T20:10:21.497Z] Copy ./x-pack/elastic-agent/build into build/x-pack/elastic-agent/build
[2020-10-14T20:10:21.516Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21818/src/github.com/elastic/beats/build
[2020-10-14T20:10:22.060Z] + rm -rf ve
[2020-10-14T20:10:22.060Z] + find . -type d -name vendor -exec rm -r {} ;
[2020-10-14T20:10:22.089Z] WARNING: Unknown parameter(s) found for class type 'hudson.tasks.junit.pipeline.JUnitResultsStep': id,stashedTestReports
[2020-10-14T20:10:22.098Z] Recording test results
[2020-10-14T20:10:25.197Z] Stashed 1 file(s)
[2020-10-14T20:10:25.637Z] + tar --version
[2020-10-14T20:10:26.046Z] + tar --exclude=test-build-artifacts-x-pack/elastic-agent-build.tgz -czf test-build-artifacts-x-pack/elastic-agent-build.tgz .
[2020-10-14T20:10:28.798Z] Archiving artifacts
[2020-10-14T20:10:30.653Z] + python .ci/scripts/search_system_tests.py
[2020-10-14T20:10:30.904Z] [INFO] system-tests=''. If no empty then let's create a tarball
[2020-10-14T20:10:31.422Z] Client: Docker Engine - Community
[2020-10-14T20:10:31.422Z]  Version:           19.03.13
[2020-10-14T20:10:31.422Z]  API version:       1.40
[2020-10-14T20:10:31.422Z]  Go version:        go1.13.15
[2020-10-14T20:10:31.422Z]  Git commit:        4484c46d9d
[2020-10-14T20:10:31.422Z]  Built:             Wed Sep 16 17:02:36 2020
[2020-10-14T20:10:31.422Z]  OS/Arch:           linux/amd64
[2020-10-14T20:10:31.422Z]  Experimental:      false
[2020-10-14T20:10:31.422Z] 
[2020-10-14T20:10:31.422Z] Server: Docker Engine - Community
[2020-10-14T20:10:31.422Z]  Engine:
[2020-10-14T20:10:31.422Z]   Version:          19.03.13
[2020-10-14T20:10:31.422Z]   API version:      1.40 (minimum version 1.12)
[2020-10-14T20:10:31.422Z]   Go version:       go1.13.15
[2020-10-14T20:10:31.422Z]   Git commit:       4484c46d9d
[2020-10-14T20:10:31.422Z]   Built:            Wed Sep 16 17:01:06 2020
[2020-10-14T20:10:31.422Z]   OS/Arch:          linux/amd64
[2020-10-14T20:10:31.422Z]   Experimental:     false
[2020-10-14T20:10:31.422Z]  containerd:
[2020-10-14T20:10:31.422Z]   Version:          1.3.7
[2020-10-14T20:10:31.422Z]   GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
[2020-10-14T20:10:31.422Z]  runc:
[2020-10-14T20:10:31.422Z]   Version:          1.0.0-rc10
[2020-10-14T20:10:31.422Z]   GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
[2020-10-14T20:10:31.422Z]  docker-init:
[2020-10-14T20:10:31.422Z]   Version:          0.18.0
[2020-10-14T20:10:31.422Z]   GitCommit:        fec3683
[2020-10-14T20:10:36.220Z] Failed in branch x-pack/elastic-agent-build
[2020-10-14T20:10:41.227Z] [INFO] unstashV2: JOB_GCS_BUCKET is set. bucket param got precedency instead.
[2020-10-14T20:10:41.295Z] [INFO] unstashV2: JOB_GCS_CREDENTIALS is set. credentialsId param got precedency instead.
[2020-10-14T20:10:41.416Z] [Google Cloud Storage Plugin] Found 1 files to download from pattern: gs://beats-ci-temp/Beats/beats/PR-21818-2/source/source.tgz
[2020-10-14T20:10:41.464Z] [Google Cloud Storage Plugin] Downloading: Beats/beats/PR-21818-2/source/source.tgz to local path: /var/lib/jenkins/workspace/Beats_beats_PR-21818/source.tgz
[2020-10-14T20:10:53.787Z] + tar --version
[2020-10-14T20:10:54.842Z] + tar -xpf source.tgz
[2020-10-14T20:11:04.963Z] + rm source.tgz
[2020-10-14T20:11:05.146Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21818/src/github.com/elastic/beats
[2020-10-14T20:11:05.167Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21818/src/github.com/elastic/beats/lint-1602705255426
[2020-10-14T20:11:05.278Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21818/src/github.com/elastic/beats/x-pack-elastic-agent-windows-windows-2019-1602706081244
[2020-10-14T20:11:05.364Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-21818/src/github.com/elastic/beats/x-pack-elastic-agent-build-1602706224664
[2020-10-14T20:11:05.826Z] + cat
[2020-10-14T20:11:05.826Z] + /usr/local/bin/runbld ./runbld-test-reports --job-name elastic+beats+pull-request
[2020-10-14T20:11:05.826Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-10-14T20:11:11.281Z] runbld>>> runbld started
[2020-10-14T20:11:11.281Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-10-14T20:11:13.316Z] runbld>>> The following profiles matched the job 'elastic+beats+pull-request' in order of occurrence in the config (last value wins).
[2020-10-14T20:11:13.316Z] runbld>>> Matches in the system config:
[2020-10-14T20:11:13.316Z] runbld>>> - Matched ^elastic\+beats
[2020-10-14T20:11:13.316Z] runbld>>> - Matched ^elastic\+beats\+pull-request
[2020-10-14T20:11:14.318Z] runbld>>> Debug logging enabled.
[2020-10-14T20:11:14.318Z] runbld>>> Storing result
[2020-10-14T20:11:14.592Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-10-14T20:11:14.592Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20201014201114-A4FB8F2E
[2020-10-14T20:11:14.592Z] runbld>>> Adding system facts.
[2020-10-14T20:11:15.651Z] runbld>>> Adding vcs info for the latest commit:  80615f2c31da3d06eac8be370c376fc83b1086b8
[2020-10-14T20:11:15.651Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-10-14T20:11:15.651Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-10-14T20:11:15.651Z] + echo 'Processing JUnit reports with runbld...'
[2020-10-14T20:11:15.651Z] Processing JUnit reports with runbld...
[2020-10-14T20:11:15.948Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-10-14T20:11:15.948Z] runbld>>> DURATION: 33ms
[2020-10-14T20:11:15.948Z] runbld>>> STDOUT: 40 bytes
[2020-10-14T20:11:15.948Z] runbld>>> STDERR: 49 bytes
[2020-10-14T20:11:15.948Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-10-14T20:11:15.948Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-21818
[2020-10-14T20:11:16.912Z] runbld>>> Storing build metadata: 
[2020-10-14T20:11:16.912Z] runbld>>> Adding test report.
[2020-10-14T20:11:16.912Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-21818/src/github.com/elastic/beats
[2020-10-14T20:11:17.631Z] runbld>>> Found 2 test output files
[2020-10-14T20:11:18.242Z] runbld>>> Test output logs contained: Errors: 0 Failures: 4 Tests: 1376 Skipped: 0
[2020-10-14T20:11:18.242Z] runbld>>> Storing result
[2020-10-14T20:11:18.242Z] runbld>>> FAILURES: 4
[2020-10-14T20:11:19.237Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-10-14T20:11:19.237Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20201014201114-A4FB8F2E
[2020-10-14T20:11:19.517Z] runbld>>> Email notification disabled by environment variable.
[2020-10-14T20:11:19.517Z] runbld>>> Slack notification disabled by environment variable.
[2020-10-14T20:11:28.103Z] Running on worker-395930 in /var/lib/jenkins/workspace/Beats_beats_PR-21818
[2020-10-14T20:11:28.285Z] [INFO] getVaultSecret: Getting secrets
[2020-10-14T20:11:28.445Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-10-14T20:11:30.717Z] + chmod 755 generate-build-data.sh
[2020-10-14T20:11:30.717Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21818/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21818/runs/2 FAILURE 2327673
[2020-10-14T20:11:30.717Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21818/runs/2/steps/?limit=10000 -o steps-info.json
[2020-10-14T20:11:31.440Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21818/runs/2/tests/?status=FAILED -o tests-errors.json
[2020-10-14T20:11:32.922Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21818/runs/2/log/ -o pipeline-log.txt

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