Skip to content

Commit 9fcb65a

Browse files
Merge branch 'main' into dependabot/go_modules/github.com/elastic/go-elasticsearch/v8-8.11.0
2 parents 2b23885 + d8f5134 commit 9fcb65a

File tree

78 files changed

+8624
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+8624
-486
lines changed

.buildkite/hooks/pre-command.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ go version
1414

1515
$GOPATH = $(go env GOPATH)
1616
$env:Path = "$GOPATH\bin;" + $env:Path
17+
$env:GOTMPDIR = "$GOPATH\tmp"
18+
New-Item -ItemType Directory -Force -Path $env:GOTMPDIR
1719
[Environment]::SetEnvironmentVariable("GOPATH", "$GOPATH", [EnvironmentVariableTarget]::Machine)
20+
[Environment]::SetEnvironmentVariable("GOTMPDIR", "$GOPATH\tmp", [EnvironmentVariableTarget]::Machine)
1821
[Environment]::SetEnvironmentVariable("Path", "$GOPATH\bin;$env:Path", [EnvironmentVariableTarget]::Machine)
22+
go env
1923

2024
# Install tools
2125
go install github.com/magefile/mage

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/deploy/kubernetes @elastic/obs-cloudnative-monitoring
55
/dev-tools/kubernetes @elastic/obs-cloudnative-monitoring
66
/internal/pkg/composable/providers/kubernetes @elastic/obs-cloudnative-monitoring
7+
/internal/pkg/agent/application/configuration_embed_changed_test.go @elastic/cloudbeat

.go-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.21.6
1+
1.21.7

.golangci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ linters-settings:
116116

117117
gosimple:
118118
# Select the Go version to target. The default is '1.13'.
119-
go: "1.21.6"
119+
go: "1.21.7"
120120

121121
nakedret:
122122
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
@@ -136,17 +136,17 @@ linters-settings:
136136

137137
staticcheck:
138138
# Select the Go version to target. The default is '1.13'.
139-
go: "1.21.6"
139+
go: "1.21.7"
140140
checks: ["all"]
141141

142142
stylecheck:
143143
# Select the Go version to target. The default is '1.13'.
144-
go: "1.21.6"
144+
go: "1.21.7"
145145
checks: ["all"]
146146

147147
unused:
148148
# Select the Go version to target. The default is '1.13'.
149-
go: "1.21.6"
149+
go: "1.21.7"
150150

151151
gosec:
152152
excludes:

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GO_VERSION=1.21.6
1+
ARG GO_VERSION=1.21.7
22
FROM circleci/golang:${GO_VERSION}
33

44

Dockerfile.skaffold

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GO_VERSION=1.21.6
1+
ARG GO_VERSION=1.21.7
22
ARG crossbuild_image="docker.elastic.co/beats-dev/golang-crossbuild"
33
ARG AGENT_VERSION=8.9.0-SNAPSHOT
44
ARG AGENT_IMAGE="docker.elastic.co/beats/elastic-agent"

NOTICE.txt

+212-212
Large diffs are not rendered by default.

_meta/config/providers.yml.tmpl

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
# and conditionals. Each provider's keys are automatically prefixed with the name
55
# of the provider.
66

7+
# All registered providers are enabled by default.
8+
9+
# Disable all providers by default and only enable explicitly configured providers.
10+
# agent.providers.initial_default: false
11+
712
#providers:
813

914
# Agent provides information about the running agent.

catalog-info.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ spec:
104104
access_level: MANAGE_BUILD_AND_READ
105105
release-eng:
106106
access_level: BUILD_AND_READ
107+
endpoint-ci-admin:
108+
access_level: BUILD_AND_READ
107109
everyone:
108110
access_level: READ_ONLY
109111

changelog/fragments/1704304944-Upgrade-to-Go-1.21.6.yaml changelog/fragments/1704304944-Upgrade-to-Go-1.21.7.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
kind: security
1212

1313
# Change summary; a 80ish characters long description of the change.
14-
summary: Upgrade to Go 1.21.6
14+
summary: Upgrade to Go 1.21.7
1515

1616
# Long description; in case the summary is not enough to describe the change
1717
# this field accommodate a description without length limits.
1818
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
19-
# description:
19+
description: Removes support for Windows 8.1. See https://tip.golang.org/doc/go1.21#windows.
2020

2121
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
2222
component: "elastic-agent"
@@ -25,7 +25,7 @@ component: "elastic-agent"
2525
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
2626
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
2727
# Please provide it if you are adding a fragment for a different PR.
28-
pr: https://github.com/elastic/elastic-agent/pull/4073
28+
pr: https://github.com/elastic/elastic-agent/pull/4221
2929

3030
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
3131
# If not present is automatically filled by the tooling with the issue linked to the PR number.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Kind can be one of:
2+
# - breaking-change: a change to previously-documented behavior
3+
# - deprecation: functionality that is being removed in a later release
4+
# - bug-fix: fixes a problem in a previous version
5+
# - enhancement: extends functionality but does not break or fix existing behavior
6+
# - feature: new functionality
7+
# - known-issue: problems that we are aware of in a given version
8+
# - security: impacts on the security of a product or a user’s deployment.
9+
# - upgrade: important information for someone upgrading from a prior version
10+
# - other: does not fit into any of the other categories
11+
kind: enhancement
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: Add agent.providers.initial_default configuration flag to disable providers by default
15+
16+
# Long description; in case the summary is not enough to describe the change
17+
# this field accommodate a description without length limits.
18+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
19+
#description:
20+
21+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
22+
component: elastic-agent
23+
24+
# PR URL; optional; the PR number that added the changeset.
25+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
26+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
27+
# Please provide it if you are adding a fragment for a different PR.
28+
pr: https://github.com/elastic/elastic-agent/pull/4166
29+
30+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
31+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
32+
issue: https://github.com/elastic/elastic-agent/issues/4145

docs/test-framework-dev-guide.md

+80
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,60 @@ when running them manually, such as `ELASTICSEARCH_HOST`, `ELASTICSEARCH_USERNAM
134134

135135
### Debugging tests
136136

137+
#### Manually debugging tests on VMs
138+
Many of the integration tests will install the Elastic-Agent and/or
139+
require root to run, which makes it hard to just run them on our work
140+
machines, the best way to circumvent that is to debug the tests
141+
directly on a VM. `mage integration:DeployDebugTools` will show a menu
142+
to select a VM and then install the common debugging tools: Delve,
143+
Mage and Docker. It will also create the `~/elastic-agent` folder
144+
containing the Git repository (required to package from within the VM)
145+
and the last version of the code uploaded to the VM. This allows you
146+
to easily build/package the Elastic-Agent from within the VM as well
147+
as run any tests.
148+
149+
After deploying the debug tools, `mage integrationDeployEnvFile` will
150+
create a `env.sh` and copy it to a selected VM, sourcing it will allow
151+
you to any test against the Cloud Stack you selected.
152+
153+
Example of how to run a test from within the VM:
154+
```
155+
## Run a single test
156+
SNAPSHOT=true TEST_PLATFORMS="linux/amd64" mage integration:single TestLogIngestionFleetManaged
157+
## Let's suppose it has failed
158+
159+
## Install DebugTools
160+
mage -v integration:DeployDebugTools
161+
162+
## Generate and deploy env file
163+
mage -v integration:DeployEnvFile
164+
165+
## SSH into the VM
166+
$(mage integration:SSHVM)
167+
168+
## From inside the VM, the test needs root
169+
sudo su
170+
source ./env.sh
171+
cd elastic-agent
172+
## Any flags passed to the test binary go after the '--', they also need to
173+
## include the `test.` prefix if they're for `go test`
174+
TEST_DEFINE_PREFIX=gambiarra dlv test ./testing/integration/ --build-flags="-tags integration" -- -test.v -test.run TestLogIngestionFleetManaged
175+
```
176+
177+
**A Delve trick**
178+
If you didn't build the Elastic-Agent directly on the machine you're
179+
debugging, it is very likely the location of the source code is
180+
different, hence delve cannot show you the code it is running. To
181+
solve this, once on Delve shell, run:
182+
``
183+
config substitute-path /go/src/github.com/elastic/elastic-agent /home/ubuntu/elastic-agent`
184+
``
185+
where:
186+
- `/go/src/github.com/elastic/elastic-agent` is the path annotated in
187+
the binary you are debugging (the one Delve shows).
188+
- `/home/ubuntu/elastic-agent` is where Delve should read the source
189+
code form.
190+
137191
#### Auto diagnostics retrieval
138192
When an integration test fails the testing fixture will try its best to automatically collect the diagnostic
139193
information of the installed Elastic Agent. In the case that diagnostics is collected the test runner will
@@ -172,6 +226,32 @@ with `go test`. E.g.:
172226
TEST_DEFINE_PREFIX=gambiarra go test -v -tags integration -run TestProxyURL ./testing/integration/
173227
```
174228

229+
## Connecting to VMs and running tests
230+
### Connecting to VMs
231+
All VMs (including Windows) support connections via SSH, the framework
232+
generates and stores the necessary SSH keys to access the VMs, the
233+
easiest way to connect to them is using the SSH command returned by
234+
`mage integration:SSHVM`. It will list the VMs and ask to select
235+
one.
236+
237+
On a Unix shell you can run `$(mage integration:SSHVM)`, the menu is
238+
printed to stderr and the SSH command to stdout. After selecting the
239+
VM you will have shell connected to it.
240+
241+
### Credentials for cloud stack/projects
242+
All cloud deployments and projects can be listed with `mage
243+
integration:listStacks`, they can be used to manually connect to
244+
Kibana and Elasticsearch.
245+
246+
If you need to manually run tests against any deployments, `mage
247+
integration:GenerateEnvFile` will generate a file called `env.sh` that
248+
exports environment variables for Unix compatible shells, you can load
249+
them into your shell by running `source ./env.sh`.
250+
251+
To easily deploy the credentials to any VM, just run `mage
252+
integration:DeployEnvFile`. A menu will ask for the desired Stack and
253+
VM.
254+
175255
## Writing tests
176256

177257
Write integration and E2E tests by adding them to the `testing/integration`

elastic-agent.docker.yml

+5
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ agent.logging.to_stderr: true
218218
# and conditionals. Each provider's keys are automatically prefixed with the name
219219
# of the provider.
220220

221+
# All registered providers are enabled by default.
222+
223+
# Disable all providers by default and only enable explicitly configured providers.
224+
# agent.providers.initial_default: false
225+
221226
#providers:
222227

223228
# Agent provides information about the running agent.

elastic-agent.reference.yml

+5
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ agent.logging.to_stderr: true
271271
# and conditionals. Each provider's keys are automatically prefixed with the name
272272
# of the provider.
273273

274+
# All registered providers are enabled by default.
275+
276+
# Disable all providers by default and only enable explicitly configured providers.
277+
# agent.providers.initial_default: false
278+
274279
#providers:
275280

276281
# Agent provides information about the running agent.

elastic-agent.yml

+5
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ agent.logging.to_stderr: true
261261
# and conditionals. Each provider's keys are automatically prefixed with the name
262262
# of the provider.
263263

264+
# All registered providers are enabled by default.
265+
266+
# Disable all providers by default and only enable explicitly configured providers.
267+
# agent.providers.initial_default: false
268+
264269
#providers:
265270

266271
# Agent provides information about the running agent.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ require (
6565
go.opentelemetry.io/collector/exporter v0.93.0
6666
go.opentelemetry.io/collector/exporter/debugexporter v0.93.0
6767
go.opentelemetry.io/collector/exporter/otlpexporter v0.93.0
68+
go.opentelemetry.io/collector/featuregate v1.0.1
6869
go.opentelemetry.io/collector/otelcol v0.93.0
6970
go.opentelemetry.io/collector/processor v0.93.0
7071
go.opentelemetry.io/collector/processor/batchprocessor v0.93.0
@@ -214,7 +215,6 @@ require (
214215
go.opentelemetry.io/collector/consumer v0.93.0 // indirect
215216
go.opentelemetry.io/collector/extension v0.93.0 // indirect
216217
go.opentelemetry.io/collector/extension/auth v0.93.0 // indirect
217-
go.opentelemetry.io/collector/featuregate v1.0.1 // indirect
218218
go.opentelemetry.io/collector/pdata v1.0.1 // indirect
219219
go.opentelemetry.io/collector/semconv v0.93.0 // indirect
220220
go.opentelemetry.io/collector/service v0.93.0 // indirect

internal/pkg/agent/application/actions/handlers/handler_action_policy_change.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
// PolicyChangeHandler is a handler for POLICY_CHANGE action.
3838
type PolicyChangeHandler struct {
3939
log *logger.Logger
40-
agentInfo *info.AgentInfo
40+
agentInfo info.Agent
4141
config *configuration.Configuration
4242
store storage.Store
4343
ch chan coordinator.ConfigChange
@@ -52,7 +52,7 @@ type PolicyChangeHandler struct {
5252
// NewPolicyChangeHandler creates a new PolicyChange handler.
5353
func NewPolicyChangeHandler(
5454
log *logger.Logger,
55-
agentInfo *info.AgentInfo,
55+
agentInfo info.Agent,
5656
config *configuration.Configuration,
5757
store storage.Store,
5858
ch chan coordinator.ConfigChange,
@@ -264,7 +264,7 @@ func clientEqual(k1 remote.Config, k2 remote.Config) bool {
264264
return true
265265
}
266266

267-
func fleetToReader(agentInfo *info.AgentInfo, cfg *configuration.Configuration) (io.Reader, error) {
267+
func fleetToReader(agentInfo info.Agent, cfg *configuration.Configuration) (io.Reader, error) {
268268
configToStore := map[string]interface{}{
269269
"fleet": cfg.Fleet,
270270
"agent": map[string]interface{}{

internal/pkg/agent/application/actions/handlers/handler_action_policy_change_test.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ func TestPolicyChange(t *testing.T) {
3434
log, _ := logger.New("", false)
3535
ack := noopacker.New()
3636

37-
ctx, cancel := context.WithCancel(context.Background())
38-
defer cancel()
39-
40-
agentInfo, _ := info.NewAgentInfo(ctx, true)
37+
agentInfo := &info.AgentInfo{}
4138
nullStore := &storage.NullStore{}
4239

4340
t.Run("Receive a config change and successfully emits a raw configuration", func(t *testing.T) {
@@ -63,10 +60,8 @@ func TestPolicyChange(t *testing.T) {
6360

6461
func TestPolicyAcked(t *testing.T) {
6562
log, _ := logger.New("", false)
66-
ctx, cancel := context.WithCancel(context.Background())
67-
defer cancel()
6863

69-
agentInfo, _ := info.NewAgentInfo(ctx, true)
64+
agentInfo := &info.AgentInfo{}
7065
nullStore := &storage.NullStore{}
7166

7267
t.Run("Config change should ACK", func(t *testing.T) {

internal/pkg/agent/application/actions/handlers/handler_action_settings.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import (
2020
// Settings handles settings change coming from fleet and updates log level.
2121
type Settings struct {
2222
log *logger.Logger
23-
agentInfo *info.AgentInfo
23+
agentInfo info.Agent
2424
coord *coordinator.Coordinator
2525
}
2626

2727
// NewSettings creates a new Settings handler.
2828
func NewSettings(
2929
log *logger.Logger,
30-
agentInfo *info.AgentInfo,
30+
agentInfo info.Agent,
3131
coord *coordinator.Coordinator,
3232
) *Settings {
3333
return &Settings{

internal/pkg/agent/application/actions/handlers/handler_action_upgrade_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ func TestUpgradeHandler(t *testing.T) {
6363
defer cancel()
6464

6565
log, _ := logger.New("", false)
66-
agentInfo, _ := info.NewAgentInfo(ctx, true)
66+
67+
agentInfo := &info.AgentInfo{}
6768
msgChan := make(chan string)
6869

6970
// Create and start the coordinator
@@ -95,7 +96,8 @@ func TestUpgradeHandlerSameVersion(t *testing.T) {
9596
defer cancel()
9697

9798
log, _ := logger.New("", false)
98-
agentInfo, _ := info.NewAgentInfo(ctx, true)
99+
100+
agentInfo := &info.AgentInfo{}
99101
msgChan := make(chan string)
100102

101103
// Create and start the Coordinator
@@ -129,7 +131,8 @@ func TestUpgradeHandlerNewVersion(t *testing.T) {
129131
defer cancel()
130132

131133
log, _ := logger.New("", false)
132-
agentInfo, _ := info.NewAgentInfo(ctx, true)
134+
135+
agentInfo := &info.AgentInfo{}
133136
msgChan := make(chan string)
134137

135138
// Create and start the Coordinator

0 commit comments

Comments
 (0)