Skip to content

Commit 48e7e3a

Browse files
mergify[bot]leehinmanpierrehilbert
authored
re-enable otel subcommand on Windows (#6068) (#6156)
* move processing windows events earlier in the boot process * add Windows to otel integration tests (cherry picked from commit 8e83ce0) Co-authored-by: Lee E Hinman <57081003+leehinman@users.noreply.github.com> Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co>
1 parent c520f08 commit 48e7e3a

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
@@ -71,7 +71,7 @@ func runCollector(cmdCtx context.Context, configFiles []string) error {
7171
stop := make(chan bool)
7272
ctx, cancel := context.WithCancel(cmdCtx)
7373

74-
var stopCollector = func() {
74+
stopCollector := func() {
7575
close(stop)
7676
}
7777

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
@@ -83,7 +83,7 @@ func TestOtelFileProcessing(t *testing.T) {
8383
Group: Default,
8484
Local: true,
8585
OS: []define.OS{
86-
// input path missing on windows
86+
{Type: define.Windows},
8787
{Type: define.Linux},
8888
{Type: define.Darwin},
8989
},
@@ -428,7 +428,7 @@ func TestOtelLogsIngestion(t *testing.T) {
428428
Group: Default,
429429
Local: true,
430430
OS: []define.OS{
431-
// input path missing on windows
431+
{Type: define.Windows},
432432
{Type: define.Linux},
433433
{Type: define.Darwin},
434434
},
@@ -725,7 +725,7 @@ func TestFileBeatReceiver(t *testing.T) {
725725
Group: Default,
726726
Local: true,
727727
OS: []define.OS{
728-
// {Type: define.Windows}, we don't support otel on Windows yet
728+
{Type: define.Windows},
729729
{Type: define.Linux},
730730
{Type: define.Darwin},
731731
},
@@ -830,7 +830,7 @@ func TestOtelFBReceiverE2E(t *testing.T) {
830830
Group: Default,
831831
Local: true,
832832
OS: []define.OS{
833-
// {Type: define.Windows}, we don't support otel on Windows yet
833+
{Type: define.Windows},
834834
{Type: define.Linux},
835835
{Type: define.Darwin},
836836
},

0 commit comments

Comments
 (0)