Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8cb857a
Bump Go version to 1.25.1
ycombinator Sep 25, 2025
54ab85d
Update CHANGELOG entry
ycombinator Sep 25, 2025
3bc30ca
Bump the version of golangci-lint
ycombinator Sep 25, 2025
35b1f90
Update dev-tools/mage/otel/deps_test.go
ycombinator Sep 25, 2025
5e14744
Remove references to the ms_tls13kdf build tag
ycombinator Sep 25, 2025
512cd5f
Use mage target specifically intended for fips140=only unit testing
ycombinator Sep 25, 2025
e3d6e60
Download go module dependencies before GODEBUG=fips140=only is set
ycombinator Sep 25, 2025
cf10246
[Debugging] Print go test command environment right before command is…
ycombinator Sep 25, 2025
b9fde90
Revert "[Debugging] Print go test command environment right before co…
ycombinator Sep 26, 2025
25eebfb
Fix regular expression for matching panicking output
ycombinator Sep 26, 2025
4493898
Run dependencies first
ycombinator Sep 26, 2025
9602f2b
Append requirefips build tag for fips140=only unit tests
ycombinator Sep 26, 2025
4a6fec2
Fix policy change handler unit tests
ycombinator Sep 26, 2025
807956d
Fix TestDownloadVersion test
ycombinator Sep 26, 2025
20c2d62
Set GODEBUG=tlsmlkem=0 for test
ycombinator Sep 27, 2025
eeb3dca
No longer necessary
ycombinator Sep 27, 2025
07f97b5
Formatting fixes
ycombinator Sep 27, 2025
e11d9f8
Remove pre-downloading of go modules
ycombinator Sep 29, 2025
88be1e0
Revert unit test pipeline changes
ycombinator Oct 1, 2025
507d5bf
Add GODEBUG=tlsmlkem=0
ycombinator Oct 7, 2025
7327700
s/1.25.1/1.25.2/g
ycombinator Oct 13, 2025
01de1a7
Go version: s/1.25.2/1.25.4/g
ycombinator Nov 5, 2025
35136fe
Update go version in edot go.mod
ycombinator Dec 5, 2025
e6f0267
s/1.24.4/1.24.5/g
ycombinator Dec 5, 2025
bd2f378
Remove ms_tls13kdf from TestTagsWithFIPS
ycombinator Mar 6, 2026
a2a873f
Running go mod tidy
ycombinator Mar 6, 2026
66e5cc3
s/1.25.5/1.25.8/g
ycombinator Mar 6, 2026
9c6d0ed
Running go mod tidy and mage notice
ycombinator Mar 6, 2026
a4f1e64
Running mage otel:readme
ycombinator Mar 6, 2026
3792438
Fixing go.mods
ycombinator Mar 6, 2026
6b9f39d
Bumping up beats
ycombinator Mar 7, 2026
75c9cd4
Running go mod tidy
ycombinator Mar 7, 2026
3c9b377
Update unit tests
ycombinator Mar 8, 2026
87dcd07
Merge branch 'main' into bump-golang-1.25.1
swiatekm Mar 11, 2026
bf6e8b9
Use Go 1.24's RemoveAll in uninstall
swiatekm Mar 11, 2026
83ca6d4
Wait for fsnotify watcher to be released
swiatekm Mar 9, 2026
2316448
Update internal/pkg/agent/application/upgrade/marker_watcher.go
swiatekm Mar 11, 2026
a114241
Fix function signature in MarkerFileWatcher
swiatekm Mar 11, 2026
88ece11
Use the exact removaAll implementation from Go 1.24
swiatekm Mar 11, 2026
3c6a49d
Add link to the new RemoveAll implementation
swiatekm Mar 11, 2026
743a105
Revert "Use the exact removaAll implementation from Go 1.24"
swiatekm Mar 12, 2026
719ea85
Merge branch 'main' into bump-golang-1.25.1
swiatekm Mar 12, 2026
dca2b40
Merge branch 'main' into bump-golang-1.25.1
swiatekm Mar 12, 2026
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: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ steps:
# Note: The GODEBUG=fips140=only environment variable must be set in the command itself (as opposed to
# in the env block) so that it is applied *only* to the 'go' command invoked by the script, and
# not to any other Go code executed as part of the Buildkite agent itself.
command: 'GODEBUG="fips140=only" .buildkite/scripts/steps/unit-tests.sh'
command: 'GODEBUG="fips140=only,tlsmlkem=0" .buildkite/scripts/steps/unit-tests.sh'
env:
FIPS: "true"
artifact_paths:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v2.1.0
version: v2.5.0

# Give the job more time to execute.
# Regarding `--whole-files`, the linter is supposed to support linting of changed a patch only but,
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.24.13
1.25.8
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.24.7
ARG GO_VERSION=1.25.8
FROM circleci/golang:${GO_VERSION}


Expand Down
4 changes: 2 additions & 2 deletions NOTICE-fips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79933,11 +79933,11 @@ Contents of probable licence file $GOMODCACHE/github.com/gomodule/redigo@v1.9.3/

--------------------------------------------------------------------------------
Dependency : github.com/google/cel-go
Version: v0.26.0
Version: v0.26.1
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/google/cel-go@v0.26.0/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/google/cel-go@v0.26.1/LICENSE:


Apache License
Expand Down
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83464,11 +83464,11 @@ Contents of probable licence file $GOMODCACHE/github.com/gomodule/redigo@v1.9.3/

--------------------------------------------------------------------------------
Dependency : github.com/google/cel-go
Version: v0.26.0
Version: v0.26.1
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/google/cel-go@v0.26.0/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/google/cel-go@v0.26.1/LICENSE:


Apache License
Expand Down
2 changes: 1 addition & 1 deletion beats
Submodule beats updated 80 files
+1 −1 .github/workflows/golangci-lint.yml
+1 −1 .github/workflows/trigger-duplicate-issue-detector.yml
+1 −1 .github/workflows/trigger-issue-triage.yml
+1 −1 .github/workflows/trigger-mention-in-issue.yml
+1 −1 .github/workflows/trigger-mention-in-pr.yml
+0 −4 .github/workflows/trigger-pr-actions-detective.yml
+0 −26 .github/workflows/trigger-pr-ci-detective.yml
+1 −1 .github/workflows/trigger-pr-review.yml
+1 −1 .go-version
+1 −0 CHANGELOG.asciidoc
+2 −2 NOTICE.txt
+1 −1 auditbeat/Dockerfile
+32 −0 changelog/fragments/1760385532-bump-golang-1.25.8.yaml
+45 −0 changelog/fragments/1772192816-logstash-status-reporting.yaml
+11 −0 changelog/fragments/1772629661-winlog-filtering-and-recovery-hardening.yaml
+45 −0 changelog/fragments/1772635870-es-index-mode-&-codec-in-metricbeat.yaml
+45 −0 changelog/fragments/1772665071-filebeat-input-report-stopped.yaml
+1 −1 dev-tools/kubernetes/filebeat/Dockerfile.debug
+1 −1 dev-tools/kubernetes/heartbeat/Dockerfile.debug
+1 −1 dev-tools/kubernetes/metricbeat/Dockerfile.debug
+0 −1 dev-tools/mage/fips-settings.yaml
+16 −4 dev-tools/mage/gotest.go
+0 −1 dev-tools/packaging/package_test.go
+2 −0 docs/reference/filebeat/filebeat-input-winlog.md
+8 −0 docs/reference/metricbeat/exported-fields-elasticsearch.md
+2 −0 docs/reference/metricbeat/metricbeat-metricset-elasticsearch-index.md
+2 −0 docs/reference/winlogbeat/configuration-winlogbeat-options.md
+3 −3 docs/release-notes/known-issues.md
+1 −0 filebeat/input/v2/compat/compat.go
+41 −0 filebeat/input/v2/compat/compat_test.go
+11 −0 filebeat/magefile.go
+2 −2 go.mod
+2 −2 go.sum
+1 −1 heartbeat/Dockerfile
+1 −1 heartbeat/hbtest/hbtestutil.go
+3 −2 heartbeat/monitors/active/http/http_test.go
+1 −1 libbeat/docs/version.asciidoc
+4 −2 libbeat/processors/add_kubernetes_metadata/indexers.go
+4 −2 libbeat/processors/add_kubernetes_metadata/indexers_test.go
+1 −1 metricbeat/Dockerfile
+3 −3 metricbeat/helper/server/tcp/tcp_test.go
+3 −2 metricbeat/helper/server/udp/udp_test.go
+7 −1 metricbeat/magefile.go
+1 −1 metricbeat/module/apache/status/status_test.go
+1 −1 metricbeat/module/elasticsearch/fields.go
+2 −0 metricbeat/module/elasticsearch/index/_meta/data.json
+4 −0 metricbeat/module/elasticsearch/index/_meta/fields.yml
+10 −1 metricbeat/module/elasticsearch/index/data.go
+1 −1 metricbeat/module/http/_meta/Dockerfile
+1 −1 metricbeat/module/vsphere/_meta/Dockerfile
+1 −1 packetbeat/Dockerfile
+0 −1 testing/go-ech/ech.go
+3 −1 winlogbeat/_meta/config/header.yml.tmpl
+0 −4 winlogbeat/eventlog/config.go
+2 −2 winlogbeat/eventlog/errors_windows.go
+220 −0 winlogbeat/eventlog/record_filter.go
+132 −0 winlogbeat/eventlog/record_filter_test.go
+36 −36 winlogbeat/eventlog/runner.go
+252 −45 winlogbeat/eventlog/wineventlog.go
+69 −0 winlogbeat/eventlog/wineventlog_retry_test.go
+2 −38 winlogbeat/eventlog/wineventlog_test.go
+35 −13 winlogbeat/sys/wineventlog/iterator.go
+55 −7 winlogbeat/sys/wineventlog/iterator_test.go
+0 −291 winlogbeat/sys/wineventlog/query.go
+0 −152 winlogbeat/sys/wineventlog/query_test.go
+8 −17 winlogbeat/sys/wineventlog/util_test.go
+3 −1 winlogbeat/winlogbeat.reference.yml
+3 −1 winlogbeat/winlogbeat.yml
+1 −1 x-pack/filebeat/fbreceiver/receiver_test.go
+6 −1 x-pack/metricbeat/magefile.go
+2 −1 x-pack/metricbeat/module/airflow/statsd/data_test.go
+1 −1 x-pack/metricbeat/module/stan/_meta/Dockerfile
+35 −8 x-pack/otel/exporter/logstashexporter/exporter.go
+76 −0 x-pack/otel/exporter/logstashexporter/exporter_test.go
+23 −0 x-pack/otel/exporter/logstashexporter/internal/worker.go
+17 −7 x-pack/otel/oteltest/oteltest.go
+1 −1 x-pack/packetbeat/scripts/mage/pcap.go
+1 −1 x-pack/packetbeat/tests/system/app_test.go
+3 −1 x-pack/winlogbeat/winlogbeat.reference.yml
+3 −1 x-pack/winlogbeat/winlogbeat.yml
32 changes: 32 additions & 0 deletions changelog/fragments/1758822287-bump-golang-1.25.8.yaml
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: Update Go version to 1.25.8

# 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; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
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/10156

# 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/owner/repo/1234
4 changes: 1 addition & 3 deletions dev-tools/mage/gotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,7 @@ func TestGoTest_Helper_WithPanic(t *testing.T) {

var wantTestWithPanic = `(?sm:
=== FAIL: dev-tools/mage TestGoTest_Helper_WithPanic.*
panic: Kaputt. \[recovered\].*
panic: Kaputt.*
)`
panic: Kaputt. \[recovered, repanicked\].*)`

func TestGoTest_Helper_WithWrongPanic(t *testing.T) {
if !gotestHelperMode {
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/mage/otel/deps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func TestGetOtelDependencies(t *testing.T) {
goModContent := `module github.com/elastic/elastic-agent

go 1.24.1
go 1.25.8

require (
github.com/elastic/opentelemetry-collector-components/connector/signaltometricsconnector v0.3.0
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/mage/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ func (s *Settings) TestTagsWithFIPS() []string {
tags := make([]string, len(s.Test.Tags))
copy(tags, s.Test.Tags)
if s.Build.FIPSBuild {
tags = append(tags, "requirefips", "ms_tls13kdf")
tags = append(tags, "requirefips")
}
return tags
}
Expand Down
4 changes: 2 additions & 2 deletions dev-tools/mage/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func TestSettingsTestTagsWithFIPS(t *testing.T) {

tags := s.TestTagsWithFIPS()

assert.Equal(t, []string{"tag1", "requirefips", "ms_tls13kdf"}, tags)
assert.Equal(t, []string{"tag1", "requirefips"}, tags)
})

t.Run("does not modify original tags", func(t *testing.T) {
Expand All @@ -327,7 +327,7 @@ func TestSettingsTestTagsWithFIPS(t *testing.T) {

tags := s.TestTagsWithFIPS()

assert.Equal(t, []string{"requirefips", "ms_tls13kdf"}, tags)
assert.Equal(t, []string{"requirefips"}, tags)
})
}

Expand Down
1 change: 0 additions & 1 deletion dev-tools/packaging/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ settings:
MS_GOTOOLCHAIN_TELEMETRY_ENABLED: "0"
tags:
- requirefips
- ms_tls13kdf
platforms:
- *linux-amd64
- *linux-arm64
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elastic/elastic-agent

go 1.24.13
go 1.25.8

replace github.com/elastic/beats/v7 => ./beats

Expand Down
4 changes: 2 additions & 2 deletions internal/edot/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elastic/elastic-agent/internal/edot

go 1.24.13
go 1.25.8

// use in-repo directory
replace github.com/elastic/elastic-agent => ../../
Expand Down Expand Up @@ -439,7 +439,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/gomodule/redigo v1.9.3 // indirect
github.com/google/cel-go v0.26.0 // indirect
github.com/google/cel-go v0.26.1 // indirect
github.com/google/flatbuffers v25.2.10+incompatible // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0
Expand Down
4 changes: 2 additions & 2 deletions internal/edot/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,8 @@ github.com/gomodule/redigo v1.9.3/go.mod h1:KsU3hiK/Ay8U42qpaJk+kuNa3C+spxapWpM+
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
github.com/google/cel-go v0.26.0 h1:DPGjXackMpJWH680oGY4lZhYjIameYmR+/6RBdDGmaI=
github.com/google/cel-go v0.26.0/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM=
github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ=
github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM=
github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q=
github.com/google/flatbuffers v25.2.10+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
Expand Down
25 changes: 20 additions & 5 deletions internal/pkg/agent/application/upgrade/marker_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import (
type MarkerWatcher interface {
Watch() <-chan UpdateMarker
Run(ctx context.Context) error
Done() <-chan struct{}
SetUpgradeStarted()
}

type MarkerFileWatcher struct {
markerFilePath string
logger *logger.Logger
updateCh chan UpdateMarker
doneCh chan struct{}

upgradeStarted atomic.Bool
lastMarker *UpdateMarker
Expand All @@ -39,6 +41,7 @@ func newMarkerFileWatcher(upgradeMarkerFilePath string, logger *logger.Logger) M
markerFilePath: upgradeMarkerFilePath,
logger: logger,
updateCh: make(chan UpdateMarker),
doneCh: make(chan struct{}),
}
}

Expand All @@ -50,6 +53,10 @@ func (mfw *MarkerFileWatcher) SetUpgradeStarted() {
mfw.upgradeStarted.Store(true)
}

func (mfw *MarkerFileWatcher) Done() <-chan struct{} {
return mfw.doneCh
}

func (mfw *MarkerFileWatcher) Run(ctx context.Context) error {
watcher, err := fsnotify.NewWatcher()
if err != nil {
Expand All @@ -70,6 +77,7 @@ func (mfw *MarkerFileWatcher) Run(ctx context.Context) error {

// Handle watching
go func() {
defer close(mfw.doneCh)
defer watcher.Close()
for {
select {
Expand Down Expand Up @@ -100,7 +108,7 @@ func (mfw *MarkerFileWatcher) Run(ctx context.Context) error {
case e.Op&(fsnotify.Create|fsnotify.Write) != 0:
// Upgrade marker file was created or updated; read its contents
// and send them over the update channel.
mfw.processMarker(version.GetAgentPackageVersion(), version.Commit())
mfw.processMarker(ctx, version.GetAgentPackageVersion(), version.Commit())
case e.Op&(fsnotify.Remove) != 0:
// Upgrade marker file was removed.
// - Upgrade could've been rolled back
Expand All @@ -109,19 +117,23 @@ func (mfw *MarkerFileWatcher) Run(ctx context.Context) error {
// upgrade was successful
if mfw.lastMarker != nil && mfw.lastMarker.Details != nil && mfw.lastMarker.Details.State != details.StateRollback {
mfw.lastMarker.Details = nil
mfw.updateCh <- *mfw.lastMarker
select {
case mfw.updateCh <- *mfw.lastMarker:
case <-ctx.Done():
return
}
}
}
case <-doInitialRead:
mfw.processMarker(version.GetAgentPackageVersion(), version.Commit())
mfw.processMarker(ctx, version.GetAgentPackageVersion(), version.Commit())
}
}
}()

return nil
}

func (mfw *MarkerFileWatcher) processMarker(currentVersion string, commit string) {
func (mfw *MarkerFileWatcher) processMarker(ctx context.Context, currentVersion string, commit string) {
marker, err := loadMarker(mfw.markerFilePath)
if err != nil {
mfw.logger.Error(err)
Expand Down Expand Up @@ -151,5 +163,8 @@ func (mfw *MarkerFileWatcher) processMarker(currentVersion string, commit string
}

mfw.lastMarker = marker
mfw.updateCh <- *marker
select {
case mfw.updateCh <- *marker:
case <-ctx.Done():
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ func TestMarkerWatcher(t *testing.T) {
markerWatcher := newMarkerFileWatcher(testMarkerFile, testLogger)

testCtx, testCancel := context.WithCancel(context.Background())
defer testCancel()
defer func() {
testCancel()
<-markerWatcher.Done()
}()

var testDetails *details.Details
var testDetailsMu sync.Mutex
Expand Down Expand Up @@ -270,7 +273,7 @@ details:
mfw.SetUpgradeStarted()
}

mfw.processMarker(currentVersion, currentCommit)
mfw.processMarker(t.Context(), currentVersion, currentCommit)

// error loading marker
if test.expectedErrLogMsg {
Expand Down
7 changes: 6 additions & 1 deletion internal/pkg/agent/application/upgrade/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,18 @@ type createContextWithTimeout func(ctx context.Context, timeout time.Duration) (
func waitForWatcherWithTimeoutCreationFunc(ctx context.Context, log *logger.Logger, markerFilePath string, waitTime time.Duration, createTimeoutContext createContextWithTimeout) error {
// Wait for the watcher to be up and running
watcherContext, cancel := createTimeoutContext(ctx, waitTime)
defer cancel()

markerWatcher := newMarkerFileWatcher(markerFilePath, log)
err := markerWatcher.Run(watcherContext)
if err != nil {
return fmt.Errorf("error starting update marker watcher: %w", err)
}
// Ensure the fsnotify watcher goroutine fully exits before returning,
// so that directory handles are released (needed on Windows for cleanup).
defer func() {
cancel()
<-markerWatcher.Done()
}()

log.Infof("waiting up to %s for upgrade watcher to set %s state in upgrade marker", waitTime, details.StateWatching)

Expand Down
66 changes: 65 additions & 1 deletion internal/pkg/agent/install/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func RemovePath(path string) error {
start := time.Now()
var lastErr error
for time.Since(start) <= arbitraryTimeout {
lastErr = os.RemoveAll(path)
lastErr = removeAll(path)

if lastErr == nil || !isRetryableError(lastErr) {
return lastErr
Expand Down Expand Up @@ -326,6 +326,70 @@ func RemoveBut(path string, bestEffort bool, exceptions ...string) error {
return err
}

// TODO: Replace this with a more robust and less mysterious approach.
// removeAll is a reimplementation of Go 1.24's os.RemoveAll. Go 1.25 switched
// to directory-relative unlinkat/openat syscalls (removeall_at.go) which on
// Windows use NtCreateFile with DELETE access — these are stricter about file
// state and fail on files that have been ADS-renamed. The simple path-based
// approach using os.Remove works correctly with the ADS rename trick that
// RemovePath uses to delete running executables on Windows.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, what's the plan here, are we going to address the changes in file permissions or do something else? Do we have a follow-up issue?

Copy link
Copy Markdown
Member

@swiatekm swiatekm Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have an issue, and I'm not sure what the actual root cause is. Just that the new RemoveAll implementation doesn't like the data stream renames and naive attempts to fix it don't really help. The errors aren't very informative either, you just get Access Denied.

I will file an issue describing the problem and what I tried to fix it. For now, I want to unblock this upgrade because it blocks a bunch of other updates.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes at this point, let's fall back to the implementation we know works and work out how to get rid of this separately. This is blocking the collector and contrib dependency updates for example, in addition to use not getting CVE fixes in Go anymore.

// Taken from: https://cs.opensource.google/go/go/+/refs/tags/go1.24.13:src/os/removeall_noat.go;drc=a2baae6851a157d662dff7cc508659f66249698a;l=15
// The implementation which breaks our install is here:
// https://cs.opensource.google/go/go/+/refs/tags/go1.25.8:src/os/removeall_at.go;drc=e81c624656e415626c7ac3a97768f5c2717979a4;l=15
func removeAll(path string) error {
Comment thread
cmacknz marked this conversation as resolved.
// Try simple remove first (handles files and empty directories).
err := os.Remove(path)
if err == nil || errors.Is(err, fs.ErrNotExist) {
return nil
}

// Check if it's a directory.
info, serr := os.Lstat(path)
if serr != nil {
if errors.Is(serr, fs.ErrNotExist) {
return nil
}
return serr
}
if !info.IsDir() {
// Not a directory — return the original Remove error.
return err
}

// Remove directory contents recursively.
err = removeAllChildren(path)
if err != nil {
return err
}

// Remove the now-empty directory.
err = os.Remove(path)
if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
}

func removeAllChildren(path string) error {
entries, err := os.ReadDir(path)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
}

var firstErr error
for _, entry := range entries {
child := filepath.Join(path, entry.Name())
err := removeAll(child)
if err != nil && firstErr == nil {
firstErr = err
}
}
return firstErr
}

func containsString(str string, a []string, caseSensitive bool) bool {
if !caseSensitive {
str = strings.ToLower(str)
Expand Down
Loading
Loading