This repository was archived by the owner on Sep 17, 2024. It is now read-only.
feat: support installing the agent with TAR installer and the install subcommand#378
Merged
mdelapenya merged 43 commits intoelastic:masterfrom Oct 21, 2020
Merged
Conversation
We refactored the installer install actions to delegate the execution to the installer instead of running it in the tests. We also added the new steps for the commands feature.
The life cycle (preInstall > install > enroll > postInstall) depends on the installer: - TAR leverages preInstall phase to extract the TAR file and create the proper layout - RPM and DEB leverage install phase to use package managers to install the artifact - TAR leverages install phase to actually install and enroll the agent - RPM and DEP needs an extra enrollment call - TAR defines an enroll method to be used outside the life cycle - RPM and DEB leverages postInstall phase to enable and run the service using systemd
| } | ||
| return nil | ||
| } | ||
| enrollFn := func(token string) error { |
Contributor
There was a problem hiding this comment.
enroll is performed out of the box using install so this should not be necessary
Contributor
Author
There was a problem hiding this comment.
If you take a look, we are providing the enroll command for further usage in the re-enroll scenario. As defined in the life cycle (see PR description), we use install command to initial enroll, but enroll for following ones
mdelapenya
commented
Oct 21, 2020
| } | ||
| } | ||
|
|
||
| // createFleetPolicy() sends a POST request to Fleet creating a new test policy |
Contributor
Author
There was a problem hiding this comment.
We are not creating the policy because of elastic/kibana#81236
Contributor
🐛 Flaky test report❕ There are test failures but not known flaky tests. Test stats 🧪
|
Contributor
mdelapenya
commented
Oct 21, 2020
| And the "metricbeat" process is in the "stopped" state on the host | ||
| And the file system Agent folder is empty | ||
| And the agent is listed in Fleet as "inactive" | ||
| And the agent is listed in Fleet as "offline" |
Contributor
Author
There was a problem hiding this comment.
It takes +2 minutes in reaching the offline status. Is that correct?
cachedout
approved these changes
Oct 21, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds the the TAR installer so that it's possible to install the agent from a TAR file. For that, we had to define a proper life cycle for agent commands (install, enroll), as depending on the installer type (RPM, DEB, TAR), the life cycle (preInstall > install > enroll > postInstall) depends on the installer:
preInstall:
TARleverages preInstall phase to extract the TAR file and create the proper layoutinstall:
RPMandDEBleverage install phase to use package managers to install the artifactTARleverages install phase to actually install and enroll the agentenroll:
RPMandDEPneeds an extra enrollment callTARdefines an enroll method to be used outside the lifepostInstall:
RPMandDEBleverages postInstall phase to enable and run the service using systemdThis PR also refactors the scenarios (feature files) merging the subcommand feature file with Fleet one. In these files, and for the sake of a green CI build, we are removing any interaction with the RPM and DEB installers, because we prefer the TAR install process. We could at any time turn them back as Outline examples in Gherkin:
Why is it important?
The first main thing is that the PR matches the e2e tests code with the Elastic Agent way of installing the agent, which is critical. The second thing, the tests pass locally and we expect to fix the tests on CI too.
Checklist
make noticein the proper directory)How to test this PR locally
SUITE=fleet TAGS="fleet_mode" DEVELOPER_MODE=false TIMEOUT_FACTOR=3 LOG_LEVEL=TRACE make -C e2e functional-testRelated issues
Follow-ups
The test for uninstalling the agent is failing. Need to check. I pushed the PR to receive feedback from the team.
We could refactor the download of the agents and add it when installing the agent instead of at the beginning of the test suite. Why? Because we download them at that time to create a volume and mount it into the container, at startup. This is causing that, when running the tests in DEV mode (DEVELOPER_MODE=true) locally, where the services are not destroyed, docker-compose tries to reuse the service without recreating it (we are not using the
--force-recreateoption). Therefore, that installer is already there and could lead to unexpected errors because of garbage in the target container for the agent.