Skip to content

Commit 4c14480

Browse files
authored
Merge branch 'main' into dependabot/go_modules/github.com/elastic/elastic-agent-autodiscover-0.6.7
2 parents a0b706d + 5ce913e commit 4c14480

File tree

84 files changed

+9010
-636
lines changed

Some content is hidden

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

84 files changed

+9010
-636
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

.github/workflows/bump-golang.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ name: bump-golang
44
on:
55
workflow_dispatch:
66
schedule:
7-
- cron: "0 20 * * 6"
7+
- cron: "0 20 * * 1-6"
88

99
permissions:
1010
contents: read
1111

12+
env:
13+
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
14+
1215
jobs:
1316
bump:
1417
runs-on: ubuntu-latest
@@ -21,3 +24,5 @@ jobs:
2124
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
2225
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
2326
pipeline: ./.github/updatecli-bump-golang.yml
27+
notifySlackChannel: "#ingest-notifications"
28+
messageIfFailure: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, `@agent-team` please look what's going on <${{ env.JOB_URL }}|here>"

.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

+250-250
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

+6-4
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ spec:
4848
filter_condition: >-
4949
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
5050
cancel_intermediate_builds: true
51-
cancel_intermediate_builds_branch_filter: "!main"
51+
cancel_intermediate_builds_branch_filter: '!main !7.* !8.* !9.*'
5252
skip_intermediate_builds: true
53-
skip_intermediate_builds_branch_filter: "!main"
53+
skip_intermediate_builds_branch_filter: '!main !7.* !8.* !9.*'
5454
env:
5555
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
5656
SLACK_NOTIFICATIONS_CHANNEL: "#ingest-notifications"
@@ -96,14 +96,16 @@ spec:
9696
filter_condition: >-
9797
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
9898
cancel_intermediate_builds: true
99-
cancel_intermediate_builds_branch_filter: "!main"
99+
cancel_intermediate_builds_branch_filter: '!main !7.* !8.* !9.*'
100100
skip_intermediate_builds: true
101-
skip_intermediate_builds_branch_filter: "!main"
101+
skip_intermediate_builds_branch_filter: '!main !7.* !8.* !9.*'
102102
teams:
103103
ingest-fp:
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ require (
5454
github.com/shirou/gopsutil/v3 v3.23.12
5555
github.com/sirupsen/logrus v1.9.3
5656
github.com/spf13/cobra v1.8.0
57+
github.com/spf13/pflag v1.0.5
5758
github.com/stretchr/testify v1.8.4
5859
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b
5960
go.elastic.co/apm/module/apmgorilla v1.15.0
@@ -64,6 +65,7 @@ require (
6465
go.opentelemetry.io/collector/exporter v0.93.0
6566
go.opentelemetry.io/collector/exporter/debugexporter v0.93.0
6667
go.opentelemetry.io/collector/exporter/otlpexporter v0.93.0
68+
go.opentelemetry.io/collector/featuregate v1.0.1
6769
go.opentelemetry.io/collector/otelcol v0.93.0
6870
go.opentelemetry.io/collector/processor v0.93.0
6971
go.opentelemetry.io/collector/processor/batchprocessor v0.93.0
@@ -187,7 +189,6 @@ require (
187189
github.com/sergi/go-diff v1.2.0 // indirect
188190
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
189191
github.com/shoenig/go-m1cpu v0.1.6 // indirect
190-
github.com/spf13/pflag v1.0.5 // indirect
191192
github.com/stretchr/objx v0.5.0 // indirect
192193
github.com/tklauser/go-sysconf v0.3.12 // indirect
193194
github.com/tklauser/numcpus v0.6.1 // indirect
@@ -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) {

0 commit comments

Comments
 (0)