Skip to content

Commit f18a91e

Browse files
[8.17](backport #8736) ci: pin elastic-agent version (#8748)
* ci: pin elastic-agent version (#8736) * ci: pin elastic-agent version * ci: override BEAT_VERSION * ci: fix mage cloud:load and cloud:push (cherry picked from commit 5c5b174) # Conflicts: # .buildkite/bk.integration-fips.pipeline.yml # .buildkite/bk.integration.pipeline.yml # .buildkite/scripts/buildkite-integration-tests.sh # magefile.go * fix: resolve conflicts * fix: pin at 8.17.8 --------- Co-authored-by: Panos Koutsovasilis <[email protected]>
1 parent 1cd6b96 commit f18a91e

File tree

7 files changed

+41
-31
lines changed

7 files changed

+41
-31
lines changed

.buildkite/bk.integration.pipeline.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ env:
66

77
# The following images are defined here and their values will be updated by updatecli
88
# Please do not change them manually.
9-
IMAGE_UBUNTU_2404_X86_64: "platform-ingest-elastic-agent-ubuntu-2404-1749258065"
10-
IMAGE_UBUNTU_2404_ARM_64: "platform-ingest-elastic-agent-ubuntu-2404-aarch64-1749258065"
11-
IMAGE_RHEL_8: "platform-ingest-elastic-agent-rhel-8-1749258065"
12-
IMAGE_DEBIAN_12: "platform-ingest-elastic-agent-debian-12-1749258065"
13-
IMAGE_WIN_2022: "platform-ingest-elastic-agent-windows-2022-1749258065"
14-
IMAGE_WIN_2025: "platform-ingest-elastic-agent-windows-2025-1749258065"
9+
IMAGE_UBUNTU_2404_X86_64: "platform-ingest-elastic-agent-ubuntu-2404-1750467641"
10+
IMAGE_UBUNTU_2404_ARM_64: "platform-ingest-elastic-agent-ubuntu-2404-aarch64-1750467641"
11+
IMAGE_RHEL_8: "platform-ingest-elastic-agent-rhel-8-1750467641"
12+
IMAGE_DEBIAN_12: "platform-ingest-elastic-agent-debian-12-1750467641"
13+
IMAGE_WIN_2022: "platform-ingest-elastic-agent-windows-2022-1750467641"
14+
IMAGE_WIN_2025: "platform-ingest-elastic-agent-windows-2025-1750467641"
15+
# Remove AGENT_VERSION pinning once 8.17.8 DRA and stack are released
16+
AGENT_VERSION: "8.17.8-SNAPSHOT"
1517

1618
# This section is used to define the plugins that will be used in the pipeline.
1719
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins

.buildkite/integration.pipeline.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
env:
44
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
5+
# Remove AGENT_PACKAGE_VERSION and AGENT_VERSION pinning once 8.17.8 DRA and stack are released
6+
AGENT_PACKAGE_VERSION: "8.17.8"
7+
BEAT_VERSION: "8.17.8"
58

69
steps:
710
- group: "Integration tests: packaging"

.buildkite/scripts/buildkite-integration-tests.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ go install gotest.tools/gotestsum
2525
gotestsum --version
2626

2727
$env:TEST_BINARY_NAME = "elastic-agent"
28-
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
29-
$AGENT_VERSION = (Get-Content version/version.go | Select-String -Pattern 'const defaultBeatVersion =' | ForEach-Object { $_ -replace '.*?"(.*?)".*', '$1' })
30-
$env:AGENT_VERSION = $AGENT_VERSION + "-SNAPSHOT"
28+
if (-not $env:AGENT_VERSION) {
29+
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
30+
$AGENT_VERSION = (Get-Content version/version.go | Select-String -Pattern 'const defaultBeatVersion =' | ForEach-Object { $_ -replace '.*?"(.*?)".*', '$1' })
31+
$env:AGENT_VERSION = $AGENT_VERSION + "-SNAPSHOT"
32+
}
3133

3234
Write-Output "~~~ Agent version: $env:AGENT_VERSION"
3335
$env:SNAPSHOT = $true

.buildkite/scripts/buildkite-integration-tests.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ echo "~~~ Running integration tests as $USER"
3232

3333
make install-gotestsum
3434

35-
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
36-
AGENT_VERSION=$(grep "const defaultBeatVersion =" version/version.go | cut -d\" -f2)
37-
AGENT_VERSION="${AGENT_VERSION}-SNAPSHOT"
35+
if [[ -z "${AGENT_VERSION:-}" ]]; then
36+
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
37+
AGENT_VERSION=$(grep "const defaultBeatVersion =" version/version.go | cut -d\" -f2)
38+
AGENT_VERSION="${AGENT_VERSION}-SNAPSHOT"
39+
fi
40+
3841
export AGENT_VERSION
3942
echo "~~~ Agent version: ${AGENT_VERSION}"
4043

.buildkite/scripts/common.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ fi
99
if [[ -z "${SETUP_GVM_VERSION-""}" ]]; then
1010
SETUP_GVM_VERSION="v0.5.2" # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
1111
fi
12-
BEAT_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' "${WORKSPACE}/version/version.go")
13-
export BEAT_VERSION
12+
13+
if [[ -z "${BEAT_VERSION-""}" ]]; then
14+
BEAT_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' "${WORKSPACE}/version/version.go")
15+
export BEAT_VERSION
16+
fi
1417

1518
getOSOptions() {
1619
case $(uname | tr '[:upper:]' '[:lower:]') in

magefile.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -821,41 +821,37 @@ func (Cloud) Image(ctx context.Context) {
821821
// Push builds a cloud image tags it correctly and pushes to remote image repo.
822822
// Previous login to elastic registry is required!
823823
func (Cloud) Push() error {
824-
snapshot := os.Getenv(snapshotEnv)
825-
defer os.Setenv(snapshotEnv, snapshot)
826-
827-
os.Setenv(snapshotEnv, "true")
824+
agentVersion, err := mage.AgentPackageVersion()
825+
if err != nil {
826+
return fmt.Errorf("failed to get agent package version: %w", err)
827+
}
828828

829-
version := getVersion()
830-
var tag string
829+
var targetTag string
831830
if envTag, isPresent := os.LookupEnv("CUSTOM_IMAGE_TAG"); isPresent && len(envTag) > 0 {
832-
tag = envTag
831+
targetTag = envTag
833832
} else {
834-
commit := dockerCommitHash()
835-
time := time.Now().Unix()
836-
837-
tag = fmt.Sprintf("%s-%s-%d", version, commit, time)
833+
targetTag = fmt.Sprintf("%s-%s-%d", agentVersion, dockerCommitHash(), time.Now().Unix())
838834
}
839835

840-
sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s", version)
836+
sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s-SNAPSHOT", agentVersion)
841837
var targetCloudImageName string
842838
if customImage, isPresent := os.LookupEnv("CI_ELASTIC_AGENT_DOCKER_IMAGE"); isPresent && len(customImage) > 0 {
843-
targetCloudImageName = fmt.Sprintf("%s:%s", customImage, tag)
839+
targetCloudImageName = fmt.Sprintf("%s:%s", customImage, targetTag)
844840
} else {
845-
targetCloudImageName = fmt.Sprintf(cloudImageTmpl, tag)
841+
targetCloudImageName = fmt.Sprintf(cloudImageTmpl, targetTag)
846842
}
847843

848844
fmt.Printf(">> Setting a docker image tag to %s\n", targetCloudImageName)
849-
err := sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName)
845+
err = sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName)
850846
if err != nil {
851-
return fmt.Errorf("Failed setting a docker image tag: %w", err)
847+
return fmt.Errorf("failed setting a docker image tag: %w", err)
852848
}
853849
fmt.Println(">> Docker image tag updated successfully")
854850

855851
fmt.Println(">> Pushing a docker image to remote registry")
856852
err = sh.RunV("docker", "image", "push", targetCloudImageName)
857853
if err != nil {
858-
return fmt.Errorf("Failed pushing docker image: %w", err)
854+
return fmt.Errorf("failed pushing docker image: %w", err)
859855
}
860856
fmt.Printf(">> Docker image pushed to remote registry successfully: %s\n", targetCloudImageName)
861857

testing/integration/upgrade_broken_package_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestUpgradeBrokenPackageVersion(t *testing.T) {
3131
Local: false, // requires Agent installation
3232
Sudo: true, // requires Agent installation
3333
})
34+
t.Skip("Skip this test until elastic agent version pinning is removed from Integration test runs on CI")
3435

3536
ctx, cancel := testcontext.WithDeadline(t, context.Background(), time.Now().Add(10*time.Minute))
3637
defer cancel()

0 commit comments

Comments
 (0)