Skip to content

Add Pipeline to deploy custom agent image for FIPS testing #8035

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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ea416ea
Add Pipeline to deploy custom agent image for FIPS testing
michel-laterman Apr 29, 2025
c9d4023
Add new pipeline as triggered step
michel-laterman Apr 29, 2025
f8d343b
Use normal bk agent
michel-laterman Apr 29, 2025
46ec87a
Add bk agent provider and machinetype
michel-laterman May 1, 2025
cd7f72a
Add FIPS support to cloud:push
michel-laterman May 1, 2025
3ae5f92
Fix magefile
michel-laterman May 1, 2025
b84b803
Merge branch 'main' into fips-ech
michel-laterman May 1, 2025
838cdbd
Push image to beats-ci, add docker login hook
michel-laterman May 6, 2025
7515f8f
Fix pipeline
michel-laterman May 6, 2025
8ad48a3
Add FIPS env check to buildkite-integration-tests.sh
michel-laterman May 6, 2025
0ace521
Remove integration.fips addition
michel-laterman May 7, 2025
005746a
Merge branch 'main' into fips-ech
michel-laterman May 7, 2025
bd6119d
Fix label names
michel-laterman May 7, 2025
85ae7fa
revert change to integration tests
michel-laterman May 8, 2025
11b8ada
Pass FIPS
michel-laterman May 8, 2025
3ddecb1
Merge branch 'main' into fips-ech
michel-laterman May 9, 2025
775bd58
Add integration test with FIPS: true in requirements
michel-laterman May 9, 2025
5fb8569
Remove extra test
michel-laterman May 9, 2025
bb16fc7
Merge branch 'main' into fips-ech
michel-laterman May 9, 2025
9800591
Review feedback
michel-laterman May 9, 2025
6ee1fde
Change to k8s testing 9.1.0, change to running test on aws FIPS enabl…
michel-laterman May 9, 2025
878203f
Use ARM fips image
michel-laterman May 21, 2025
628f05d
Merge branch 'main' into fips-ech
michel-laterman May 21, 2025
68cc3cb
Fix pipeline
michel-laterman May 21, 2025
74c7e0f
Merge branch 'main' into fips-ech
michel-laterman May 22, 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
225 changes: 225 additions & 0 deletions .buildkite/bk.fips-integration.pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json

env:
DOCKER_REGISTRY: "docker.elastic.co"
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
ASDF_MAGE_VERSION: 1.14.0
CUSTOM_IMAGE_TAG: "git-${BUILDKITE_COMMIT:0:12}"
CI_ELASTIC_AGENT_DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-fips-cloud"

IMAGE_UBUNTU_2404_X86_64: "platform-ingest-elastic-agent-ubuntu-2404-1744855248"
IMAGE_UBUNTU_X86_64_FIPS: "platform-ingest-fleet-server-ubuntu-2204-fips"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a known reason why we use a fleet-server image here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that the images were created as a result of some experimentation that was being done with the fleet-server repo

Copy link
Contributor

@pazone pazone May 21, 2025

Choose a reason for hiding this comment

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

Should I create FIPS-compliant images for elastic-agent to avoid possible problems?

IMAGE_UBUNTU_ARM64_FIPS: "test-platform-ingest-fleet-server-ubuntu-2204-fips-aarch64-1747830486"

steps:
- label: Build and push custom elastic-agent image
key: integration-fips-cloud-image
env:
ASDF_TERRAFORM_VERSION: 1.9.2
FIPS: "true"
command: |
#!/usr/bin/env bash
set -euo pipefail
mage cloud:image
Copy link
Contributor

@pazone pazone May 22, 2025

Choose a reason for hiding this comment

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

cloud:image invokes the Package() function that packages the agent again. This step takes a considerable amount of time (~15 minutes). Can we download the artifacts produced by the packaging step and reuse them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can try, but I'm not sure if the Image step will use artifacts that are already present, @pkoutsovasilis do you know if it will?

mage cloud:push
agents:
provider: "gcp"
machineType: "n1-standard-8"
image: "${IMAGE_UBUNTU_2404_X86_64}"

- label: Start ESS stack for FIPS integration tests
key: integration-fips-ess
depends_on:
- integration-fips-cloud-image
env:
ASDF_TERRAFORM_VERSION: 1.9.2
TF_VAR_integration_server_docker_image: "${CI_ELASTIC_AGENT_DOCKER_IMAGE}:${CUSTOM_IMAGE_TAG}"
command: |
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/steps/ess_start.sh
artifact_paths:
- test_infra/ess/*.tfstate
- test_infra/ess/*.lock.hcl
agents:
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:0.5"
useCustomGlobalHooks: true

- group: "fips:Stateful:Ubuntu"
Copy link
Contributor

@pazone pazone May 20, 2025

Choose a reason for hiding this comment

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

Do I understand correctly that we run a set integration test groups in the same way and the only difference is in the VM image and the FIPS=true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

VM image, and i think that FIPS=true results in -integration.fips=true being sent

key: integration-tests-ubuntu-fips
depends_on:
- integration-fips-ess
steps:
- label: "fips:x86_64:non-sudo:{{matrix}}"
depends_on:
- packaging-ubuntu-x86-64-fips
env:
FIPS: "true"
command: |
buildkite-agent artifact download build/distributions/** . --step 'packaging-ubuntu-x86-64-fips'
.buildkite/scripts/steps/integration_tests_tf.sh {{matrix}} false
artifact_paths:
- build/**
- build/diagnostics/**
retry:
automatic:
limit: 1
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_X86_64_FIPS}"
instanceType: "m5.2xlarge"
matrix:
- default
- upgrade
- upgrade-flavor
- standalone-upgrade
- fleet
# FIPS tests don't have other groups enabled in order to save resources

- label: "fips:x86_64:sudo:{{matrix}}"
depends_on:
- packaging-ubuntu-x86-64-fips
env:
FIPS: "true"
command: |
buildkite-agent artifact download build/distributions/** . --step packaging-ubuntu-x86-64-fips
.buildkite/scripts/steps/integration_tests_tf.sh {{matrix}} true
artifact_paths:
- build/**
- build/diagnostics/**
retry:
automatic:
limit: 1
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_X86_64_FIPS}"
instanceType: "m5.2xlarge"
matrix:
- default
- upgrade
- upgrade-flavor
- standalone-upgrade
- fleet

- label: "fips:arm64:non-sudo:{{matrix}}"
depends_on:
- packaging-ubuntu-arm64-fips
env:
FIPS: "true"
command: |
buildkite-agent artifact download build/distributions/** . --step 'packaging-ubuntu-arm64-fips'
.buildkite/scripts/steps/integration_tests_tf.sh {{matrix}} false
artifact_paths:
- build/**
- build/diagnostics/**
retry:
automatic:
limit: 1
agents:
provider: "aws"
image: "${IMAGE_UBUNTU_ARM64_FIPS}"
instanceType: "m6g.2xlarge"
matrix:
- default
- upgrade
- upgrade-flavor
- standalone-upgrade
- fleet

- label: "fips:arm64:sudo:{{matrix}}"
depends_on:
- packaging-ubuntu-arm64-fips
env:
FIPS: "true"
command: |
buildkite-agent artifact download build/distributions/** . --step packaging-ubuntu-arm64-fips
.buildkite/scripts/steps/integration_tests_tf.sh {{matrix}} true
artifact_paths:
- build/**
- build/diagnostics/**
retry:
automatic:
limit: 1
agents:
provider: "aws"
image: "${IMAGE_UBUNTU_ARM64_FIPS}"
instanceType: "m6g.2xlarge"
matrix:
- default
- upgrade
- upgrade-flavor
- standalone-upgrade
- fleet

- group: "fips:Kubernetes"
key: integration-tests-kubernetes-fips
depends_on:
- integration-fips-ess
- packaging-containers-x86-64-fips
steps:
- label: "fips:{{matrix.version}}:amd64"
env:
K8S_VERSION: "{{matrix.version}}"
ASDF_KIND_VERSION: "0.27.0"
DOCKER_VARIANTS: "fips"
TARGET_ARCH: "amd64"
AGENT_VERSION: "9.1.0-SNAPSHOT" # Set to 9.1.0 as it is the first release in 9.x that supports FIPS
FIPS: "true"
command: |
buildkite-agent artifact download build/distributions/*-linux-amd64.docker.tar.gz . --step 'packaging-containers-x86-64-fips'
.buildkite/scripts/steps/integration_tests_tf.sh kubernetes false
artifact_paths:
- build/**
- build/diagnostics/**
- build/*.pod_logs_dump/*
retry:
automatic:
limit: 1
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_X86_64_FIPS}"
instanceType: "m5.2xlarge"
diskSizeGb: 80
matrix:
setup:
version:
- v1.27.16
- v1.28.9
- v1.29.8
- v1.30.8
- v1.31.0
- v1.32.0

- label: ESS FIPS stack cleanup
depends_on:
- integration-tests-ubuntu-fips
- integration-tests-kubernetes-fips
allow_dependency_failure: true
command: |
buildkite-agent artifact download "test_infra/ess/**" . --step "integration-fips-ess"
ls -lah test_infra/ess
.buildkite/scripts/steps/ess_down.sh
agents:
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:0.5"
useCustomGlobalHooks: true

- label: Aggregate test reports
# Warning: The key has a hook in pre-command
key: aggregate-reports-fips
depends_on:
- integration-tests-ubuntu-fips
- integration-tests-kubernetes-fips
allow_dependency_failure: true
command: |
buildkite-agent artifact download "build/*.xml" .
agents:
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:0.5"
useCustomGlobalHooks: true
soft_fail:
- exit_status: "*"
plugins:
- test-collector#v1.10.1:
files: "build/*.xml"
format: "junit"
branches: "main"
debug: true
2 changes: 1 addition & 1 deletion .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if [[ "$BUILDKITE_STEP_KEY" == *"aggregate-reports"* ]]; then
export BUILDKITE_ANALYTICS_TOKEN
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-binary-dra" ]]; then
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-binary-dra" || ("$BUILDKITE_PIPELINE_SLUG" == "elastic-agent" && "$BUILDKITE_STEP_KEY" == "integration-fips-cloud-image") ]]; then
if command -v docker &>/dev/null; then
docker_login
else
Expand Down
5 changes: 5 additions & 0 deletions .buildkite/integration.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,8 @@ steps:
depends_on:
- int-packaging
command: "buildkite-agent pipeline upload .buildkite/bk.integration.pipeline.yml"

- label: "Triggering custom FIPS integration tests"
depends_on:
- int-packaging
command: "buildkite-agent pipeline upload .buildkite/bk.fips-integration.pipeline.yml"
12 changes: 11 additions & 1 deletion .buildkite/scripts/buildkite-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,17 @@ outputJSON="build/${fully_qualified_group_name}.integration.out.json"
echo "~~~ Integration tests: ${GROUP_NAME}"

set +e
TEST_BINARY_NAME="elastic-agent" AGENT_VERSION="${AGENT_VERSION}" SNAPSHOT=true gotestsum --no-color -f standard-quiet --junitfile-hide-skipped-tests --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- -tags integration -test.shuffle on -test.timeout 2h0m0s github.com/elastic/elastic-agent/testing/integration -v -args -integration.groups="${GROUP_NAME}" -integration.sudo="${TEST_SUDO}"
TEST_BINARY_NAME="elastic-agent" AGENT_VERSION="${AGENT_VERSION}" SNAPSHOT=true \
gotestsum --no-color -f standard-quiet \
--junitfile-hide-skipped-tests \
--junitfile "${outputXML}" \
--jsonfile "${outputJSON}" \
-- \
-tags integration -test.shuffle on -test.timeout 2h0m0s \
github.com/elastic/elastic-agent/testing/integration \
-v \
-args -integration.groups="${GROUP_NAME}" -integration.sudo="${TEST_SUDO}" -integration.fips="${FIPS:-false}"

TESTS_EXIT_STATUS=$?
set -e

Expand Down
4 changes: 4 additions & 0 deletions .buildkite/scripts/steps/integration_tests_tf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ if [ -z "$TEST_SUDO" ]; then
exit 1
fi

if [[ ${FIPS:-false} == "true " ]]; then
echo "FIPS Integration tests detected."
fi

# Override the agent package version using a string with format <major>.<minor>.<patch>
# There is a time when the snapshot is not built yet, so we cannot use the latest version automatically
# This file is managed by an automation (mage integration:UpdateAgentPackageVersion) that check if the snapshot is ready.
Expand Down
15 changes: 14 additions & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,20 @@ func (Cloud) Push() error {
tag = fmt.Sprintf("%s-%s-%d", version, commit, time)
}

// Need to get the FIPS env var flag to see if we are using the normal source cloud image name, or the FIPS variant
fips := os.Getenv(fipsEnv)
defer os.Setenv(fipsEnv, fips)
fipsVal, err := strconv.ParseBool(fips)
if err != nil {
fipsVal = false
}
os.Setenv(fipsEnv, strconv.FormatBool(fipsVal))
devtools.FIPSBuild = fipsVal

sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s", version)
if fipsVal {
sourceCloudImageName = fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-fips-cloud:%s", version)
}
var targetCloudImageName string
if customImage, isPresent := os.LookupEnv("CI_ELASTIC_AGENT_DOCKER_IMAGE"); isPresent && len(customImage) > 0 {
targetCloudImageName = fmt.Sprintf("%s:%s", customImage, tag)
Expand All @@ -1010,7 +1023,7 @@ func (Cloud) Push() error {
}

fmt.Printf(">> Setting a docker image tag to %s\n", targetCloudImageName)
err := sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName)
err = sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName)
if err != nil {
return fmt.Errorf("Failed setting a docker image tag: %w", err)
}
Expand Down