Skip to content
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

[8.x](backport #40996) Revert "Revert "[filebeat] Fix long filepaths in diagnostics exceeding max path limits on Windows"" #41010

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix publication of group data from the Okta entity analytics provider. {pull}40681[40681]
- Ensure netflow custom field configuration is applied. {issue}40735[40735] {pull}40730[40730]
- Fix replace processor handling of zero string replacement validation. {pull}40751[40751]
- Fix long filepaths in diagnostics exceeding max path limits on Windows. {pull}40909[40909]


*Heartbeat*

Expand Down
1 change: 1 addition & 0 deletions filebeat/input/v2/compat/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (r *runner) Start() {
err := r.input.Run(
v2.Context{
ID: r.id,
IDWithoutName: r.id,
Agent: *r.agent,
Logger: log,
Cancelation: r.sig,
Expand Down
2 changes: 2 additions & 0 deletions filebeat/input/v2/input-cursor/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func (inp *managedInput) Run(
grp.Go(func() (err error) {
// refine per worker context
inpCtx := ctx
// Preserve IDWithoutName, in case the context was constructed who knows how
inpCtx.IDWithoutName = ctx.ID
inpCtx.ID = ctx.ID + "::" + source.Name()
inpCtx.Logger = ctx.Logger.With("input_source", source.Name())

Expand Down
4 changes: 4 additions & 0 deletions filebeat/input/v2/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ type Context struct {
// The input ID.
ID string

// The input ID without name. Some inputs append sourcename, we need the id to be untouched
// https://github.com/elastic/beats/blob/43d80af2aea60b0c45711475d114e118d90c4581/filebeat/input/v2/input-cursor/input.go#L118
IDWithoutName string

// Agent provides additional Beat info like instance ID or beat name.
Agent beat.Info

Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/cel/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
ctx := ctxtool.FromCanceller(env.Cancelation)

if cfg.Resource.Tracer != nil {
id := sanitizeFileName(env.ID)
id := sanitizeFileName(env.IDWithoutName)
cfg.Resource.Tracer.Filename = strings.ReplaceAll(cfg.Resource.Tracer.Filename, "*", id)
}

Expand Down Expand Up @@ -1245,7 +1245,7 @@
// walkMap walks to all ends of the provided path in m and applies fn to the
// final element of each walk. Nested arrays are not handled.
func walkMap(m mapstr.M, path string, fn func(parent mapstr.M, key string)) {
key, rest, more := strings.Cut(path, ".")

Check failure on line 1248 in x-pack/filebeat/input/cel/input.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

rest declared and not used (typecheck)
v, ok := m[key]
if !ok {
return
Expand Down
8 changes: 5 additions & 3 deletions x-pack/filebeat/input/cel/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1690,10 +1690,12 @@ func TestInput(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

id := "test_id:" + test.name
v2Ctx := v2.Context{
Logger: logp.NewLogger("cel_test"),
ID: "test_id:" + test.name,
Cancelation: ctx,
Logger: logp.NewLogger("cel_test"),
ID: id,
IDWithoutName: id,
Cancelation: ctx,
}
var client publisher
client.done = func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (p *jamfInput) Run(inputCtx v2.Context, store *kvstore.Store, client beat.C
updateTimer := time.NewTimer(updateWaitTime)

if p.cfg.Tracer != nil {
id := sanitizeFileName(inputCtx.ID)
id := sanitizeFileName(inputCtx.IDWithoutName)
p.cfg.Tracer.Filename = strings.ReplaceAll(p.cfg.Tracer.Filename, "*", id)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (p *oktaInput) Run(inputCtx v2.Context, store *kvstore.Store, client beat.C
p.lim = rate.NewLimiter(1, 1)

if p.cfg.Tracer != nil {
id := sanitizeFileName(inputCtx.ID)
id := sanitizeFileName(inputCtx.IDWithoutName)
p.cfg.Tracer.Filename = strings.ReplaceAll(p.cfg.Tracer.Filename, "*", id)
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/http_endpoint/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (e *httpEndpoint) Run(ctx v2.Context, pipeline beat.Pipeline) error {
defer metrics.Close()

if e.config.Tracer != nil {
id := sanitizeFileName(ctx.ID)
id := sanitizeFileName(ctx.IDWithoutName)
e.config.Tracer.Filename = strings.ReplaceAll(e.config.Tracer.Filename, "*", id)
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/httpjson/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func run(ctx v2.Context, cfg config, pub inputcursor.Publisher, crsr *inputcurso
stdCtx := ctxtool.FromCanceller(ctx.Cancelation)

if cfg.Request.Tracer != nil {
id := sanitizeFileName(ctx.ID)
id := sanitizeFileName(ctx.IDWithoutName)
cfg.Request.Tracer.Filename = strings.ReplaceAll(cfg.Request.Tracer.Filename, "*", id)

// Propagate tracer behaviour to all chain children.
Expand Down
7 changes: 4 additions & 3 deletions x-pack/filebeat/input/httpjson/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1660,9 +1660,10 @@ func newChainPaginationTestServer(
func newV2Context(id string) (v2.Context, func()) {
ctx, cancel := context.WithCancel(context.Background())
return v2.Context{
Logger: logp.NewLogger("httpjson_test"),
ID: id,
Cancelation: ctx,
Logger: logp.NewLogger("httpjson_test"),
ID: id,
IDWithoutName: id,
Cancelation: ctx,
}, cancel
}

Expand Down
Loading