Skip to content

Commit 9a8765a

Browse files
[9.0](backport #8736) ci: pin elastic-agent version (#8750)
* 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 * fix: correct 9.0.3 agent version --------- Co-authored-by: Panos Koutsovasilis <[email protected]>
1 parent 53fc088 commit 9a8765a

File tree

7 files changed

+37
-26
lines changed

7 files changed

+37
-26
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_PACKAGE_VERSION pinning once 9.0.4 DRA and stack are released
16+
AGENT_VERSION: "9.0.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 BEAT_VERSION pinning once 9.0.4 DRA and stack are released
6+
AGENT_PACKAGE_VERSION: "9.0.3"
7+
BEAT_VERSION: "9.0.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: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -889,48 +889,44 @@ func (Cloud) Image(ctx context.Context) {
889889
// Push builds a cloud image tags it correctly and pushes to remote image repo.
890890
// Previous login to elastic registry is required!
891891
func (Cloud) Push() error {
892-
snapshot := os.Getenv(snapshotEnv)
893-
defer os.Setenv(snapshotEnv, snapshot)
894-
895-
os.Setenv(snapshotEnv, "true")
892+
agentVersion, err := mage.AgentPackageVersion()
893+
if err != nil {
894+
return fmt.Errorf("failed to get agent package version: %w", err)
895+
}
896896

897-
version := getVersion()
898-
var tag string
897+
var targetTag string
899898
if envTag, isPresent := os.LookupEnv("CUSTOM_IMAGE_TAG"); isPresent && len(envTag) > 0 {
900-
tag = envTag
899+
targetTag = envTag
901900
} else {
902-
commit := dockerCommitHash()
903-
time := time.Now().Unix()
904-
905-
tag = fmt.Sprintf("%s-%s-%d", version, commit, time)
901+
targetTag = fmt.Sprintf("%s-%s-%d", agentVersion, dockerCommitHash(), time.Now().Unix())
906902
}
907903

908-
sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s", version)
904+
sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s-SNAPSHOT", agentVersion)
909905
var targetCloudImageName string
910906
if customImage, isPresent := os.LookupEnv("CI_ELASTIC_AGENT_DOCKER_IMAGE"); isPresent && len(customImage) > 0 {
911-
targetCloudImageName = fmt.Sprintf("%s:%s", customImage, tag)
907+
targetCloudImageName = fmt.Sprintf("%s:%s", customImage, targetTag)
912908
} else {
913-
targetCloudImageName = fmt.Sprintf(cloudImageTmpl, tag)
909+
targetCloudImageName = fmt.Sprintf(cloudImageTmpl, targetTag)
914910
}
915911

916912
fmt.Printf(">> Setting a docker image tag to %s\n", targetCloudImageName)
917-
err := sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName)
913+
err = sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName)
918914
if err != nil {
919-
return fmt.Errorf("Failed setting a docker image tag: %w", err)
915+
return fmt.Errorf("failed setting a docker image tag: %w", err)
920916
}
921917
fmt.Println(">> Docker image tag updated successfully")
922918

923919
fmt.Println(">> Pushing a docker image to remote registry")
924920
err = sh.RunV("docker", "image", "push", targetCloudImageName)
925921
if err != nil {
926-
return fmt.Errorf("Failed pushing docker image: %w", err)
922+
return fmt.Errorf("failed pushing docker image: %w", err)
927923
}
928924
fmt.Printf(">> Docker image pushed to remote registry successfully: %s\n", targetCloudImageName)
929925

930926
return nil
931927
}
932928

933-
// Creates a new devmachine that will be auto-deleted in 6 hours.
929+
// Create a new devmachine that will be auto-deleted in 6 hours.
934930
// Example: MACHINE_IMAGE="family/platform-ingest-elastic-agent-ubuntu-2204" ZONE="us-central1-a" mage devmachine:create "pavel-dev-machine"
935931
// ZONE defaults to 'us-central1-a', MACHINE_IMAGE defaults to 'family/platform-ingest-elastic-agent-ubuntu-2204'
936932
func (Devmachine) Create(instanceName string) error {

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)