Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6a382ad
Add component list to specs
pchila Apr 1, 2025
8f53cdd
WIP - extract component dependencies from the packages to be built
pchila Apr 1, 2025
041e076
Refactor component extraction from package specs
pchila Apr 1, 2025
2c0f166
Fix package tests error handling
pchila Apr 2, 2025
87171f8
Inject dependencies and remove references to ExpectedBinaries
pchila Apr 2, 2025
7de031e
Remove ExpectedBinaries global
pchila Apr 2, 2025
9896dfe
Add rootdir to components
pchila Apr 2, 2025
20cafa0
Extract actual version matched on the package file and use it to rend…
pchila Apr 2, 2025
57cddeb
Package elastic-agent FIPS specs when FIPS=true is specified
pchila Apr 2, 2025
32616c0
refactor ResolveManifestPackage
pchila Apr 3, 2025
58bcc26
Move FIPS compile settings in packages.yml
pchila Apr 3, 2025
9ba0fc2
Add more FIPS components
pchila Apr 3, 2025
eaa8f43
Properly handle dependenciesVersion when calling mage package
pchila Apr 4, 2025
2dbeb3c
Refactor ChecksumsWithoutManifest to use list of dependencies instead…
pchila Apr 4, 2025
fc7e7ef
fixup! Properly handle dependenciesVersion when calling mage package
pchila Apr 4, 2025
543a351
Disable apm-server-fips on linux/arm64 because binary name is wrong
pchila Apr 4, 2025
298dfe9
fixup! Add rootdir to components
pchila Apr 4, 2025
5a0d9bd
Rework useDRAAgentBinaryForPackage for repackaging agent
pchila Apr 4, 2025
bc17bed
Write spec FIPS flag into manifest.yaml when packaging
pchila Apr 4, 2025
0316195
fixup! Write spec FIPS flag into manifest.yaml when packaging
pchila Apr 5, 2025
0c1aa58
Add FIPS elastic agent absic and cloud docker images
pchila Apr 7, 2025
9ea7006
fixup! Add FIPS elastic agent absic and cloud docker images
pchila Apr 7, 2025
4cf8d4f
Build FIPS docker images in CI packaging
pchila Apr 7, 2025
ec5906b
fixup! Build FIPS docker images in CI packaging
pchila Apr 7, 2025
72430dc
fixup! fixup! Build FIPS docker images in CI packaging
pchila Apr 7, 2025
d7665bb
Fix FIPS .tar.gz package tests
pchila Apr 7, 2025
8b3b3d1
Restructure package tests
pchila Apr 7, 2025
4635764
Extend FIPS check to all binaries in components directory
pchila Apr 7, 2025
cbd4b9e
fixup! Restructure package tests
pchila Apr 7, 2025
1ec6087
fixup! fixup! Restructure package tests
pchila Apr 7, 2025
605293f
fixup! Extend FIPS check to all binaries in components directory
pchila Apr 7, 2025
b5531d8
Create FIPS elastic-agent-core artifacts in elastic-agent-binary-dra …
pchila Apr 7, 2025
9335dc8
Cleanup ChecksumsWithManifest and improve godoc
pchila Apr 7, 2025
f6ac709
Clarify debug variables
pchila Apr 7, 2025
8f19e2e
Improve comments on components definitions
pchila Apr 7, 2025
39e20b4
Improve godoc for BinarySpec
pchila Apr 7, 2025
f39e53e
fixup! Improve comments on components definitions
pchila Apr 7, 2025
a2d90d2
re-include apm-server fips component
pchila Apr 9, 2025
2620629
cleanup mage package verbose logs
pchila Apr 9, 2025
ba72248
Fix header of packages.yml
pchila Apr 9, 2025
d738701
fixup! Create FIPS elastic-agent-core artifacts in elastic-agent-bina…
pchila Apr 9, 2025
e9be5cb
fixup! fixup! Create FIPS elastic-agent-core artifacts in elastic-age…
pchila Apr 9, 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
30 changes: 30 additions & 0 deletions .buildkite/integration.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,36 @@ steps:
imagePrefix: "core-ubuntu-2204-aarch64"
diskSizeGb: 200

- label: "Packaging: Containers linux/amd64 FIPS"
key: packaging-containers-x86-64-fips
env:
PACKAGES: "docker"
PLATFORMS: "linux/amd64"
FIPS: "true"
command: ".buildkite/scripts/steps/integration-package.sh"
artifact_paths:
- build/distributions/**
agents:
provider: "gcp"
machineType: "n2-standard-8"
diskSizeGb: 200

- label: "Packaging: Containers linux/arm64 FIPS"
key: packaging-containers-arm64-fips
env:
PACKAGES: "docker"
PLATFORMS: "linux/arm64"
FIPS: "true"
command: |
.buildkite/scripts/steps/integration-package.sh
artifact_paths:
- build/distributions/**
agents:
provider: "aws"
instanceType: "c6g.4xlarge"
imagePrefix: "core-ubuntu-2204-aarch64"
diskSizeGb: 200

- label: "Serverless integration test"
key: "serverless-integration-tests"
depends_on:
Expand Down
61 changes: 60 additions & 1 deletion .buildkite/pipeline.elastic-agent-binary-dra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,21 @@ steps:
env:
DRA_WORKFLOW: "snapshot"
PLATFORMS: "linux/amd64 windows/amd64 darwin/amd64"


- label: ":package: linux/amd64 FIPS Elastic-Agent Core Snapshot"
commands:
- .buildkite/scripts/steps/build-agent-core.sh
key: "build-dra-snapshot-x86-fips"
artifact_paths:
- "build/distributions/**/*"
agents:
provider: "gcp"
machineType: "c2-standard-16"
env:
DRA_WORKFLOW: "snapshot"
PLATFORMS: "linux/amd64"
FIPS: "true"

- label: ":package: linux/arm64 darwin/arm64 Elastic-Agent Core Snapshot"
commands:
- .buildkite/scripts/steps/build-agent-core.sh
Expand All @@ -40,6 +54,20 @@ steps:
DRA_WORKFLOW: "snapshot"
PLATFORMS: "linux/arm64 darwin/arm64"

- label: ":package: linux/arm64 FIPS Elastic-Agent Core Snapshot"
commands:
- .buildkite/scripts/steps/build-agent-core.sh
key: "build-dra-snapshot-arm-fips"
artifact_paths:
- "build/distributions/**/*"
agents:
provider: "aws"
instanceType: "c6g.4xlarge"
imagePrefix: "core-ubuntu-2204-aarch64"
env:
DRA_WORKFLOW: "snapshot"
PLATFORMS: "linux/arm64"
FIPS: "true"
- wait

- label: ":hammer: DRA Publish Elastic-Agent Core Snapshot"
Expand Down Expand Up @@ -86,6 +114,21 @@ steps:
DRA_WORKFLOW: "staging"
PLATFORMS: "linux/amd64 windows/amd64 darwin/amd64"

- label: ":package: linux/amd64 FIPS Elastic-Agent Core staging"
commands: |
source .buildkite/scripts/version_qualifier.sh
.buildkite/scripts/steps/build-agent-core.sh
key: "build-dra-staging-x86-fips"
artifact_paths:
- "build/distributions/**/*"
agents:
provider: "gcp"
machineType: "c2-standard-16"
env:
DRA_WORKFLOW: "staging"
PLATFORMS: "linux/amd64"
FIPS: "true"

- label: ":package: linux/arm64 darwin/arm64 Elastic-Agent Core staging"
commands: |
source .buildkite/scripts/version_qualifier.sh
Expand All @@ -101,6 +144,22 @@ steps:
DRA_WORKFLOW: "dra-core-staging"
PLATFORMS: "linux/arm64 darwin/arm64"

- label: ":package: linux/arm64 FIPS Elastic-Agent Core staging"
commands: |
source .buildkite/scripts/version_qualifier.sh
.buildkite/scripts/steps/build-agent-core.sh
key: "build-dra-staging-arm-fips"
artifact_paths:
- "build/distributions/**/*"
agents:
provider: "aws"
instanceType: "c6g.4xlarge"
imagePrefix: "core-ubuntu-2204-aarch64"
env:
DRA_WORKFLOW: "dra-core-staging"
PLATFORMS: "linux/arm64"
FIPS: "true"

- wait

- label: ":hammer: DRA Publish Elastic-Agent Core staging"
Expand Down
20 changes: 13 additions & 7 deletions dev-tools/mage/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/magefile/mage/sh"
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/elastic/elastic-agent/dev-tools/packaging"
)

// BuildArgs are the arguments used for the "build" target and they define how
Expand Down Expand Up @@ -73,6 +75,7 @@ func DefaultBuildArgs() BuildArgs {
args := BuildArgs{
Name: BeatName,
CGO: build.Default.CgoEnabled,
Env: map[string]string{},
Vars: map[string]string{
elasticAgentModulePath + "/version.buildTime": "{{ date }}",
elasticAgentModulePath + "/version.commit": "{{ commit }}",
Expand All @@ -88,8 +91,16 @@ func DefaultBuildArgs() BuildArgs {
}

if FIPSBuild {
args.ExtraFlags = append(args.ExtraFlags, "-tags=requirefips")
args.CGO = true

fipsConfig := packaging.Settings().FIPS

for _, tag := range fipsConfig.Compile.Tags {
args.ExtraFlags = append(args.ExtraFlags, "-tags="+tag)
}
args.CGO = args.CGO || fipsConfig.Compile.CGO
for varName, value := range fipsConfig.Compile.Env {
args.Env[varName] = value
}
}

if DevBuild {
Expand Down Expand Up @@ -191,11 +202,6 @@ func Build(params BuildArgs) error {
cgoEnabled = "1"
}

if FIPSBuild {
cgoEnabled = "1"
env["GOEXPERIMENT"] = "systemcrypto"
}

env["CGO_ENABLED"] = cgoEnabled

// Spec
Expand Down
97 changes: 51 additions & 46 deletions dev-tools/mage/checksums.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"log"
"os"
"path/filepath"
"strings"

"github.com/magefile/mage/mg"
"github.com/otiai10/copy"
Expand Down Expand Up @@ -41,68 +40,82 @@ func CopyComponentSpecs(componentName, versionedDropPath string) (string, error)
return GetSHA512Hash(targetPath)
}

// This is a helper function for flattenDependencies that's used when not packaging from a manifest
func ChecksumsWithoutManifest(versionedFlatPath string, versionedDropPath string, packageVersion string) map[string]string {
globExpr := filepath.Join(versionedFlatPath, fmt.Sprintf("*%s*", packageVersion))
if mg.Verbose() {
log.Printf("Finding files to copy with %s", globExpr)
}
files, err := filepath.Glob(globExpr)
if err != nil {
panic(err)
}
if mg.Verbose() {
log.Printf("Validating checksums for %+v", files)
log.Printf("--- Copying into %s: %v", versionedDropPath, files)
}

// ChecksumsWithoutManifest is a helper function for flattenDependencies that's used when not packaging from a manifest.
// This function will iterate over the dependencies, resolve *exactly* the package name for each dependency and platform using the passed
// dependenciesVersion, and it will copy the extracted files contained in the rootDir of each dependency from the versionedFlatPath
// (a directory containing all the extracted dependencies per platform) to the versionedDropPath (a drop path by platform
// that will be used to compose the package content)
// ChecksumsWithoutManifest will accumulate the checksums of each component spec that is copied, and return it to the caller.
func ChecksumsWithoutManifest(platform string, dependenciesVersion string, versionedFlatPath string, versionedDropPath string, dependencies []packaging.BinarySpec) map[string]string {
checksums := make(map[string]string)
for _, f := range files {

for _, dep := range dependencies {

if dep.PythonWheel {
if mg.Verbose() {
log.Printf(">>>>>>> Component %s/%s is a Python wheel, skipping", dep.ProjectName, dep.BinaryName)
}
continue
}

if !dep.SupportsPlatform(platform) {
log.Printf(">>>>>>> Component %s/%s does not support platform %s, skipping", dep.ProjectName, dep.BinaryName, platform)
continue
}

srcDir := filepath.Join(versionedFlatPath, dep.GetRootDir(dependenciesVersion, platform))

if mg.Verbose() {
log.Printf("Validating checksums for %+v", dep.BinaryName)
log.Printf("--- Copying into %s: %v", versionedDropPath, srcDir)
}

options := copy.Options{
OnSymlink: func(_ string) copy.SymlinkAction {
return copy.Shallow
},
Sync: true,
}
if mg.Verbose() {
log.Printf("> prepare to copy %s into %s ", f, versionedDropPath)
log.Printf("> prepare to copy %s into %s ", srcDir, versionedDropPath)
}

err = copy.Copy(f, versionedDropPath, options)
err := copy.Copy(srcDir, versionedDropPath, options)
if err != nil {
panic(err)
panic(fmt.Errorf("copying dependency %s files from %q to %q: %w", dep.BinaryName, srcDir, versionedDropPath, err))
}

// copy spec file for match
specName := filepath.Base(f)
idx := strings.Index(specName, "-"+packageVersion)
if idx != -1 {
specName = specName[:idx]
}
if mg.Verbose() {
log.Printf(">>>> Looking to copy spec file: [%s]", specName)
log.Printf(">>>> Looking to copy spec file: [%s]", dep.BinaryName)
}

checksum, err := CopyComponentSpecs(specName, versionedDropPath)
checksum, err := CopyComponentSpecs(dep.BinaryName, versionedDropPath)
if err != nil {
panic(err)
}

checksums[specName+ComponentSpecFileSuffix] = checksum
checksums[dep.BinaryName+ComponentSpecFileSuffix] = checksum
}

return checksums
}

// This is a helper function for flattenDependencies that's used when building from a manifest
func ChecksumsWithManifest(platform, dependenciesVersion string, versionedFlatPath string, versionedDropPath string, manifestResponse *manifest.Build) map[string]string {
// ChecksumsWithManifest is a helper function for flattenDependencies that's used when building from a manifest.
// This function will iterate over the dependencies, resolve the package name for each dependency and platform using the manifest,
// (there may be some variability there in case the manifest does not include an exact match for the expected filename),
// and it will copy the extracted files contained in the rootDir of each dependency from the versionedFlatPath
// (a directory containing all the extracted dependencies per platform) to the versionedDropPath (a drop path by platform
// that will be used to compose the package content)
// ChecksumsWithManifest will accumulate the checksums of each component spec that is copied, and return it to the caller.
func ChecksumsWithManifest(platform string, dependenciesVersion string, versionedFlatPath string, versionedDropPath string, manifestResponse *manifest.Build, dependencies []packaging.BinarySpec) map[string]string {
checksums := make(map[string]string)
if manifestResponse == nil {
return checksums
}

// Iterate over the external binaries that we care about for packaging agent
for _, spec := range packaging.ExpectedBinaries {
for _, spec := range dependencies {

if spec.PythonWheel {
if mg.Verbose() {
Expand All @@ -124,21 +137,13 @@ func ChecksumsWithManifest(platform, dependenciesVersion string, versionedFlatPa
continue
}

rootDir := spec.GetRootDir(manifestPackage.ActualVersion, platform)

// Combine the package name w/ the versioned flat path
fullPath := filepath.Join(versionedFlatPath, manifestPackage.Name)

// Eliminate the file extensions to get the proper directory
// name that we need to copy
var dirToCopy string
if strings.HasSuffix(fullPath, ".tar.gz") {
dirToCopy = fullPath[:strings.LastIndex(fullPath, ".tar.gz")]
} else if strings.HasSuffix(fullPath, ".zip") {
dirToCopy = fullPath[:strings.LastIndex(fullPath, ".zip")]
} else {
dirToCopy = fullPath
}
fullPath := filepath.Join(versionedFlatPath, rootDir)

if mg.Verbose() {
log.Printf(">>>>>>> Calculated directory to copy: [%s]", dirToCopy)
log.Printf(">>>>>>> Calculated directory to copy: [%s]", fullPath)
}

// Set copy options
Expand All @@ -149,11 +154,11 @@ func ChecksumsWithManifest(platform, dependenciesVersion string, versionedFlatPa
Sync: true,
}
if mg.Verbose() {
log.Printf("> prepare to copy %s into %s ", dirToCopy, versionedDropPath)
log.Printf("> prepare to copy %s into %s ", fullPath, versionedDropPath)
}

// Do the copy
err = copy.Copy(dirToCopy, versionedDropPath, options)
err = copy.Copy(fullPath, versionedDropPath, options)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions dev-tools/mage/crossbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const defaultCrossBuildTarget = "golangCrossBuild"
var Platforms = BuildPlatforms.Defaults()

// SelectedPackageTypes is the list of package types. If empty, all packages types
// are considered to be selected (see isPackageTypeSelected).
// are considered to be selected (see IsPackageTypeSelected).
var SelectedPackageTypes []PackageType

// SelectedDockerVariants is the list of docker variants. If empty, all docker variants
// are considered to be selected (see isDockerVariantSelected).
// are considered to be selected (see IsDockerVariantSelected).
var SelectedDockerVariants []DockerVariant

func init() {
Expand Down
4 changes: 1 addition & 3 deletions dev-tools/mage/dockerbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ func (b *dockerBuilder) dockerBuild() (string, []string, error) {
if b.Snapshot {
mainTag = mainTag + "-SNAPSHOT"
}
if b.FIPS {
mainTag = mainTag + "-fips"
}

if repository := b.ExtraVars["repository"]; repository != "" {
mainTag = fmt.Sprintf("%s/%s", repository, mainTag)
}
Expand Down
Loading