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

modify runtime variable 'install.in_default' with rpm/deb #3309

Merged
merged 2 commits into from
Aug 29, 2023

Conversation

leehinman
Copy link
Contributor

What does this PR do?

changes how the install.in_default runtime protection variable is calculated on systems where elastic-agent is installed via deb or rpm package. Previously this would have returned false be cause the install path is not the same as the tar.gz install. However, endpoint knows how to operate when elastic-agent is installed as a deb or rpm, so now it will return true.

Why is it important?

This is required because the runtime prevention was blocking the install of endpoint on systems installed via deb/rpm.

example:

sudo elastic-agent status
┌─ fleet
│  └─ status: (HEALTHY) Connected
└─ elastic-agent
   ├─ status: (DEGRADED) 1 or more components/units in a failed state
   └─ endpoint-default
      ├─ status: (FAILED) Elastic Defend requires Elastic Agent be installed at the default installation path
      ├─ endpoint-default
      │  └─ status: (FAILED) Elastic Defend requires Elastic Agent be installed at the default installation path
      └─ endpoint-default-3575ea0b-e4a5-4b6d-b95e-a1ec04cb1683
         └─ status: (FAILED) Elastic Defend requires Elastic Agent be installed at the default installation path

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/fragments using the changelog tool
  • I have added an integration test or an E2E test

Author's Checklist

  • [ ]

How to test this PR locally

  1. Debian or RPM system
  2. Stack version 8.10.0
  3. default version of elastic-agent 8.10.0
  4. build custom version of elastic-agent off this PR, but change version to 8.10.0
  5. create a policy with system and endpoint integrations
  6. install default elastic-agent, should get error message above
  7. uninstall elastic-agent
  8. install custom elastic-agent, no error, agent should be healthy and endpoint sending data

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@leehinman leehinman added bug Something isn't working backport-v8.10.0 Automated backport with mergify labels Aug 29, 2023
@leehinman leehinman requested a review from a team as a code owner August 29, 2023 01:48
@leehinman leehinman requested review from faec and pchila August 29, 2023 01:48
@leehinman leehinman added the Team:Elastic-Agent Label for the Agent team label Aug 29, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 29, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-08-29T17:58:40.113+0000

  • Duration: 28 min 8 sec

Test stats 🧪

Test Results
Failed 0
Passed 6217
Skipped 43
Total 6260

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 29, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 98.765% (80/81) 👍
Files 67.368% (192/285) 👍
Classes 66.105% (353/534) 👍
Methods 52.921% (1105/2088) 👍
Lines 38.526% (12608/32726) 👎 -0.031
Conditionals 100.0% (0/0) 💚

modify the `install.in_default` runtime protection variable so that
when elastic-agent is installed via deb or rpm package manager it is
still considered to be in the default path.  This is necessary because
endpoint supports being a component when elastic-agent is installed
via rpm/deb.

// NOTE searching for english words might not be a great idea as far as portability goes.
// list all installed packages then search for paths.BinaryName?
// dpkg is strange as the remove and purge processes leads to the package bing isted after a remove, but not after a purge
Copy link
Contributor

Choose a reason for hiding this comment

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

bing isted -> being listed? 😄


// check debian based systems (or systems that use dpkg)
// If the package has been installed, the status starts with "install"
// If the package has been removed (but not pruged) status starts with "deinstall"
Copy link
Contributor

Choose a reason for hiding this comment

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

purged

Copy link
Member

@cmacknz cmacknz left a comment

Choose a reason for hiding this comment

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

That this code already exists and executes on every install makes me feel better about it not having tests yet.


// check rhel and sles based systems (or systems that use rpm)
// if package has been installed the query will returns the list of associated files.
// otherwise if uninstalled, or has never been installled status ends with "not installed"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// otherwise if uninstalled, or has never been installled status ends with "not installed"
// otherwise if uninstalled, or has never been installed status ends with "not installed"

@cmacknz
Copy link
Member

cmacknz commented Aug 29, 2023

No new failures, merging.

@cmacknz cmacknz merged commit 117d7de into elastic:main Aug 29, 2023
12 checks passed
mergify bot pushed a commit that referenced this pull request Aug 29, 2023
* modify runtime variable 'install.in_default' with rpm/deb

modify the `install.in_default` runtime protection variable so that
when elastic-agent is installed via deb or rpm package manager it is
still considered to be in the default path.  This is necessary because
endpoint supports being a component when elastic-agent is installed
via rpm/deb.

* fix typos in comments

(cherry picked from commit 117d7de)
cmacknz pushed a commit that referenced this pull request Aug 29, 2023
)

* modify runtime variable 'install.in_default' with rpm/deb

modify the `install.in_default` runtime protection variable so that
when elastic-agent is installed via deb or rpm package manager it is
still considered to be in the default path.  This is necessary because
endpoint supports being a component when elastic-agent is installed
via rpm/deb.

* fix typos in comments

(cherry picked from commit 117d7de)

Co-authored-by: Lee E Hinman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.10.0 Automated backport with mergify bug Something isn't working skip-changelog Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RPM and DEB agents goes to unhealthy state when Elastic Defend integration is added.
4 participants