Skip to content

Commit 9480df4

Browse files
authored
Merge branch 'main' into golangci-lint-modernize
2 parents 77d5ba6 + b6e6fc1 commit 9480df4

44 files changed

Lines changed: 1364 additions & 752 deletions

Some content is hidden

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

NOTICE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10798,11 +10798,11 @@ SOFTWARE
1079810798

1079910799
--------------------------------------------------------------------------------
1080010800
Dependency : github.com/elastic/elastic-agent-libs
10801-
Version: v0.45.0
10801+
Version: v0.46.1
1080210802
Licence type (autodetected): Apache-2.0
1080310803
--------------------------------------------------------------------------------
1080410804

10805-
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.45.0/LICENSE:
10805+
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.46.1/LICENSE:
1080610806

1080710807
Apache License
1080810808
Version 2.0, January 2004
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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: bug-fix
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: Emit pack_name and query_name in osquerybeat scheduled query results
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+
Scheduled pack queries (both osquery native interval schedules and osquerybeat
21+
RRULE schedules) now include two additional fields in their result and response
22+
documents: pack_name, taken from the new optional `pack_name` config field on a
23+
pack (alongside the existing pack_id), and query_name, taken from the pack's
24+
queries config map key. Both fields are only emitted when set. These fields are
25+
required by the Osquery Manager dashboards, which group and label scheduled
26+
query results by pack and query name; without them the dashboards cannot render
27+
those results correctly.
28+
29+
# Affected component; a word indicating the component this changeset affects.
30+
component: osquerybeat
31+
32+
# PR URL; optional; the PR number that added the changeset.
33+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
34+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
35+
# Please provide it if you are adding a fragment for a different PR.
36+
#pr: https://github.com/owner/repo/1234
37+
38+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
39+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
40+
#issue: https://github.com/owner/repo/1234
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
kind: bug-fix
2+
3+
summary: Prevent statestore startup failure when meta.json is left empty after an unclean shutdown
4+
5+
component: libbeat
6+
7+
pr: https://github.com/elastic/beats/pull/51897
Lines changed: 32 additions & 0 deletions
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: bug-fix
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: update elastic-agent-libs to v0.46.1
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: Fixed an issue where malformed TLS keys could be printed in the error logs during loading failures.
20+
21+
# Affected component; a word indicating the component this changeset affects.
22+
component: all
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/beats/pull/51921
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/owner/repo/1234

dev-tools/packaging/package_test.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
"github.com/stretchr/testify/require"
4747

4848
"github.com/elastic/beats/v7/dev-tools/mage"
49+
"github.com/elastic/beats/v7/testing/testutils"
4950
)
5051

5152
const (
@@ -900,30 +901,7 @@ func checkFIPS(t *testing.T, beatName, path string) {
900901
info, err := buildinfo.ReadFile(binaryPath)
901902
require.NoError(t, err)
902903

903-
foundTags := false
904-
foundFIPS := false
905-
foundFIPSDefault := false
906-
for _, setting := range info.Settings {
907-
switch setting.Key {
908-
case "-tags":
909-
foundTags = true
910-
require.Contains(t, setting.Value, "requirefips")
911-
continue
912-
case "GOFIPS140":
913-
foundFIPS = true
914-
require.True(t, strings.HasPrefix(setting.Value, "v1.0.0"), "GOFIPS140 must reference the certified module version, got %q", setting.Value)
915-
continue
916-
case "DefaultGODEBUG":
917-
if strings.Contains(setting.Value, "fips140=on") {
918-
foundFIPSDefault = true
919-
}
920-
continue
921-
}
922-
}
923-
924-
require.True(t, foundTags, "Did not find -tags within binary version information")
925-
require.True(t, foundFIPS, "Did not find GOFIPS140 within binary version information")
926-
require.True(t, foundFIPSDefault, "Did not find fips140=on in DefaultGODEBUG — binary will not enforce FIPS mode at runtime (check GOFIPS140 env at build time)")
904+
testutils.RequireFIPSBuildInfo(t, info.Settings)
927905
}
928906

929907
// inspector is a file contents inspector. It vets the contents of the file

docs/reference/filebeat/filebeat-input-kafka.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,31 +98,31 @@ How long to wait before retrying a failed read. Default is 2s.
9898

9999
### `timeout` [_timeout_2]
100100
```{applies_to}
101-
stack: ga 9.5
101+
stack: ga 9.3+
102102
```
103103

104104
The network timeout for the connection to the Kafka brokers, applied to the dial, read, and write deadlines. Increase this for consumers reading across higher-latency links (for example cross-region or WAN), where a large fetch response may not be fully read within the default deadline. Default is 30s.
105105

106106

107107
### `keep_alive` [_keep_alive]
108108
```{applies_to}
109-
stack: ga 9.5
109+
stack: ga 9.3+
110110
```
111111

112112
The keep-alive period for the active network connection to the Kafka brokers. Default is 0s (disabled).
113113

114114

115115
### `session_timeout` [_session_timeout]
116116
```{applies_to}
117-
stack: ga 9.5
117+
stack: ga 9.3+
118118
```
119119

120120
The consumer group session timeout. If the broker receives no heartbeat from a consumer within this period, the consumer is removed from the group and a rebalance is triggered. Consumers on higher-latency links may need a larger value to avoid spurious rebalances. Default is 10s.
121121

122122

123123
### `heartbeat_interval` [_heartbeat_interval]
124124
```{applies_to}
125-
stack: ga 9.5
125+
stack: ga 9.3+
126126
```
127127

128128
How often the consumer sends heartbeats to the broker. This must be lower than `session_timeout`, and is typically set to no more than a third of that value. Default is 3s.

filebeat/beater/filebeat.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
312312
// Start the check-in loop, so Filebeat can respond to Elastic Agent,
313313
// but it won't start any inputs/output
314314
if err := b.Manager.PreInit(); err != nil {
315+
fb.runReady.Close()
315316
return err
316317
}
317318

filebeat/beater/stop_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,61 @@
1818
package beater
1919

2020
import (
21+
"errors"
2122
"testing"
2223
"time"
2324

25+
"github.com/stretchr/testify/require"
26+
27+
"github.com/elastic/beats/v7/filebeat/fileset"
28+
"github.com/elastic/beats/v7/libbeat/beat"
29+
"github.com/elastic/beats/v7/libbeat/beatmonitoring"
30+
"github.com/elastic/beats/v7/libbeat/management"
2431
"github.com/elastic/elastic-agent-libs/logp"
2532
)
2633

34+
// TestRunClosesRunReadyOnPreInitFailure guards against the regression in
35+
// commit 00068f7 where the defer fb.runReady.Close() was placed after the
36+
// PreInit call, leaving runReady unclosed when PreInit fails. An unclosed
37+
// runReady causes StopWithContext to wait the full five-second timeout.
38+
func TestRunClosesRunReadyOnPreInitFailure(t *testing.T) {
39+
preInitErr := errors.New("preinit failed")
40+
fb := &Filebeat{
41+
done: make(chan struct{}),
42+
runReady: &closeOnce{ch: make(chan struct{})},
43+
logger: logp.NewNopLogger(),
44+
moduleRegistry: new(fileset.ModuleRegistry),
45+
}
46+
b := &beat.Beat{
47+
Info: beat.Info{Logger: logp.NewNopLogger()},
48+
Manager: &preinitFailManager{err: preInitErr},
49+
Monitoring: beatmonitoring.NewMonitoring(),
50+
}
51+
52+
err := fb.Run(b)
53+
require.ErrorIs(t, err, preInitErr)
54+
55+
select {
56+
case <-fb.runReady.ch:
57+
// runReady was closed — StopWithContext will not block
58+
default:
59+
t.Fatal("runReady was not closed after PreInit failure; StopWithContext would wait five seconds")
60+
}
61+
}
62+
63+
// preinitFailManager is a management.Manager stub whose PreInit returns an
64+
// error. Only the methods called by Run before PreInit are implemented; any
65+
// other call panics, catching unexpected code paths during the test.
66+
type preinitFailManager struct {
67+
management.Manager // zero-valued; panics on any unimplemented method
68+
err error
69+
}
70+
71+
func (m *preinitFailManager) Enabled() bool { return true }
72+
func (m *preinitFailManager) PreInit() error { return m.err }
73+
func (m *preinitFailManager) RegisterDiagnosticHook(_, _, _, _ string, _ management.DiagnosticHook) {
74+
}
75+
2776
// TestStopWaitsForRunReady proves that Stop does not close the done channel
2877
// until Run has closed runReady (i.e., reached waitFinished.Wait).
2978
// This guards against a race where the OTel collector calls Shutdown before
File renamed without changes.

filebeat/input/filestream/filestream_test_non_windows.go renamed to filebeat/input/filestream/filestream_nonwindows_test.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,26 @@ package filestream
2222
import (
2323
"context"
2424
"os"
25+
"path/filepath"
2526
"testing"
2627
"time"
2728

2829
"github.com/stretchr/testify/assert"
30+
"github.com/stretchr/testify/require"
2931

3032
"github.com/elastic/elastic-agent-libs/logp/logptest"
3133
)
3234

3335
// these tests are separated as one cannot delete/rename files
3436
// while another process is working with it on Windows
3537
func TestLogFileRenamed(t *testing.T) {
36-
f := createTestLogFile()
38+
f := createTestLogFile(t)
3739
defer f.Close()
3840

3941
renamedFile := f.Name() + ".renamed"
4042

4143
reader, _, err := newFileReader(
42-
logptest.NewTestingLogger(t, ""),
44+
logptest.NewFileLogger(t, filepath.Join("..", "..", "build", "integration-tests")).Logger,
4345
context.TODO(),
4446
f,
4547
readerConfig{},
@@ -57,7 +59,7 @@ func TestLogFileRenamed(t *testing.T) {
5759

5860
buf := make([]byte, 1024)
5961
_, err = reader.Read(buf)
60-
assert.Nil(t, err)
62+
assert.NoError(t, err)
6163

6264
err = os.Rename(f.Name(), renamedFile)
6365
if err != nil {
@@ -71,11 +73,11 @@ func TestLogFileRenamed(t *testing.T) {
7173
}
7274

7375
func TestLogFileRemoved(t *testing.T) {
74-
f := createTestLogFile()
76+
f := createTestLogFile(t)
7577
defer f.Close()
7678

7779
reader, _, err := newFileReader(
78-
logptest.NewTestingLogger(t, ""),
80+
logptest.NewFileLogger(t, filepath.Join("..", "..", "build", "integration-tests")).Logger,
7981
context.TODO(),
8082
f,
8183
readerConfig{},
@@ -93,7 +95,7 @@ func TestLogFileRemoved(t *testing.T) {
9395

9496
buf := make([]byte, 1024)
9597
_, err = reader.Read(buf)
96-
assert.Nil(t, err)
98+
assert.NoError(t, err)
9799

98100
err = os.Remove(f.Name())
99101
if err != nil {
@@ -104,3 +106,16 @@ func TestLogFileRemoved(t *testing.T) {
104106

105107
assert.Equal(t, ErrClosed, err)
106108
}
109+
110+
// createTestLogFile creates a temporary plain-text log file with a few lines of
111+
// content, wrapped as a filestream File ready to be passed to newFileReader.
112+
func createTestLogFile(t *testing.T) File {
113+
t.Helper()
114+
fs := filestream{
115+
readerConfig: readerConfig{BufferSize: 512},
116+
compression: CompressionNone,
117+
}
118+
f, err := fs.newFile(createTestPlainLogFile(t))
119+
require.NoError(t, err, "could not create test log file")
120+
return f
121+
}

0 commit comments

Comments
 (0)