Skip to content

Commit 9401374

Browse files
[8.18](backport #8736) ci: pin elastic-agent version (#8749)
* 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/scripts/buildkite-integration-tests.sh # magefile.go * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <[email protected]>
1 parent 1cf3603 commit 9401374

File tree

7 files changed

+36
-25
lines changed

7 files changed

+36
-25
lines changed

.buildkite/bk.integration.pipeline.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ env:
1212
IMAGE_DEBIAN_12: "platform-ingest-elastic-agent-debian-12-1750467641"
1313
IMAGE_WIN_2022: "platform-ingest-elastic-agent-windows-2022-1750467641"
1414
IMAGE_WIN_2025: "platform-ingest-elastic-agent-windows-2025-1750467641"
15+
# Remove AGENT_VERSION pinning once 8.18.4 DRA and stack are released
16+
AGENT_VERSION: "8.18.3-SNAPSHOT"
17+
1518

1619
# This section is used to define the plugins that will be used in the pipeline.
1720
# 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.18.4 DRA and stack are released
6+
AGENT_PACKAGE_VERSION: "8.18.3"
7+
BEAT_VERSION: "8.18.3"
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
@@ -880,41 +880,37 @@ func (Cloud) Image(ctx context.Context) {
880880
// Push builds a cloud image tags it correctly and pushes to remote image repo.
881881
// Previous login to elastic registry is required!
882882
func (Cloud) Push() error {
883-
snapshot := os.Getenv(snapshotEnv)
884-
defer os.Setenv(snapshotEnv, snapshot)
885-
886-
os.Setenv(snapshotEnv, "true")
883+
agentVersion, err := mage.AgentPackageVersion()
884+
if err != nil {
885+
return fmt.Errorf("failed to get agent package version: %w", err)
886+
}
887887

888-
version := getVersion()
889-
var tag string
888+
var targetTag string
890889
if envTag, isPresent := os.LookupEnv("CUSTOM_IMAGE_TAG"); isPresent && len(envTag) > 0 {
891-
tag = envTag
890+
targetTag = envTag
892891
} else {
893-
commit := dockerCommitHash()
894-
time := time.Now().Unix()
895-
896-
tag = fmt.Sprintf("%s-%s-%d", version, commit, time)
892+
targetTag = fmt.Sprintf("%s-%s-%d", agentVersion, dockerCommitHash(), time.Now().Unix())
897893
}
898894

899-
sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s", version)
895+
sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s-SNAPSHOT", agentVersion)
900896
var targetCloudImageName string
901897
if customImage, isPresent := os.LookupEnv("CI_ELASTIC_AGENT_DOCKER_IMAGE"); isPresent && len(customImage) > 0 {
902-
targetCloudImageName = fmt.Sprintf("%s:%s", customImage, tag)
898+
targetCloudImageName = fmt.Sprintf("%s:%s", customImage, targetTag)
903899
} else {
904-
targetCloudImageName = fmt.Sprintf(cloudImageTmpl, tag)
900+
targetCloudImageName = fmt.Sprintf(cloudImageTmpl, targetTag)
905901
}
906902

907903
fmt.Printf(">> Setting a docker image tag to %s\n", targetCloudImageName)
908-
err := sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName)
904+
err = sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName)
909905
if err != nil {
910-
return fmt.Errorf("Failed setting a docker image tag: %w", err)
906+
return fmt.Errorf("failed setting a docker image tag: %w", err)
911907
}
912908
fmt.Println(">> Docker image tag updated successfully")
913909

914910
fmt.Println(">> Pushing a docker image to remote registry")
915911
err = sh.RunV("docker", "image", "push", targetCloudImageName)
916912
if err != nil {
917-
return fmt.Errorf("Failed pushing docker image: %w", err)
913+
return fmt.Errorf("failed pushing docker image: %w", err)
918914
}
919915
fmt.Printf(">> Docker image pushed to remote registry successfully: %s\n", targetCloudImageName)
920916

testing/integration/ess/upgrade_broken_package_test.go

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

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

0 commit comments

Comments
 (0)