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

Changes to binary distribution #6542

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

michalpristas
Copy link
Contributor

Ready for review but DO NOT MERGE before spec files of dependencies are updated in other repos

What does this PR do?

This PR changes logic of installation and ugprades in following manner.

Default install installs only:

  • agentbeat
  • endpoint-security
  • pf-host-agent

additional flag is added that includes components above and:

  • cloudbeat
  • apm-server
  • fleet-server
  • pf-elastic-symbolizer
  • pf-elastic-collector

Upon installation user choice is backed into .flavor file.

Part of elastic agent package is .flavors file defining flavor for this particular version.
Upon upgrade or install .flavors is read and only components specified in desired flavor (using flag with install or content of .flavor in case of upgrade) are copied.

In case of any issues with parsing any of the above files we fall back to previous way and copy everything.

Each components needs to define files in addition to binary, spec and config in a form

component_files:
 - file1
 - dir1/*

in their spec file.

During upgrade target version spec file is parsed. not the current installation.

Why is it important?

Reducing space on disk by omitting not needed components.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • 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 TODO: @michalpristas
  • 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

How to test this PR locally

Scenario 1 and 2 (installation)

Build package and install without and with flag --install-server
check components present

Scenario 3 - upgrade to future version

Prepare same agent but with different commit hash (do small change and commit locally)
Run upgrade 9.0.0-SNAPSHOT --source-uri="file://....zip" --skip-verify and check only desired components are present

Scenario 4 - upgrade from stale version

Upgrade from previous version to this one and check ALL components are present

@michalpristas michalpristas added enhancement New feature or request backport-skip labels Jan 17, 2025
@michalpristas michalpristas self-assigned this Jan 17, 2025
@michalpristas michalpristas requested a review from a team as a code owner January 17, 2025 16:13
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
38.5% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

@cmacknz
Copy link
Member

cmacknz commented Jan 17, 2025

You will need to add integration tests to make sure upgrades respect the flavor or lack of one.

For the existing upgrade tests you could probably add a check to ensure every component exists in both versions easily. For flavors you'll need new tests for those case most likely.

@@ -190,7 +190,7 @@ func TestUpgrader_unpackTarGz(t *testing.T) {
archiveFile, err := tt.args.archiveGenerator(t, tt.args.archiveFiles)
require.NoError(t, err, "creation of test archive file failed")

got, err := untar(log, archiveFile, testDataDir)
got, err := untar(log, archiveFile, testDataDir, false, "")
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to unit test that the logic to respect the flavors when unpacking actually works.

unpackRes, err := u.unpack(version, archivePath, paths.Data())
// default to extended flavor to avoid breaking behavior

// no default flavor, keep everything in case flavor is not
Copy link
Member

Choose a reason for hiding this comment

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

keep everything in case flavor is not

Is not what?

@@ -0,0 +1,13 @@
basic:
Copy link
Member

@cmacknz cmacknz Jan 17, 2025

Choose a reason for hiding this comment

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

What value are we getting out of making this a file and having to deal with opening+parsing it vs just embedded this list into the agent as code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants