-
Notifications
You must be signed in to change notification settings - Fork 118
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
Add initial support for Elastic Stack 9.x #2102
Changes from all commits
164e1ca
1135e80
2636638
031aa4b
03ad1e9
0dd9078
d447532
10a5d76
332c2e5
d918cc2
40deb26
afee3c6
168ae0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
name: Bump latest 9.x-SNAPSHOT elastic-stack test version | ||
pipelineid: 'bump-latest-9x-elastic-stack-version' | ||
|
||
actions: | ||
default: | ||
title: '[updatecli] Update latest snapshot to {{ source "latestSnapshot" }}' | ||
kind: github/pullrequest | ||
scmid: default | ||
spec: | ||
labels: | ||
- automation | ||
- dependency | ||
|
||
scms: | ||
default: | ||
kind: github | ||
spec: | ||
owner: '{{ .scm.owner }}' | ||
repository: '{{ .scm.repository }}' | ||
user: '{{ requiredEnv "GITHUB_ACTOR" }}' | ||
username: '{{ requiredEnv "GITHUB_ACTOR" }}' | ||
token: '{{ requiredEnv "GITHUB_TOKEN" }}' | ||
commitusingapi: true | ||
branch: main | ||
|
||
sources: | ||
latestSnapshot: | ||
name: Get latest snapshot build | ||
kind: json | ||
spec: | ||
file: https://storage.googleapis.com/artifacts-api/snapshots/main.json | ||
key: .build_id | ||
|
||
targets: | ||
update-snapshot: | ||
name: '[updatecli] Update latest snapshot to {{ source "latestSnapshot" }}' | ||
kind: file | ||
sourceid: latestSnapshot | ||
scmid: default | ||
spec: | ||
file: Makefile | ||
matchpattern: '(./scripts/test-stack-command.sh) 9\.[^\s]+-SNAPSHOT' | ||
replacepattern: '$1 {{ source "latestSnapshot" }}-SNAPSHOT' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,13 +153,13 @@ func (ac *ApplicationConfiguration) SetCurrentProfile(name string) { | |
// This is mandatory as "elastic-agent-complete" is available since 7.15.0-SNAPSHOT. | ||
func selectElasticAgentImageName(version, agentBaseImage string) string { | ||
if version == "" { // as version is optional and can be empty | ||
return elasticAgentLegacyImageName | ||
return elasticAgentWolfiImageName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT about changing these defaults values to use the wolfi image docker.elastic.co/elastic-agent/elastic-agent-wolfi (e.g. no version specified) instead of the legacy image (beats namespace) docker.elastic.co/beats/elastic-agent? Or should we keep unchanged this default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can adapt this to the new default, yes, if we are sure that in old versions the beats namespace is used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the same behaviour is kept.
|
||
} | ||
|
||
v, err := semver.NewVersion(version) | ||
if err != nil { | ||
logger.Errorf("stack version not in semver format (value: %s): %v", v, err) | ||
return elasticAgentLegacyImageName | ||
logger.Errorf("stack version not in semver format (value: %s): %v", version, err) | ||
return elasticAgentWolfiImageName | ||
} | ||
|
||
disableWolfiImages := false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it is now, the Elastic Agent image is chosen as:
Would that be ok? Specially if stack version is set to 9.0.0 and the environment variable to disable wolfi is set to true. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the same set of images is going to be available in 9.0 keeping the same logic sounds good to me. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,43 +14,43 @@ import ( | |
func TestSelectElasticAgentImageName_NoVersion(t *testing.T) { | ||
var version string | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentLegacyImageName) | ||
assert.Equal(t, elasticAgentWolfiImageName, selected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the test changing the value, it would return the wolfi image instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In principle it LGTM. Maybe another option is to return an error if the version is empty? Not sure about the implications of the change, but would look safer to me to know where/if we are passing an empty version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commands like |
||
} | ||
|
||
func TestSelectElasticAgentImageName_OlderStack(t *testing.T) { | ||
version := "7.14.99-SNAPSHOT" | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentLegacyImageName) | ||
assert.Equal(t, elasticAgentLegacyImageName, selected) | ||
} | ||
|
||
func TestSelectElasticAgentImageName_FirstStackWithCompleteAgent(t *testing.T) { | ||
version := stackVersion715 | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentCompleteLegacyImageName) | ||
assert.Equal(t, elasticAgentCompleteLegacyImageName, selected) | ||
} | ||
|
||
func TestSelectElasticAgentImageName_NextStackWithAgentComplete(t *testing.T) { | ||
version := "7.16.0-SNAPSHOT" | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentCompleteLegacyImageName) | ||
assert.Equal(t, elasticAgentCompleteLegacyImageName, selected) | ||
} | ||
|
||
func TestSelectElasticAgentImageName_OwnNamespace(t *testing.T) { | ||
version := "8.2.0-SNAPSHOT" | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentCompleteImageName) | ||
assert.Equal(t, elasticAgentCompleteImageName, selected) | ||
} | ||
|
||
func TestSelectElasticAgentImageName_OwnNamespace_Release(t *testing.T) { | ||
version := "8.2.0" | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentCompleteImageName) | ||
assert.Equal(t, elasticAgentCompleteImageName, selected) | ||
} | ||
|
||
func TestSelectElasticAgentImageName_NextStackInOwnNamespace(t *testing.T) { | ||
version := "8.4.0-SNAPSHOT" | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentCompleteImageName) | ||
assert.Equal(t, elasticAgentCompleteImageName, selected) | ||
} | ||
|
||
func TestSelectElasticAgentImageName_DefaultImage816_WithoutEnvVar(t *testing.T) { | ||
|
@@ -60,56 +60,56 @@ func TestSelectElasticAgentImageName_DefaultImage816_WithoutEnvVar(t *testing.T) | |
os.Unsetenv(disableElasticAgentWolfiEnvVar) | ||
|
||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentWolfiImageName) | ||
assert.Equal(t, elasticAgentWolfiImageName, selected) | ||
} | ||
|
||
func TestSelectElasticAgentImageName_DisableWolfiImageEnvVar(t *testing.T) { | ||
version := stackVersion8160 | ||
t.Setenv(disableElasticAgentWolfiEnvVar, "true") | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentCompleteImageName) | ||
assert.Equal(t, elasticAgentCompleteImageName, selected) | ||
} | ||
func TestSelectElasticAgentImageName_EnableWolfiImageEnvVar(t *testing.T) { | ||
version := stackVersion8160 | ||
t.Setenv(disableElasticAgentWolfiEnvVar, "false") | ||
selected := selectElasticAgentImageName(version, "") | ||
assert.Equal(t, selected, elasticAgentWolfiImageName) | ||
assert.Equal(t, elasticAgentWolfiImageName, selected) | ||
} | ||
|
||
func TestSelectCompleteElasticAgentImageName_ForceCompleteImage(t *testing.T) { | ||
version := stackVersion8160 | ||
selected := selectElasticAgentImageName(version, "complete") | ||
assert.Equal(t, selected, elasticAgentCompleteImageName) | ||
assert.Equal(t, elasticAgentCompleteImageName, selected) | ||
} | ||
|
||
func TestSelectCompleteElasticAgentImageName_ForceDefaultImage_DisabledEnvVar(t *testing.T) { | ||
version := stackVersion8160 | ||
t.Setenv(disableElasticAgentWolfiEnvVar, "true") | ||
selected := selectElasticAgentImageName(version, "default") | ||
assert.Equal(t, selected, elasticAgentCompleteImageName) | ||
assert.Equal(t, elasticAgentCompleteImageName, selected) | ||
} | ||
|
||
func TestSelectCompleteElasticAgentImageName_ForceDefaultImage_EnabledEnvVar(t *testing.T) { | ||
version := stackVersion8160 | ||
t.Setenv(disableElasticAgentWolfiEnvVar, "false") | ||
selected := selectElasticAgentImageName(version, "default") | ||
assert.Equal(t, selected, elasticAgentWolfiImageName) | ||
assert.Equal(t, elasticAgentWolfiImageName, selected) | ||
} | ||
|
||
func TestSelectCompleteElasticAgentImageName_ForceDefaultImageOldStack(t *testing.T) { | ||
version := "8.15.0-SNAPSHOT" | ||
selected := selectElasticAgentImageName(version, "default") | ||
assert.Equal(t, selected, elasticAgentCompleteImageName) | ||
assert.Equal(t, elasticAgentCompleteImageName, selected) | ||
} | ||
|
||
func TestSelectCompleteElasticAgentImageName_ForceSystemDImage(t *testing.T) { | ||
version := stackVersion8160 | ||
selected := selectElasticAgentImageName(version, "systemd") | ||
assert.Equal(t, selected, elasticAgentImageName) | ||
assert.Equal(t, elasticAgentImageName, selected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the order to ensure that the values are the expected and the actual ones as required by the assert functions. |
||
} | ||
|
||
func TestSelectCompleteElasticAgentImageName_ForceSystemDImageOldStack(t *testing.T) { | ||
version := stackVersion715 | ||
selected := selectElasticAgentImageName(version, "systemd") | ||
assert.Equal(t, selected, elasticAgentLegacyImageName) | ||
assert.Equal(t, elasticAgentLegacyImageName, selected) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required to remove
v
from the version string for the chocolotey tool. Currently, this environment variable has this valuev2.24.1
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, how has it worked in the past?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, it was failing in the past too. I realized that even if with those commands were failing, the execution of the script continued.
I see that at the beginning of the file is defined
but it does not stopped the execution. Not sure if choco command does not return any error in that scenario, or when the error is inside a function there are some differences in how to manage the errors.