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

[Elastic Agent] Add skeleton for client/server for agent control protocol #20163

Merged
merged 9 commits into from
Jul 30, 2020

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Jul 22, 2020

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

@elasticmachine
Copy link
Collaborator

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 22, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 22, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20163 updated]

  • Start Time: 2020-07-28T14:23:44.932+0000

  • Duration: 79 min 49 sec

@blakerouse
Copy link
Contributor Author

Rebased with master after #20146 has been merged, this is ready for a review.

// Address returns the address to connect to Elastic Agent daemon.
func Address() string {
data = paths.Data()
return fmt.Sprintf(`\\.\pipe\elastic-agent-%s`, sha256.Sum256(data))
Copy link
Contributor

Choose a reason for hiding this comment

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

careful with the length here, i think it should be fine with 64b for sha256 but maybe a comment/reminder in case somebody wants to change format would be handy

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.

overall it looks good, do you have some auth strategy in mind?

s := &AgentStatus{
Status: res.Status,
Message: res.Message,
Applications: make([]*ApplicationStatus, 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit, we know the length of res.Applications we can set the capacity right

if err != nil {
return nil, err
}
sd, err := npipe.DefaultSD(u.Username)
Copy link
Contributor

Choose a reason for hiding this comment

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

is Default secure enough? we dont want to allow anybody trigger restart/stop/upgrade procedures, need to think about that for future releases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The DefaultSD creates the pipe so only that specific user can access it. So we get the same level of permissions we have on the configuration files.

@ph
Copy link
Contributor

ph commented Jul 30, 2020

@michalpristas @blakerouse Not sure we need auth, I think OS' ACL would take care of that?

@blakerouse
Copy link
Contributor Author

@ph correct the OS ACL's is going to take care of it

@blakerouse blakerouse merged commit 77a8472 into elastic:master Jul 30, 2020
@blakerouse blakerouse deleted the agent-control-version branch July 30, 2020 15:33
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20163 updated]

  • Start Time: 2020-07-30T14:45:51.911+0000

  • Duration: 52 min 1 sec

v1v added a commit to v1v/beats that referenced this pull request Jul 30, 2020
…ne-2.0

* upstream/master:
  [Elastic Agent] Add skeleton for client/server for agent control protocol (elastic#20163)
  Auditbeat: Allow multiple instances by grouping kprobes by PID (elastic#20325)
  [Filebeat][Fortinet] Remove pre populated event.timezone (elastic#20273)
v1v added a commit to v1v/beats that referenced this pull request Jul 31, 2020
…allation

* upstream/master:
  Check expand_event_list_from_field when json in map[string]interface{} format (elastic#20370)
  [docs] Remove deprecated security roles (elastic#20162)
  Modify doc in app_insights metricset (elastic#20185)
  [Elastic Agent] Add skeleton for client/server for agent control protocol (elastic#20163)
  Auditbeat: Allow multiple instances by grouping kprobes by PID (elastic#20325)
  [Filebeat][Fortinet] Remove pre populated event.timezone (elastic#20273)
  Add an explicit system test for processes on unix systems (elastic#20320)
blakerouse added a commit to blakerouse/beats that referenced this pull request Aug 3, 2020
…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)
blakerouse added a commit that referenced this pull request Aug 4, 2020
…ocol (#20163) (#20401)

* 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)
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants