From 7e1b5efc5516caa8e59b0a42d4f4eea7b4f9a59e Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 31 Jul 2024 09:53:26 -0700 Subject: [PATCH 1/5] Fix docker_observer default on Windows --- extension/observer/dockerobserver/README.md | 6 +-- extension/observer/dockerobserver/config.go | 3 +- extension/observer/dockerobserver/factory.go | 3 +- extension/observer/dockerobserver/go.mod | 5 +- extension/observer/dockerobserver/go.sum | 10 +--- internal/docker/config.go | 4 +- internal/docker/docker_test.go | 54 ++++++------------- internal/docker/docker_test_listener.go | 30 +++++++++++ .../docker/docker_test_listener_windows.go | 22 ++++++++ internal/docker/go.mod | 2 +- internal/docker/go.sum | 8 +-- 11 files changed, 83 insertions(+), 64 deletions(-) create mode 100644 internal/docker/docker_test_listener.go create mode 100644 internal/docker/docker_test_listener_windows.go diff --git a/extension/observer/dockerobserver/README.md b/extension/observer/dockerobserver/README.md index 280686aa24f4..fee1ef7d1097 100644 --- a/extension/observer/dockerobserver/README.md +++ b/extension/observer/dockerobserver/README.md @@ -19,7 +19,7 @@ This observer watches the Docker engine's stream of events to dynamically create Requires Docker API Version 1.24+. The collector will need permissions to access the Docker Engine API, specifically it will need -read access to the Docker socket (default `unix:///var/run/docker.sock`). +read access to the Docker socket (default `unix:///var/run/docker.sock` on non-Windows and `npipe:////./pipe/docker_engine` on Windows). ## Example Config @@ -27,7 +27,7 @@ read access to the Docker socket (default `unix:///var/run/docker.sock`). ```yaml extensions: docker_observer: - # url of the docker socket, default to unix:///var/run/docker.sock + # url of the docker socket, defaults to unix:///var/run/docker.sock on non-Windows and npipe:////./pipe/docker_engine on Windows endpoint: my/path/to/docker.sock # list of container image names to exclude excluded_images: ['redis', 'another_image_name'] @@ -53,7 +53,7 @@ receivers: The URL of the docker server. -default: `unix:///var/run/docker.sock` +default: `unix:///var/run/docker.sock` on non-Windows and `npipe:////./pipe/docker_engine` on Windows ### `timeout` diff --git a/extension/observer/dockerobserver/config.go b/extension/observer/dockerobserver/config.go index 4e3bb293beae..585dc4fcb4f1 100644 --- a/extension/observer/dockerobserver/config.go +++ b/extension/observer/dockerobserver/config.go @@ -16,7 +16,8 @@ import ( // Config defines configuration for docker observer type Config struct { - // The URL of the docker server. Default is "unix:///var/run/docker.sock" + // The URL of the docker server. Default is "unix:///var/run/docker.sock" on non-Windows + // and "npipe:////./pipe/docker_engine" on Windows Endpoint string `mapstructure:"endpoint"` // The maximum amount of time to wait for docker API responses. Default is 5s diff --git a/extension/observer/dockerobserver/factory.go b/extension/observer/dockerobserver/factory.go index 1a132f21c0dc..23a023ddd635 100644 --- a/extension/observer/dockerobserver/factory.go +++ b/extension/observer/dockerobserver/factory.go @@ -7,6 +7,7 @@ import ( "context" "time" + "github.com/docker/docker/client" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/extension" @@ -25,7 +26,7 @@ func NewFactory() extension.Factory { func createDefaultConfig() component.Config { return &Config{ - Endpoint: "unix:///var/run/docker.sock", + Endpoint: client.DefaultDockerHost, Timeout: 5 * time.Second, CacheSyncInterval: 60 * time.Minute, DockerAPIVersion: defaultDockerAPIVersion, diff --git a/extension/observer/dockerobserver/go.mod b/extension/observer/dockerobserver/go.mod index ca718a8bcda9..2dc1c25c9ba6 100644 --- a/extension/observer/dockerobserver/go.mod +++ b/extension/observer/dockerobserver/go.mod @@ -22,7 +22,7 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Microsoft/hcsshim v0.11.4 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect @@ -83,12 +83,9 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.24.0 // indirect - golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.26.0 // indirect - golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect google.golang.org/grpc v1.65.0 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/extension/observer/dockerobserver/go.sum b/extension/observer/dockerobserver/go.sum index e42802602a75..dbae7719a205 100644 --- a/extension/observer/dockerobserver/go.sum +++ b/extension/observer/dockerobserver/go.sum @@ -4,8 +4,8 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9 github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -190,8 +190,6 @@ golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -201,8 +199,6 @@ golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -227,8 +223,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/docker/config.go b/internal/docker/config.go index 460fb217786c..ee78570dec9f 100644 --- a/internal/docker/config.go +++ b/internal/docker/config.go @@ -11,10 +11,12 @@ import ( "time" "github.com/docker/docker/api/types/versions" + "github.com/docker/docker/client" ) type Config struct { // The URL of the docker server. Default is "unix:///var/run/docker.sock" + // on non-Windows and "npipe:////./pipe/docker_engine" on Windows Endpoint string `mapstructure:"endpoint"` // The maximum amount of time to wait for docker API responses. Default is 5s @@ -43,7 +45,7 @@ func NewConfig(endpoint string, timeout time.Duration, excludedImages []string, // to be used when creating a docker client func NewDefaultConfig() *Config { cfg := &Config{ - Endpoint: "unix:///var/run/docker.sock", + Endpoint: client.DefaultDockerHost, Timeout: 5 * time.Second, DockerAPIVersion: minimumRequiredDockerAPIVersion, } diff --git a/internal/docker/docker_test.go b/internal/docker/docker_test.go index 5bb749220f68..e5d5185b16cf 100644 --- a/internal/docker/docker_test.go +++ b/internal/docker/docker_test.go @@ -1,20 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -//go:build !windows - -// TODO review if tests should succeed on Windows - package docker import ( "context" "fmt" "io" - "net" "net/http" "net/http/httptest" - "os" + "runtime" "strings" "sync" "testing" @@ -47,34 +42,14 @@ func TestInvalidExclude(t *testing.T) { assert.Equal(t, "could not determine docker client excluded images: invalid glob item: unexpected end of input", err.Error()) } -func tmpSock(t *testing.T) (net.Listener, string) { - f, err := os.CreateTemp(os.TempDir(), "testsock") - if err != nil { - t.Fatal(err) - } - addr := f.Name() - assert.NoError(t, os.Remove(addr)) - - listener, err := net.Listen("unix", addr) - if err != nil { - t.Fatal(err) - } - - return listener, addr -} - func TestWatchingTimeouts(t *testing.T) { - listener, addr := tmpSock(t) + listener, addr := testListener(t) defer func() { assert.NoError(t, listener.Close()) }() - defer func() { - assert.NoError(t, os.Remove(addr)) - }() - config := &Config{ - Endpoint: fmt.Sprintf("unix://%s", addr), + Endpoint: portableEndpoint(addr), Timeout: 50 * time.Millisecond, } @@ -109,17 +84,14 @@ func TestWatchingTimeouts(t *testing.T) { } func TestFetchingTimeouts(t *testing.T) { - listener, addr := tmpSock(t) + listener, addr := testListener(t) defer func() { assert.NoError(t, listener.Close()) }() - defer func() { - assert.NoError(t, os.Remove(addr)) - }() config := &Config{ - Endpoint: fmt.Sprintf("unix://%s", addr), + Endpoint: portableEndpoint(addr), Timeout: 50 * time.Millisecond, } @@ -165,17 +137,13 @@ func TestFetchingTimeouts(t *testing.T) { } func TestToStatsJSONErrorHandling(t *testing.T) { - listener, addr := tmpSock(t) + listener, addr := testListener(t) defer func() { assert.NoError(t, listener.Close()) }() - defer func() { - assert.NoError(t, os.Remove(addr)) - }() - config := &Config{ - Endpoint: fmt.Sprintf("unix://%s", addr), + Endpoint: portableEndpoint(addr), Timeout: 50 * time.Millisecond, } @@ -254,3 +222,11 @@ func TestEventLoopHandlesError(t *testing.T) { return } } + +func portableEndpoint(addr string) string { + endpoint := fmt.Sprintf("unix://%s", addr) + if runtime.GOOS == "windows" { + endpoint = fmt.Sprintf("npipe://%s", strings.ReplaceAll(addr, "\\", "/")) + } + return endpoint +} diff --git a/internal/docker/docker_test_listener.go b/internal/docker/docker_test_listener.go new file mode 100644 index 000000000000..ba82fb72315e --- /dev/null +++ b/internal/docker/docker_test_listener.go @@ -0,0 +1,30 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +//go:build !windows + +package docker + +import ( + "net" + "os" + "testing" + + "github.com/stretchr/testify/require" +) + +func testListener(t *testing.T) (net.Listener, string) { + f, err := os.CreateTemp(t.TempDir(), "testListener") + if err != nil { + t.Fatal(err) + } + addr := f.Name() + require.NoError(t, f.Close()) + require.NoError(t, os.Remove(addr)) + + listener, err := net.Listen("unix", addr) + if err != nil { + t.Fatal(err) + } + + return listener, addr +} diff --git a/internal/docker/docker_test_listener_windows.go b/internal/docker/docker_test_listener_windows.go new file mode 100644 index 000000000000..4ae41f71f4b8 --- /dev/null +++ b/internal/docker/docker_test_listener_windows.go @@ -0,0 +1,22 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +//go:build windows + +package docker + +import ( + "net" + "testing" + + "github.com/Microsoft/go-winio" + "github.com/stretchr/testify/require" +) + +func testListener(t *testing.T) (net.Listener, string) { + addr := "\\\\.\\pipe\\testListener-otel-collector-contrib" + + l, err := winio.ListenPipe(addr, nil) + require.NoError(t, err) + require.NotNil(t, l) + return l, addr +} diff --git a/internal/docker/go.mod b/internal/docker/go.mod index 6dbd982a0658..ff55ed35ad8c 100644 --- a/internal/docker/go.mod +++ b/internal/docker/go.mod @@ -11,7 +11,7 @@ require ( ) require ( - github.com/Microsoft/go-winio v0.4.17 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect github.com/containerd/log v0.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/distribution/reference v0.5.0 // indirect diff --git a/internal/docker/go.sum b/internal/docker/go.sum index b8b6269c4c1e..7304bbb646a8 100644 --- a/internal/docker/go.sum +++ b/internal/docker/go.sum @@ -1,7 +1,7 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Microsoft/go-winio v0.4.17 h1:iT12IBVClFevaf8PuVyi3UmZOVh4OqnaLxDTW2O6j3w= -github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= @@ -59,11 +59,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -107,9 +105,7 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From ba73786d52e1f24cf1e0aa95af8ab869a4fbb040 Mon Sep 17 00:00:00 2001 From: pjanotti Date: Wed, 31 Jul 2024 11:27:56 -0700 Subject: [PATCH 2/5] Keep using os.TmpDir to keep short paths --- internal/docker/docker_test_listener.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/docker/docker_test_listener.go b/internal/docker/docker_test_listener.go index ba82fb72315e..65dec4cedc12 100644 --- a/internal/docker/docker_test_listener.go +++ b/internal/docker/docker_test_listener.go @@ -13,12 +13,11 @@ import ( ) func testListener(t *testing.T) (net.Listener, string) { - f, err := os.CreateTemp(t.TempDir(), "testListener") + f, err := os.CreateTemp(os.TempDir(), "testListener") if err != nil { t.Fatal(err) } addr := f.Name() - require.NoError(t, f.Close()) require.NoError(t, os.Remove(addr)) listener, err := net.Listen("unix", addr) From 4de91e78a173b13d40f59c7b89bb01f612f31d6f Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 31 Jul 2024 12:27:45 -0700 Subject: [PATCH 3/5] Add changelog --- ...ker_observer_default_windows_endpoint.yaml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .chloggen/docker_observer_default_windows_endpoint.yaml diff --git a/.chloggen/docker_observer_default_windows_endpoint.yaml b/.chloggen/docker_observer_default_windows_endpoint.yaml new file mode 100644 index 000000000000..8076d7e9a91c --- /dev/null +++ b/.chloggen/docker_observer_default_windows_endpoint.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'bug_fix' + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: docker_observer + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Change default endpoint for `docker_observer` on Windows to `npipe:////./pipe/docker_engine` + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [34358] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] From 204869fdb9bc4fa0b876990eb160d344a6ce8379 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 31 Jul 2024 13:09:40 -0700 Subject: [PATCH 4/5] make gotidy --- internal/docker/go.mod | 2 +- receiver/dockerstatsreceiver/go.mod | 5 +---- receiver/dockerstatsreceiver/go.sum | 10 ++-------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/internal/docker/go.mod b/internal/docker/go.mod index ff55ed35ad8c..42c11833d34d 100644 --- a/internal/docker/go.mod +++ b/internal/docker/go.mod @@ -3,6 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/docker go 1.21.0 require ( + github.com/Microsoft/go-winio v0.6.2 github.com/docker/docker v26.1.5+incompatible github.com/gobwas/glob v0.2.3 github.com/stretchr/testify v1.9.0 @@ -11,7 +12,6 @@ require ( ) require ( - github.com/Microsoft/go-winio v0.6.2 // indirect github.com/containerd/log v0.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/distribution/reference v0.5.0 // indirect diff --git a/receiver/dockerstatsreceiver/go.mod b/receiver/dockerstatsreceiver/go.mod index 86efba024bac..1b976b0ec409 100644 --- a/receiver/dockerstatsreceiver/go.mod +++ b/receiver/dockerstatsreceiver/go.mod @@ -28,7 +28,7 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Microsoft/hcsshim v0.11.4 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect @@ -95,12 +95,9 @@ require ( go.opentelemetry.io/otel/sdk v1.28.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect golang.org/x/crypto v0.24.0 // indirect - golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.26.0 // indirect - golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/grpc v1.65.0 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/receiver/dockerstatsreceiver/go.sum b/receiver/dockerstatsreceiver/go.sum index f6d5c76ab445..f7ddd6311f27 100644 --- a/receiver/dockerstatsreceiver/go.sum +++ b/receiver/dockerstatsreceiver/go.sum @@ -4,8 +4,8 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9 github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -207,8 +207,6 @@ golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -218,8 +216,6 @@ golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -243,8 +239,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 6274501d794174d41cb7c19fea1af328dc31e421 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 31 Jul 2024 14:17:32 -0700 Subject: [PATCH 5/5] make goporto --- internal/docker/docker_test_listener.go | 2 +- internal/docker/docker_test_listener_windows.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/docker/docker_test_listener.go b/internal/docker/docker_test_listener.go index 65dec4cedc12..15ea298bbfde 100644 --- a/internal/docker/docker_test_listener.go +++ b/internal/docker/docker_test_listener.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 //go:build !windows -package docker +package docker // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/docker" import ( "net" diff --git a/internal/docker/docker_test_listener_windows.go b/internal/docker/docker_test_listener_windows.go index 4ae41f71f4b8..03c2728848f6 100644 --- a/internal/docker/docker_test_listener_windows.go +++ b/internal/docker/docker_test_listener_windows.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 //go:build windows -package docker +package docker // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/docker" import ( "net"