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 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b937799
mark and skip flaky TestOTelManager_Run
michalpristas Nov 22, 2024
ac0cce2
Merge branch 'main' of github.com:elastic/elastic-agent
michalpristas Nov 27, 2024
42c4611
Merge branch 'main' of github.com:elastic/elastic-agent
michalpristas Dec 4, 2024
326add2
Merge branch 'main' of github.com:elastic/elastic-agent
michalpristas Dec 19, 2024
fa83554
Merge branch 'main' of github.com:elastic/elastic-agent
michalpristas Jan 3, 2025
a6dc99b
Merge branch 'main' of github.com:elastic/elastic-agent
michalpristas Jan 9, 2025
d23268c
basic works
michalpristas Jan 10, 2025
9b7e08f
zip works
michalpristas Jan 15, 2025
1919511
cleanup
michalpristas Jan 15, 2025
a99e9e6
ut for componentsForFLavor and subpathsForComponent
michalpristas Jan 15, 2025
a119e5a
ut for componentsForFLavor and subpathsForComponent
michalpristas Jan 15, 2025
33352ea
TestAllowedSubpathsForFlavor
michalpristas Jan 15, 2025
ffd57b1
TestSkipComponentsPathWithSubpathsFn
michalpristas Jan 15, 2025
4016c44
TestSkipComponentsPathFn
michalpristas Jan 15, 2025
350b087
TestSkipComponentsPathFn
michalpristas Jan 15, 2025
e0f3aef
TestParseComponentFiles
michalpristas Jan 15, 2025
cd417c8
TestFlavor
michalpristas Jan 15, 2025
41ee06a
TestSpecsForFlavor
michalpristas Jan 15, 2025
b32f0c1
fix unpack and tests
michalpristas Jan 15, 2025
6055adb
imports
michalpristas Jan 15, 2025
863adc5
integ tests
michalpristas Jan 16, 2025
b44902e
flavours in file
michalpristas Jan 17, 2025
822e308
Merge branch 'main' of github.com:elastic/elastic-agent into feat/bin…
michalpristas Jan 17, 2025
aadc6fe
lint
michalpristas Jan 17, 2025
51bd2c6
changelog
michalpristas Jan 17, 2025
67ed4a7
unpack UTs
michalpristas Jan 20, 2025
0f50031
spec files updated
michalpristas Jan 20, 2025
8a60a47
Merge branch 'main' of github.com:elastic/elastic-agent into feat/bin…
michalpristas Jan 20, 2025
a095684
handle windows correctly in UTs
michalpristas Jan 20, 2025
7cf5147
linter
michalpristas Jan 20, 2025
01cef9c
install server for fleet server tests
michalpristas Jan 20, 2025
0696c75
Merge branch 'main' of github.com:elastic/elastic-agent into feat/bin…
michalpristas Jan 20, 2025
6c39e92
install server for fleet server tests
michalpristas Jan 20, 2025
724e852
flavors in manifest
michalpristas Jan 21, 2025
255a8dc
Merge branch 'main' of github.com:elastic/elastic-agent into feat/bin…
michalpristas Jan 21, 2025
5117a62
Update internal/pkg/agent/application/upgrade/upgrade.go
michalpristas Jan 23, 2025
81e24e5
specs for flavor returning no error
michalpristas Jan 23, 2025
492bd35
Merge branch 'feat/binary-distr' of github.com:michalpristas/elastic-…
michalpristas Jan 23, 2025
1bdff99
Merge branch 'main' of github.com:elastic/elastic-agent into feat/bin…
michalpristas Jan 23, 2025
dc35611
lint
michalpristas Jan 23, 2025
8076e9f
fixed UT
michalpristas Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .flavors
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
basic:
- agentbeat
- endpoint-security
- pf-host-agent
servers:
- agentbeat
- endpoint-security
- pf-host-agent
- cloudbeat
- apm-server
- fleet-server
- pf-elastic-symbolizer
- pf-elastic-collector
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Kind can be one of:
# - breaking-change: a change to previously-documented behavior
# - deprecation: functionality that is being removed in a later release
# - bug-fix: fixes a problem in a previous version
# - enhancement: extends functionality but does not break or fix existing behavior
# - feature: new functionality
# - known-issue: problems that we are aware of in a given version
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: breaking-change

# Change summary; a 80ish characters long description of the change.
summary: Changes to binary distribution

# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
description: |
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


# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
component: elastic-agent

# PR URL; optional; the PR number that added the changeset.
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
#pr: https://github.com/owner/repo/1234

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
#issue: https://github.com/owner/repo/1234
55 changes: 49 additions & 6 deletions dev-tools/mage/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const (

elasticAgentModulePath = "github.com/elastic/elastic-agent"

defaultName = "elastic-agent"
defaultName = "elastic-agent"
flavorsRegistryFilename = ".flavors"

// Env vars
// agent package version
Expand Down Expand Up @@ -346,10 +347,15 @@ func PackageManifest() (string, error) {
return "", fmt.Errorf("retrieving agent commit hash: %w", err)
}

return GeneratePackageManifest(BeatName, packageVersion, Snapshot, hash, commitHashShort)
registry, err := loadFlavorsRegistry()
if err != nil {
return "", fmt.Errorf("retrieving agent flavors: %w", err)
}

return GeneratePackageManifest(BeatName, packageVersion, Snapshot, hash, commitHashShort, registry)
}

func GeneratePackageManifest(beatName, packageVersion string, snapshot bool, fullHash, shortHash string) (string, error) {
func GeneratePackageManifest(beatName, packageVersion string, snapshot bool, fullHash, shortHash string, flavorsRegistry map[string][]string) (string, error) {
m := v1.NewManifest()
m.Package.Version = packageVersion
m.Package.Snapshot = snapshot
Expand All @@ -360,6 +366,7 @@ func GeneratePackageManifest(beatName, packageVersion string, snapshot bool, ful
m.Package.PathMappings = []map[string]string{{}}
m.Package.PathMappings[0][versionedHomePath] = fmt.Sprintf("data/%s-%s%s-%s", beatName, m.Package.Version, GenerateSnapshotSuffix(snapshot), shortHash)
m.Package.PathMappings[0][v1.ManifestFileName] = fmt.Sprintf("data/%s-%s%s-%s/%s", beatName, m.Package.Version, GenerateSnapshotSuffix(snapshot), shortHash, v1.ManifestFileName)
m.Package.Flavors = flavorsRegistry
yamlBytes, err := yaml.Marshal(m)
if err != nil {
return "", fmt.Errorf("marshaling manifest: %w", err)
Expand Down Expand Up @@ -461,6 +468,10 @@ var (
beatVersionValue string
beatVersionErr error
beatVersionOnce sync.Once

flavorsRegistry map[string][]string
flavorsRegistryErr error
flavorsOnce sync.Once
)

// BeatQualifiedVersion returns the Beat's qualified version. The value can be overwritten by
Expand Down Expand Up @@ -492,6 +503,14 @@ func beatVersion() (string, error) {
return beatVersionValue, beatVersionErr
}

func loadFlavorsRegistry() (map[string][]string, error) {
flavorsOnce.Do(func() {
flavorsRegistry, flavorsRegistryErr = getBuildVariableSources().GetFlavorsRegistry()
})

return flavorsRegistry, flavorsRegistryErr
}

var (
beatDocBranchRegex = regexp.MustCompile(`(?m)doc-branch:\s*([^\s]+)\r?$`)
beatDocSiteBranchRegex = regexp.MustCompile(`(?m)doc-site-branch:\s*([^\s]+)\r?$`)
Expand Down Expand Up @@ -521,9 +540,10 @@ var (
// DefaultBeatBuildVariableSources contains the default locations build
// variables are read from by Elastic Beats.
DefaultBeatBuildVariableSources = &BuildVariableSources{
BeatVersion: "{{ elastic_beats_dir }}/version/version.go",
GoVersion: "{{ elastic_beats_dir }}/.go-version",
DocBranch: "{{ elastic_beats_dir }}/version/docs/version.asciidoc",
BeatVersion: "{{ elastic_beats_dir }}/version/version.go",
GoVersion: "{{ elastic_beats_dir }}/.go-version",
DocBranch: "{{ elastic_beats_dir }}/version/docs/version.asciidoc",
FlavorsRegistry: "{{ elastic_beats_dir }}/.flavors",
}

buildVariableSources *BuildVariableSources
Expand Down Expand Up @@ -584,6 +604,9 @@ type BuildVariableSources struct {

// Parses the documentation branch from the DocBranch file.
DocBranchParser func(data []byte) (string, error)

// File containing definition of flavors.
FlavorsRegistry string
}

func (s *BuildVariableSources) expandVar(in string) (string, error) {
Expand Down Expand Up @@ -628,6 +651,26 @@ func (s *BuildVariableSources) GetGoVersion() (string, error) {
return s.GoVersionParser(data)
}

// GetGoVersion reads the GoVersion file and parses the version from it.
func (s *BuildVariableSources) GetFlavorsRegistry() (map[string][]string, error) {
file, err := s.expandVar(s.FlavorsRegistry)
if err != nil {
return nil, err
}

data, err := os.ReadFile(file)
if err != nil {
return nil, fmt.Errorf("failed to read go version file=%v: %w", file, err)
}

registry := make(map[string][]string)
if err := yaml.Unmarshal(data, registry); err != nil {
return nil, err
}

return registry, nil
}

// GetDocBranch reads the DocBranch file and parses the branch from it.
func (s *BuildVariableSources) GetDocBranch() (string, error) {
file, err := s.expandVar(s.DocBranch)
Expand Down
Loading
Loading