Skip to content

Commit 3d49770

Browse files
leehinmanmergify[bot]
authored andcommitted
re-enable otel subcommand on Windows (#6068)
* move processing windows events earlier in the boot process * add Windows to otel integration tests (cherry picked from commit 8e83ce0)
1 parent 8ea9439 commit 3d49770

File tree

5 files changed

+49
-19
lines changed

5 files changed

+49
-19
lines changed
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: re-enable otel subcommand on Windows
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; a word indicating the component this changeset affects.
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/6068
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/4976

internal/pkg/agent/cmd/otel.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func runCollector(cmdCtx context.Context, configFiles []string) error {
7373
stop := make(chan bool)
7474
ctx, cancel := context.WithCancel(cmdCtx)
7575

76-
var stopCollector = func() {
76+
stopCollector := func() {
7777
close(stop)
7878
}
7979

internal/pkg/agent/cmd/run.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,6 @@ func run(override cfgOverrider, testingMode bool, fleetInitTimeout time.Duration
129129
service.WaitExecutionDone()
130130
}()
131131

132-
if err := handleUpgrade(); err != nil {
133-
return fmt.Errorf("error checking for and handling upgrade: %w", err)
134-
}
135-
136-
locker := filelock.NewAppLocker(paths.Data(), paths.AgentLockFileName)
137-
if err := locker.TryLock(); err != nil {
138-
return err
139-
}
140-
defer func() {
141-
_ = locker.Unlock()
142-
}()
143-
144132
service.BeforeRun()
145133
defer service.Cleanup()
146134

@@ -154,6 +142,18 @@ func run(override cfgOverrider, testingMode bool, fleetInitTimeout time.Duration
154142
defer cancel()
155143
go service.ProcessWindowsControlEvents(stopBeat)
156144

145+
if err := handleUpgrade(); err != nil {
146+
return fmt.Errorf("error checking for and handling upgrade: %w", err)
147+
}
148+
149+
locker := filelock.NewAppLocker(paths.Data(), paths.AgentLockFileName)
150+
if err := locker.TryLock(); err != nil {
151+
return err
152+
}
153+
defer func() {
154+
_ = locker.Unlock()
155+
}()
156+
157157
return runElasticAgent(ctx, cancel, override, stop, testingMode, fleetInitTimeout, modifiers...)
158158
}
159159

internal/pkg/agent/cmd/validate_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// or more contributor license agreements. Licensed under the Elastic License 2.0;
33
// you may not use this file except in compliance with the Elastic License 2.0.
44

5-
//go:build !windows
6-
75
package cmd
86

97
import (

testing/integration/otel_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func TestOtelFileProcessing(t *testing.T) {
8181
Group: Default,
8282
Local: true,
8383
OS: []define.OS{
84-
// input path missing on windows
84+
{Type: define.Windows},
8585
{Type: define.Linux},
8686
{Type: define.Darwin},
8787
},
@@ -301,7 +301,7 @@ func TestOtelLogsIngestion(t *testing.T) {
301301
Group: Default,
302302
Local: true,
303303
OS: []define.OS{
304-
// input path missing on windows
304+
{Type: define.Windows},
305305
{Type: define.Linux},
306306
{Type: define.Darwin},
307307
},
@@ -598,7 +598,7 @@ func TestFileBeatReceiver(t *testing.T) {
598598
Group: Default,
599599
Local: true,
600600
OS: []define.OS{
601-
// {Type: define.Windows}, we don't support otel on Windows yet
601+
{Type: define.Windows},
602602
{Type: define.Linux},
603603
{Type: define.Darwin},
604604
},
@@ -703,7 +703,7 @@ func TestOtelFBReceiverE2E(t *testing.T) {
703703
Group: Default,
704704
Local: true,
705705
OS: []define.OS{
706-
// {Type: define.Windows}, we don't support otel on Windows yet
706+
{Type: define.Windows},
707707
{Type: define.Linux},
708708
{Type: define.Darwin},
709709
},

0 commit comments

Comments
 (0)