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] Support the install, control, and uninstall of Endpoint #19248

Merged
merged 42 commits into from
Jun 29, 2020

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Jun 17, 2020

What does this PR do?

Adds the ability to install and uninstall Endpoint.

Adds new exec_file to the transpiler.StepList so file execution can be defined in a spec file. This allows the endpoint.spec file to encode all the actions required to install, check if installed, and uninstall Endpoint.

pre_uninstall steps added to the spec file and new uninstall-operation was added to perform uninstallation of applications.

check_install steps added to the spec file along with a new InstallerChecker that handles checking if the installation steps need to be ran.

Breakdown of the installation:

  1. Download endpoint (doesn't work yet, must be present in data/downloads, in a custom format until the required changes are released on Endpoint side)
  2. Verify endpoint
  3. Check if endpoint install under data/install exists, if it does call ./endpoint-security verify which will verify if its installed. If it returns 0 then it will skip install, as its already installed. (Currently this command doesn't exist, so it will always return non-zero, so installation is always performed. Once added it will just work!)
  4. If needs install, extract endpoint to data/install, then exec ./endpoint-security install --upgrade --resources endpoint-security-resources.zip
  5. Register endpoint with the GRPC server and start the v0 connection information socket.
  6. Endpoint is running!

Breakdown of the uninstallation:

  1. Send stop over GRPC to endpoint (Not currently connected, so times out after 30 seconds).
  2. Run the ./endpoint-security uninstall command from the PreUninstallSteps.
  3. Endpoint is uninstalled!

Why is it important?

To support Endpoint.

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.

@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 Jun 17, 2020
@blakerouse blakerouse marked this pull request as ready for review June 17, 2020 14:11
@elasticmachine
Copy link
Collaborator

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

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 17, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #19248 updated]

  • Start Time: 2020-06-26T20:00:36.715+0000

  • Duration: 34 min 12 sec

Test stats 🧪

Test Results
Failed 0
Passed 540
Skipped 127
Total 667

@@ -175,6 +179,7 @@ func (o *Operator) start(p Descriptor, cfg map[string]interface{}) (err error) {
func (o *Operator) stop(p Descriptor) (err error) {
flow := []operation{
newOperationStop(o.logger, o.config),
newOperationUninstall(o.logger, p, o.uninstaller),
Copy link
Contributor

Choose a reason for hiding this comment

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

what in case of multiple outputs running, you have metricbeat A and B A is stopped and uninstalled? it is the same binary as metricbeat for output B

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that even the case today? When looping with detectPrograms it only loops through the Supported programs once, creating an array. So only 1 metricbeat will be running.

The only case where that is not true with the sidecars for metrics and logs of the running metricbeat and filebeat.

At the moment uninstall doesn't do anything, other than call the pre_uninstall hooks. So this will not cause an issues currently.

@michalpristas
Copy link
Contributor

can you provide a guide for testing this?

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.

it makes sense to me, code looks good, but i havent tested it locally

@@ -21,13 +21,13 @@ import (

// defaultAgentConfigFile is a name of file used to store agent information
const defaultAgentConfigFile = "fleet.yml"
const agentInfoKey = "agent_info"
const agentInfoKey = "agent"
Copy link
Contributor

Choose a reason for hiding this comment

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

note: this is breaking between 7.8 and 7.9 so maybe we should put a note that agent might change ID in between versions when updating from 7.8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we just handle it? support reading it with either agent_info or agent?

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets document it, breaking changes are ok from 7.8->7.9

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #19488 that handles it transparently, or we can just document. I prefer to just handle it, but okay with breaking.

}

// timeout defaults to 60 seconds
if r.Timeout == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we take that to a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

comment where?

@blakerouse blakerouse merged commit 0fe1554 into elastic:master Jun 29, 2020
@blakerouse
Copy link
Contributor Author

Went ahead and merged this, wanting to get it into 7.x ASAP so we can get some real testing from the snapshot builds, which should allow Agent to download Endpoint directly from the artifact store.

Working on a follow up for the agent_info I think we can support that out of the box, instead of breaking upgrade.

@blakerouse blakerouse deleted the agent-endpoint-install branch June 29, 2020 17:58
blakerouse added a commit to blakerouse/beats that referenced this pull request Jun 29, 2020
…nt (elastic#19248)

* Initial spec parsing for endpoint.

* Update comment.

* Fix spec test.

* Update code so it copies the entire input.

* Fix ast test.

* Merge agent-improve-restart-loop

* Merge agent-endpoint-spec

* Refactor core/plugin/app into mostly core/ and use core/plugin for different app types.

* Work on endpoint service application.

* More fixes.

* Fix format and tests.

* Fix some imports.

* More cleanups.

* Fix export comment.

* Pass the program.Spec into the descriptor.

* Run endpoint verify, install, and uninstall when endpoint should be running.

* Fix install and uninstall of Endpoint

* Fix some small issues with service app.

* Add changelog entry.

* Fix lint and tests.

* Fix lint.

* Remove the code no longer needed because of newer config format.

* Fix rules and review.

* Update to Endpoint Security.

* Fix issues so endpoint security runs.

* Add comments.

* Update docstring.

* Some more fixes.

* Delete the extra endpoint testdata files.

* Add timeout to exec_file step.

* Fix supported map.

* Fix getting support programs by cmd.

* Improve app started checks.

* Fix buildspec.

(cherry picked from commit 0fe1554)
blakerouse added a commit that referenced this pull request Jun 29, 2020
…nt (#19248) (#19497)

* Initial spec parsing for endpoint.

* Update comment.

* Fix spec test.

* Update code so it copies the entire input.

* Fix ast test.

* Merge agent-improve-restart-loop

* Merge agent-endpoint-spec

* Refactor core/plugin/app into mostly core/ and use core/plugin for different app types.

* Work on endpoint service application.

* More fixes.

* Fix format and tests.

* Fix some imports.

* More cleanups.

* Fix export comment.

* Pass the program.Spec into the descriptor.

* Run endpoint verify, install, and uninstall when endpoint should be running.

* Fix install and uninstall of Endpoint

* Fix some small issues with service app.

* Add changelog entry.

* Fix lint and tests.

* Fix lint.

* Remove the code no longer needed because of newer config format.

* Fix rules and review.

* Update to Endpoint Security.

* Fix issues so endpoint security runs.

* Add comments.

* Update docstring.

* Some more fixes.

* Delete the extra endpoint testdata files.

* Add timeout to exec_file step.

* Fix supported map.

* Fix getting support programs by cmd.

* Improve app started checks.

* Fix buildspec.

(cherry picked from commit 0fe1554)
v1v added a commit to v1v/beats that referenced this pull request Jul 2, 2020
…ne-beats

* upstream/master: (105 commits)
  ci: enable packaging job (elastic#19536)
  ci: disable upstream trigger on PRs for the packaging job (elastic#19490)
  Implement memlog on-disk handling (elastic#19408)
  fix go.mod for PR elastic#19423 (elastic#19521)
  [MetricBeat] add param `aws_partition` to support aws-cn, aws-us-gov regions (elastic#19423)
  Input v2 stateless manager (elastic#19406)
  Input v2 compatibility layer (elastic#19401)
  [Elastic Agent] Fix artifact downloading to allow endpoint-security to be downloaded (elastic#19503)
  fix: ignore target changes on scans (elastic#19510)
  Add more helpers to pipeline/testing package (elastic#19405)
  Report dependencies in CSV format (elastic#19506)
  [Filebeat] Fix reference leak in TCP and Unix socket inputs (elastic#19459)
  Cursor input skeleton (elastic#19378)
  Add changelog. (elastic#19495)
  [DOC] Typo in Kerberos (elastic#19265)
  Remove accidentally commited unused NOTICE template (elastic#19485)
  [Elastic Agent] Support the install, control, and uninstall of Endpoint (elastic#19248)
  [Filebeat][httpjson] Add split_events_by config setting (elastic#19246)
  ci: disabling packaging job until we fix it (elastic#19481)
  Fix golang.org/x/tools to release1.13 (elastic#19478)
  ...
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
…nt (elastic#19248)

* Initial spec parsing for endpoint.

* Update comment.

* Fix spec test.

* Update code so it copies the entire input.

* Fix ast test.

* Merge agent-improve-restart-loop

* Merge agent-endpoint-spec

* Refactor core/plugin/app into mostly core/ and use core/plugin for different app types.

* Work on endpoint service application.

* More fixes.

* Fix format and tests.

* Fix some imports.

* More cleanups.

* Fix export comment.

* Pass the program.Spec into the descriptor.

* Run endpoint verify, install, and uninstall when endpoint should be running.

* Fix install and uninstall of Endpoint

* Fix some small issues with service app.

* Add changelog entry.

* Fix lint and tests.

* Fix lint.

* Remove the code no longer needed because of newer config format.

* Fix rules and review.

* Update to Endpoint Security.

* Fix issues so endpoint security runs.

* Add comments.

* Update docstring.

* Some more fixes.

* Delete the extra endpoint testdata files.

* Add timeout to exec_file step.

* Fix supported map.

* Fix getting support programs by cmd.

* Improve app started checks.

* Fix buildspec.
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.

5 participants