Skip to content

Commit 32b43a2

Browse files
pjanottimterhar
authored andcommitted
[extension/sumologic] Skip zombie processes on Windows (open-telemetry#36772)
#### Description On Windows it consistently fails to get the name of certain processes, likely zombie process, reporting: "A device attached to the system is not functioning." My long term recommendation will be for the owners to directly use the Win32 API to get process information instead of the library: while it uses the correct permissions to get the process name it is not using the flag that allows to get the device name path which should avoid this issue even for zombie processes, I'm not sure if that is desirable or not. #### Link to tracking issue Fixes open-telemetry#36481 #### Testing Repro the failure locally and checked that the test passed locally with the change. I couldn't lint it locally on Windows (tool crash, will use CI to check that) #### Documentation Added changelog
1 parent d545f7a commit 32b43a2

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: sumologicextension
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Skip likely zombie processes on Windows.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [36481]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

extension/sumologicextension/extension.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"net/http"
1616
"net/url"
1717
"os"
18+
"runtime"
1819
"strings"
1920
"sync"
2021
"time"
@@ -728,7 +729,7 @@ var sumoAppProcesses = map[string]string{
728729
"sqlservr": "mssql", // linux SQL Server process
729730
}
730731

731-
func filteredProcessList() ([]string, error) {
732+
func (se *SumologicExtension) filteredProcessList() ([]string, error) {
732733
var pl []string
733734

734735
processes, err := process.Processes()
@@ -739,6 +740,15 @@ func filteredProcessList() ([]string, error) {
739740
for _, v := range processes {
740741
e, err := v.Name()
741742
if err != nil {
743+
if runtime.GOOS == "windows" {
744+
// On Windows, if we can't get a process name, it is likely a zombie process, assume that and skip them.
745+
se.logger.Warn(
746+
"Failed to get executable name, it is likely a zombie process, skipping it",
747+
zap.Int32("pid", v.Pid),
748+
zap.Error(err))
749+
continue
750+
}
751+
742752
return nil, fmt.Errorf("Error getting executable name: %w", err)
743753
}
744754
e = strings.ToLower(e)
@@ -773,12 +783,12 @@ func filteredProcessList() ([]string, error) {
773783
return pl, nil
774784
}
775785

776-
func discoverTags() (map[string]any, error) {
786+
func (se *SumologicExtension) discoverTags() (map[string]any, error) {
777787
t := map[string]any{
778788
"sumo.disco.enabled": "true",
779789
}
780790

781-
pl, err := filteredProcessList()
791+
pl, err := se.filteredProcessList()
782792
if err != nil {
783793
return t, err
784794
}
@@ -814,7 +824,7 @@ func (se *SumologicExtension) updateMetadataWithHTTPClient(ctx context.Context,
814824
td := map[string]any{}
815825

816826
if se.conf.DiscoverCollectorTags {
817-
td, err = discoverTags()
827+
td, err = se.discoverTags()
818828
if err != nil {
819829
return err
820830
}

0 commit comments

Comments
 (0)