Skip to content

Cherry-pick #20111 to 7.x: [Elastic Agent] Add ability to re-exec agent#20267

Merged
blakerouse merged 1 commit intoelastic:7.xfrom
blakerouse:backport_20111_7.x
Jul 28, 2020
Merged

Cherry-pick #20111 to 7.x: [Elastic Agent] Add ability to re-exec agent#20267
blakerouse merged 1 commit intoelastic:7.xfrom
blakerouse:backport_20111_7.x

Conversation

@blakerouse
Copy link
Copy Markdown
Contributor

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

What does this PR do?

This adds the ability to re-exec Elastic Agent in the same PID and memory address space (on unix) and with in the same service on Windows (not same PID and address space).

This has been tested on Windows using SIGINT and Windows services, but the SIGINT catch is removed in the PR because it cannot be that way truly. Adding a way to perform this on Windows will occur in a follow up branch.

Why is it important?

This is one of the steps to self-upgrading the Elastic Agent. This will also be used to allow reloading of the Elastic Agent when a configuration change that does not automatically get applied through the reloader.

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 (very hard to unit test)
  • [ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • Send signal SIGHUP to process will perform shutdown of the application and the re-exec itself.

How to test this PR locally

Start the elastic-agent then send SIGHUP.

$ ./elastic-agent run &
$ sleep 60
$ kill -HUP $!

* Add ability to reexec on all platforms.

* Get it working on Windows

* Fix on mac.

* Fix vet.

* Update ShutdownChan to be receive only.

(cherry picked from commit 5a37193)
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@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 Jul 28, 2020
@blakerouse blakerouse self-assigned this Jul 28, 2020
Copy link
Copy Markdown
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
Copy Markdown
Contributor

💔 Tests Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20267 opened]

  • Start Time: 2020-07-28T12:21:51.423+0000

  • Duration: 74 min 29 sec

Test stats 🧪

Test Results
Failed 14
Passed 9425
Skipped 1577
Total 11016

Test errors

Expand to view the tests failures

  • Name: Build and Test / Metricbeat OSS Unit tests / test_process – test_system.Test

    • Age: 1
    • Duration: 1.495
    • Error Details: False is not true : fd not found in any process events
  • Name: Build and Test / Auditbeat x-pack / test_connected_udp_ipv4 – test_system_socket.Test

    • Age: 1
    • Duration: 60.095
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_connected_udp_ipv6 – test_system_socket.Test

    • Age: 1
    • Duration: 60.109
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_dns_enrichment – test_system_socket.Test

    • Age: 1
    • Duration: 60.111
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_dns_long_request – test_system_socket.Test

    • Age: 1
    • Duration: 60.11
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_dns_udp_ipv6 – test_system_socket.Test

    • Age: 1
    • Duration: 60.109
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_dns_unidirectional_udp – test_system_socket.Test

    • Age: 1
    • Duration: 60.109
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_multi_udp_upv4 – test_system_socket.Test

    • Age: 1
    • Duration: 60.112
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_no_dns_enrichment – test_system_socket.Test

    • Age: 1
    • Duration: 60.11
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_tcp_ipv4 – test_system_socket.Test

    • Age: 1
    • Duration: 60.104
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_tcp_ipv6_disabled – test_system_socket.Test

    • Age: 1
    • Duration: 60.116
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_udp_ipv4 – test_system_socket.Test

    • Age: 1
    • Duration: 60.109
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_udp_ipv6 – test_system_socket.Test

    • Age: 1
    • Duration: 60.098
    • Error Details: Expected exit code to be 0, but it was 1
  • Name: Build and Test / Auditbeat x-pack / test_udp_ipv6_disabled – test_system_socket.Test

    • Age: 1
    • Duration: 60.113
    • Error Details: Expected exit code to be 0, but it was 1

Steps errors

Expand to view the steps failures

  • Name: Make testsuite

    • Description: make -C filebeat testsuite

    • Duration: 7 min 59 sec

    • Start Time: 2020-07-28T12:47:26.404+0000

    • log

  • Name: Report to Codecov

    • Description: .ci/scripts/report-codecov.sh auditbeat filebeat heartbeat journalbeat libbeat metricbeat packetbeat winlogbeat

    • Duration: 1 min 27 sec

    • Start Time: 2020-07-28T13:01:23.782+0000

    • log

  • Name: Mage update build test

    • Description: mage update build test

    • Duration: 22 min 1 sec

    • Start Time: 2020-07-28T12:47:30.322+0000

    • log

  • Name: Report to Codecov

    • Description: .ci/scripts/report-codecov.sh auditbeat filebeat heartbeat journalbeat libbeat metricbeat packetbeat winlogbeat

    • Duration: 1 min 27 sec

    • Start Time: 2020-07-28T12:55:22.983+0000

    • log

  • Name: Make testsuite

    • Description: make -C libbeat testsuite

    • Duration: 33 min 48 sec

    • Start Time: 2020-07-28T12:47:43.846+0000

    • log

  • Name: Mage build unitTest

    • Description: mage build unitTest

    • Duration: 9 min 0 sec

    • Start Time: 2020-07-28T12:47:35.559+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-07-28T13:35:23.068Z]  Git commit:        e68fc7a
[2020-07-28T13:35:23.068Z]  Built:             Tue Aug 21 17:21:31 2018
[2020-07-28T13:35:23.068Z]  OS/Arch:           darwin/amd64
[2020-07-28T13:35:23.068Z]  Experimental:      false
[2020-07-28T13:35:23.068Z] Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[2020-07-28T13:35:23.068Z] It requires Docker daemon to be installed and running
[2020-07-28T13:35:44.186Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats
[2020-07-28T13:35:44.528Z] + find . -type f -name TEST*.xml -path */build/* -delete
[2020-07-28T13:35:44.555Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Lint
[2020-07-28T13:35:44.745Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Winlogbeat-oss
[2020-07-28T13:35:44.936Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-07-28T13:35:45.116Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Auditbeat-crosscompile
[2020-07-28T13:35:45.281Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Dockerlogbeat
[2020-07-28T13:35:45.459Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Journalbeat-oss
[2020-07-28T13:35:45.634Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Generators-Metricbeat-Linux
[2020-07-28T13:35:45.813Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Elastic-Agent-Mac-OS-X
[2020-07-28T13:35:45.975Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-07-28T13:35:46.148Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-07-28T13:35:46.305Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Filebeat-oss
[2020-07-28T13:35:46.454Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Auditbeat-oss-Mac-OS-X
[2020-07-28T13:35:46.623Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Auditbeat-x-pack-Mac-OS-X
[2020-07-28T13:35:46.769Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-OSS-Unit-tests
[2020-07-28T13:35:46.928Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Filebeat-Mac-OS-X
[2020-07-28T13:35:47.098Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Auditbeat-oss-Windows
[2020-07-28T13:35:47.259Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Heartbeat-oss
[2020-07-28T13:35:47.422Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-07-28T13:35:47.580Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-crosscompile
[2020-07-28T13:35:47.735Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-07-28T13:35:47.897Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Libbeat-x-pack
[2020-07-28T13:35:48.065Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Filebeat-Windows
[2020-07-28T13:35:48.241Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-Mac-OS-X
[2020-07-28T13:35:48.393Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Filebeat-x-pack-Mac-OS-X
[2020-07-28T13:35:48.551Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-07-28T13:35:48.706Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-x-pack-Mac-OS-X
[2020-07-28T13:35:48.856Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Auditbeat-oss-Linux
[2020-07-28T13:35:49.009Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Winlogbeat-Windows
[2020-07-28T13:35:49.162Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Heartbeat-Mac-OS-X
[2020-07-28T13:35:49.318Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Functionbeat-Mac-OS-X-x-pack
[2020-07-28T13:35:49.464Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-Windows
[2020-07-28T13:35:49.615Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Packetbeat-oss
[2020-07-28T13:35:49.762Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-07-28T13:35:49.911Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Generators-Beat-Linux
[2020-07-28T13:35:50.057Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-07-28T13:35:50.273Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Heartbeat-Windows
[2020-07-28T13:35:50.459Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Filebeat-x-pack
[2020-07-28T13:35:50.636Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Libbeat-oss
[2020-07-28T13:35:50.835Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Functionbeat-Windows
[2020-07-28T13:35:51.321Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-Python-integration-tests
[2020-07-28T13:35:51.660Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests
[2020-07-28T13:35:52.029Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Generators-Metricbeat-Mac-OS-X
[2020-07-28T13:35:52.361Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-07-28T13:35:52.781Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Generators-Beat-Mac-OS-X
[2020-07-28T13:35:53.484Z] + cat
[2020-07-28T13:35:53.484Z] + /usr/local/bin/runbld ./runbld-script
[2020-07-28T13:35:53.484Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-07-28T13:36:00.093Z] runbld>>> runbld started
[2020-07-28T13:36:00.093Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-07-28T13:36:02.637Z] runbld>>> The following profiles matched the job 'Beats/beats/PR-20267' in order of occurrence in the config (last value wins).
[2020-07-28T13:36:03.579Z] runbld>>> Debug logging enabled.
[2020-07-28T13:36:03.579Z] runbld>>> Storing result
[2020-07-28T13:36:03.846Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-07-28T13:36:03.846Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200728133603-6B326BC5
[2020-07-28T13:36:03.846Z] runbld>>> Adding system facts.
[2020-07-28T13:36:05.233Z] runbld>>> Adding vcs info for the latest commit:  700fb2296d0fca36724086361237fbb688cd5fd1
[2020-07-28T13:36:05.233Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-07-28T13:36:05.233Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-07-28T13:36:05.233Z] Processing JUnit reports with runbld...
[2020-07-28T13:36:05.233Z] + echo 'Processing JUnit reports with runbld...'
[2020-07-28T13:36:05.495Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-07-28T13:36:05.495Z] runbld>>> DURATION: 20ms
[2020-07-28T13:36:05.495Z] runbld>>> STDOUT: 40 bytes
[2020-07-28T13:36:05.495Z] runbld>>> STDERR: 49 bytes
[2020-07-28T13:36:05.495Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-07-28T13:36:05.495Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats
[2020-07-28T13:36:06.436Z] runbld>>> Storing build metadata: 
[2020-07-28T13:36:06.436Z] runbld>>> Adding test report.
[2020-07-28T13:36:06.436Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats
[2020-07-28T13:36:07.391Z] runbld>>> Found 113 test output files
[2020-07-28T13:36:07.966Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-07-28T13:36:07.966Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-07-28T13:36:07.966Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-07-28T13:36:07.966Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-07-28T13:36:08.229Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-07-28T13:36:08.489Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests/metricbeat/build/TEST-go-integration-graphite.xml
[2020-07-28T13:36:08.489Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20267/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests/metricbeat/build/TEST-go-integration-windows.xml
[2020-07-28T13:36:09.873Z] runbld>>> Test output logs contained: Errors: 0 Failures: 14 Tests: 10870 Skipped: 1340
[2020-07-28T13:36:09.873Z] runbld>>> Storing result
[2020-07-28T13:36:09.873Z] runbld>>> FAILURES: 14
[2020-07-28T13:36:13.170Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-07-28T13:36:13.171Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200728133603-6B326BC5
[2020-07-28T13:36:13.171Z] runbld>>> Email notification disabled by environment variable.
[2020-07-28T13:36:13.171Z] runbld>>> Slack notification disabled by environment variable.
[2020-07-28T13:36:19.107Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-20267
[2020-07-28T13:36:19.493Z] [INFO] getVaultSecret: Getting secrets
[2020-07-28T13:36:19.632Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-07-28T13:36:21.160Z] + chmod 755 generate-build-data.sh
[2020-07-28T13:36:21.160Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20267/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20267/runs/1 FAILURE 4469462
[2020-07-28T13:36:21.160Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20267/runs/1/steps/?limit=10000 -o steps-info.json
[2020-07-28T13:36:23.660Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20267/runs/1/tests/?status=FAILED -o tests-errors.json
[2020-07-28T13:36:24.211Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20267/runs/1/log/ -o pipeline-log.txt

@blakerouse blakerouse merged commit 64df4de into elastic:7.x Jul 28, 2020
@blakerouse blakerouse deleted the backport_20111_7.x branch July 28, 2020 13:45
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