Skip to content

Cherry-pick #20163 to 7.x: [Elastic Agent] Add skeleton for client/server for agent control protocol#20401

Merged
blakerouse merged 1 commit intoelastic:7.xfrom
blakerouse:backport_20163_7.x
Aug 4, 2020
Merged

Cherry-pick #20163 to 7.x: [Elastic Agent] Add skeleton for client/server for agent control protocol#20401
blakerouse merged 1 commit intoelastic:7.xfrom
blakerouse:backport_20163_7.x

Conversation

@blakerouse
Copy link
Copy Markdown
Contributor

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

What does this PR do?

Adds the required skeleton code to allow Elastic Agent to connect and receive information from a running Elastic Agent daemon. Includes the implementation for Version along with a test to ensure that client/server communication works.

Why is it important?

So elastic-agent {subcommands} can talk to the running daemon.

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

…ocol (elastic#20163)

* Add protocl to control Elastic Agent.

* Fix CI with protoc.

* Remove CI changes.

* Start on the control server code.

* More client/server work.

* More work.

* Add test.

* Fix vet issues.

* Fix permissions on unix socket. Add comment to Windows npipe.

(cherry picked from commit 77a8472)
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Aug 3, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Aug 3, 2020
@blakerouse blakerouse self-assigned this Aug 3, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20401 opened]

  • Start Time: 2020-08-03T13:58:21.056+0000

  • Duration: 33 min 22 sec

Steps errors

Expand to view the steps failures

  • Name: Mage build unitTest
    • Description: mage build unitTest

    • Duration: 3 min 9 sec

    • Start Time: 2020-08-03T14:28:06.631+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-08-03T14:31:15.867Z]         --- PASS: TestScheduler/PeriodicJitter_scheduler/multiple_ticks (0.17s)
[2020-08-03T14:31:15.867Z]         --- PASS: TestScheduler/PeriodicJitter_scheduler/unblock_on_first_tick (0.50s)
[2020-08-03T14:31:15.867Z]         --- PASS: TestScheduler/PeriodicJitter_scheduler/unblock_on_any_tick (1.68s)
[2020-08-03T14:31:15.867Z] PASS
[2020-08-03T14:31:15.867Z] coverage: 100.0% of statements
[2020-08-03T14:31:15.867Z] ok  	github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/scheduler	11.575s	coverage: 100.0% of statements
[2020-08-03T14:31:15.867Z] === RUN   TestSet
[2020-08-03T14:31:15.867Z] === RUN   TestSet/adding_items_and_keep_it_ordered
[2020-08-03T14:31:15.867Z] === RUN   TestSet/order_is_preserved_when_items_are_removed
[2020-08-03T14:31:15.867Z] === RUN   TestSet/return_true_when_the_key_exist
[2020-08-03T14:31:15.867Z] === RUN   TestSet/return_false_when_the_key_dont_exist
[2020-08-03T14:31:15.867Z] === RUN   TestSet/return_false_when_the_key_dont_exist#01
[2020-08-03T14:31:15.867Z] === RUN   TestSet/can_remove_the_last_item
[2020-08-03T14:31:15.867Z] === RUN   TestSet/can_remove_the_only_item
[2020-08-03T14:31:15.867Z] === RUN   TestSet/can_remove_multiple_items
[2020-08-03T14:31:15.867Z] === RUN   TestSet/make_sure_keys()_returns_a_copy
[2020-08-03T14:31:15.867Z] --- PASS: TestSet (0.00s)
[2020-08-03T14:31:15.867Z]     --- PASS: TestSet/adding_items_and_keep_it_ordered (0.00s)
[2020-08-03T14:31:15.867Z]     --- PASS: TestSet/order_is_preserved_when_items_are_removed (0.00s)
[2020-08-03T14:31:15.867Z]     --- PASS: TestSet/return_true_when_the_key_exist (0.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestSet/return_false_when_the_key_dont_exist (0.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestSet/return_false_when_the_key_dont_exist#01 (0.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestSet/can_remove_the_last_item (0.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestSet/can_remove_the_only_item (0.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestSet/can_remove_multiple_items (0.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestSet/make_sure_keys()_returns_a_copy (0.00s)
[2020-08-03T14:31:15.868Z] PASS
[2020-08-03T14:31:15.868Z] coverage: 100.0% of statements
[2020-08-03T14:31:15.868Z] ok  	github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/sorted	1.148s	coverage: 100.0% of statements
[2020-08-03T14:31:15.868Z] === RUN   TestTokenBucket
[2020-08-03T14:31:15.868Z] === RUN   TestTokenBucket/when_way_below_the_bucket_size_it_should_not_block
[2020-08-03T14:31:15.868Z] === RUN   TestTokenBucket/when_below_the_bucket_size_it_should_not_block
[2020-08-03T14:31:15.868Z] === RUN   TestTokenBucket/when_we_hit_the_bucket_size_it_should_block
[2020-08-03T14:31:15.868Z] === RUN   TestTokenBucket/When_we_use_a_timer_scheduler_we_can_unblock
[2020-08-03T14:31:15.868Z] --- PASS: TestTokenBucket (2.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestTokenBucket/when_way_below_the_bucket_size_it_should_not_block (0.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestTokenBucket/when_below_the_bucket_size_it_should_not_block (0.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestTokenBucket/when_we_hit_the_bucket_size_it_should_block (2.00s)
[2020-08-03T14:31:15.868Z]     --- PASS: TestTokenBucket/When_we_use_a_timer_scheduler_we_can_unblock (0.00s)
[2020-08-03T14:31:15.868Z] PASS
[2020-08-03T14:31:15.868Z] coverage: 64.7% of statements
[2020-08-03T14:31:15.868Z] ok  	github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/tokenbucket	3.130s	coverage: 64.7% of statements
[2020-08-03T14:31:15.868Z] Error: running "go test -race -v -coverprofile build\coverage.out ./..." failed with exit code 2
[2020-08-03T14:31:16.348Z] 
[2020-08-03T14:31:16.348Z] C:\Users\jenkins\workspace\Beats_beats_PR-20401\src\github.com\elastic\beats>python .ci/scripts/pre_archive_test.py 
[2020-08-03T14:31:16.607Z] Copy .\x-pack\elastic-agent\build into build\x-pack\elastic-agent\build
[2020-08-03T14:31:16.629Z] Running in C:\Users\jenkins\workspace\Beats_beats_PR-20401\src\github.com\elastic\beats\build
[2020-08-03T14:31:16.680Z] Recording test results
[2020-08-03T14:31:17.164Z] None of the test reports contained any result
[2020-08-03T14:31:17.313Z] Stashed 0 file(s)
[2020-08-03T14:31:17.332Z] Archiving artifacts
[2020-08-03T14:31:17.398Z] ‘**\build\TEST*.out’ doesn’t match anything: ‘**’ exists but not ‘**\build\TEST*.out’
[2020-08-03T14:31:17.398Z] No artifacts found that match the file pattern "**\build\TEST*.out". Configuration error?
[2020-08-03T14:31:17.903Z] [INFO] system-tests=''. If no empty then let's create a tarball
[2020-08-03T14:31:19.524Z] Failed in branch Elastic Agent x-pack Windows
[2020-08-03T14:31:21.333Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20401/src/github.com/elastic/beats
[2020-08-03T14:31:21.675Z] + find . -type f -name TEST*.xml -path */build/* -delete
[2020-08-03T14:31:21.699Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20401/src/github.com/elastic/beats/Lint
[2020-08-03T14:31:21.869Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20401/src/github.com/elastic/beats/Elastic-Agent-Mac-OS-X
[2020-08-03T14:31:22.024Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20401/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-08-03T14:31:22.183Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20401/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-08-03T14:31:22.629Z] + cat
[2020-08-03T14:31:22.630Z] + /usr/local/bin/runbld ./runbld-script
[2020-08-03T14:31:22.630Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-08-03T14:31:29.223Z] runbld>>> runbld started
[2020-08-03T14:31:29.224Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-08-03T14:31:31.140Z] runbld>>> The following profiles matched the job 'Beats/beats/PR-20401' in order of occurrence in the config (last value wins).
[2020-08-03T14:31:32.082Z] runbld>>> Debug logging enabled.
[2020-08-03T14:31:32.082Z] runbld>>> Storing result
[2020-08-03T14:31:32.344Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-08-03T14:31:32.344Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200803143131-1A2B7D91
[2020-08-03T14:31:32.344Z] runbld>>> Adding system facts.
[2020-08-03T14:31:33.733Z] runbld>>> Adding vcs info for the latest commit:  8441ea9950a9e6df3b10a08117f9e04a068e6c57
[2020-08-03T14:31:33.733Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-08-03T14:31:33.733Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-08-03T14:31:33.733Z] + echo 'Processing JUnit reports with runbld...'
[2020-08-03T14:31:33.733Z] Processing JUnit reports with runbld...
[2020-08-03T14:31:33.994Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-08-03T14:31:33.994Z] runbld>>> DURATION: 43ms
[2020-08-03T14:31:33.994Z] runbld>>> STDOUT: 40 bytes
[2020-08-03T14:31:33.994Z] runbld>>> STDERR: 49 bytes
[2020-08-03T14:31:33.994Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-08-03T14:31:33.994Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-20401/src/github.com/elastic/beats
[2020-08-03T14:31:34.935Z] runbld>>> Storing build metadata: 
[2020-08-03T14:31:34.936Z] runbld>>> Adding test report.
[2020-08-03T14:31:34.936Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-20401/src/github.com/elastic/beats
[2020-08-03T14:31:35.507Z] runbld>>> Found 0 test output files
[2020-08-03T14:31:35.507Z] runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 0 Skipped: 0
[2020-08-03T14:31:35.767Z] runbld>>> Storing result
[2020-08-03T14:31:36.028Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-08-03T14:31:36.028Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200803143131-1A2B7D91
[2020-08-03T14:31:36.028Z] runbld>>> Email notification disabled by environment variable.
[2020-08-03T14:31:36.028Z] runbld>>> Slack notification disabled by environment variable.
[2020-08-03T14:31:41.691Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-20401
[2020-08-03T14:31:41.877Z] [INFO] getVaultSecret: Getting secrets
[2020-08-03T14:31:41.963Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-08-03T14:31:43.175Z] + chmod 755 generate-build-data.sh
[2020-08-03T14:31:43.175Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20401/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20401/runs/1 FAILURE 2001843
[2020-08-03T14:31:43.175Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20401/runs/1/steps/?limit=10000 -o steps-info.json
[2020-08-03T14:31:43.726Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20401/runs/1/tests/?status=FAILED -o tests-errors.json

@blakerouse
Copy link
Copy Markdown
Contributor Author

The Windows failure is known, for this cherry-pick PR. The next cherry-pick PR that follows this, fixes that failure.

// Address returns the address to connect to Elastic Agent daemon.
func Address() string {
data := paths.Data()
return fmt.Sprintf("unix://%s", filepath.Join(data, "agent.sock"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you cherry pick #20426 into this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The control server isn't started in this PR. The cherry-pick after this PR actually starts the control server, I will place the #20426 into that cherry-pick to 7.x.

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.

looks good

@blakerouse blakerouse merged commit 5a81194 into elastic:7.x Aug 4, 2020
@blakerouse blakerouse deleted the backport_20163_7.x branch August 4, 2020 14:32
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