Skip to content

Commit

Permalink
re-enable otel subcommand on Windows (#6068)
Browse files Browse the repository at this point in the history
* move processing windows events earlier in the boot process

* add Windows to otel integration tests
  • Loading branch information
leehinman authored Nov 27, 2024
1 parent 031d8d0 commit 8e83ce0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Kind can be one of:
# - breaking-change: a change to previously-documented behavior
# - deprecation: functionality that is being removed in a later release
# - bug-fix: fixes a problem in a previous version
# - enhancement: extends functionality but does not break or fix existing behavior
# - feature: new functionality
# - known-issue: problems that we are aware of in a given version
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: enhancement

# Change summary; a 80ish characters long description of the change.
summary: re-enable otel subcommand on Windows

# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
#description:

# Affected component; a word indicating the component this changeset affects.
component: elastic-agent

# PR URL; optional; the PR number that added the changeset.
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
pr: https://github.com/elastic/elastic-agent/pull/6068

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
issue: https://github.com/elastic/elastic-agent/issues/4976
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func runCollector(cmdCtx context.Context, configFiles []string) error {
stop := make(chan bool)
ctx, cancel := context.WithCancel(cmdCtx)

var stopCollector = func() {
stopCollector := func() {
close(stop)
}

Expand Down
24 changes: 12 additions & 12 deletions internal/pkg/agent/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@ func run(override cfgOverrider, testingMode bool, fleetInitTimeout time.Duration
service.WaitExecutionDone()
}()

if err := handleUpgrade(); err != nil {
return fmt.Errorf("error checking for and handling upgrade: %w", err)
}

locker := filelock.NewAppLocker(paths.Data(), paths.AgentLockFileName)
if err := locker.TryLock(); err != nil {
return err
}
defer func() {
_ = locker.Unlock()
}()

service.BeforeRun()
defer service.Cleanup()

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

if err := handleUpgrade(); err != nil {
return fmt.Errorf("error checking for and handling upgrade: %w", err)
}

locker := filelock.NewAppLocker(paths.Data(), paths.AgentLockFileName)
if err := locker.TryLock(); err != nil {
return err
}
defer func() {
_ = locker.Unlock()
}()

return runElasticAgent(ctx, cancel, override, stop, testingMode, fleetInitTimeout, modifiers...)
}

Expand Down
2 changes: 0 additions & 2 deletions internal/pkg/agent/cmd/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// or more contributor license agreements. Licensed under the Elastic License 2.0;
// you may not use this file except in compliance with the Elastic License 2.0.

//go:build !windows

package cmd

import (
Expand Down
8 changes: 4 additions & 4 deletions testing/integration/otel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestOtelFileProcessing(t *testing.T) {
Group: Default,
Local: true,
OS: []define.OS{
// input path missing on windows
{Type: define.Windows},
{Type: define.Linux},
{Type: define.Darwin},
},
Expand Down Expand Up @@ -428,7 +428,7 @@ func TestOtelLogsIngestion(t *testing.T) {
Group: Default,
Local: true,
OS: []define.OS{
// input path missing on windows
{Type: define.Windows},
{Type: define.Linux},
{Type: define.Darwin},
},
Expand Down Expand Up @@ -725,7 +725,7 @@ func TestFileBeatReceiver(t *testing.T) {
Group: Default,
Local: true,
OS: []define.OS{
// {Type: define.Windows}, we don't support otel on Windows yet
{Type: define.Windows},
{Type: define.Linux},
{Type: define.Darwin},
},
Expand Down Expand Up @@ -830,7 +830,7 @@ func TestOtelFBReceiverE2E(t *testing.T) {
Group: Default,
Local: true,
OS: []define.OS{
// {Type: define.Windows}, we don't support otel on Windows yet
{Type: define.Windows},
{Type: define.Linux},
{Type: define.Darwin},
},
Expand Down

0 comments on commit 8e83ce0

Please sign in to comment.