diff --git a/docs/LICENSE_OF_DEPENDENCIES.md b/docs/LICENSE_OF_DEPENDENCIES.md index 4d3f189483269..72e25b733abec 100644 --- a/docs/LICENSE_OF_DEPENDENCIES.md +++ b/docs/LICENSE_OF_DEPENDENCIES.md @@ -100,6 +100,7 @@ following works: - github.com/cloudevents/sdk-go [Apache License 2.0](https://github.com/cloudevents/sdk-go/blob/main/LICENSE) - github.com/compose-spec/compose-go [Apache License 2.0](https://github.com/compose-spec/compose-go/blob/master/LICENSE) - github.com/containerd/containerd [Apache License 2.0](https://github.com/containerd/containerd/blob/master/LICENSE) +- github.com/containerd/errdefs [Apache License 2.0](https://github.com/containerd/errdefs/blob/main/LICENSE) - github.com/containerd/log [Apache License 2.0](https://github.com/containerd/log/blob/main/LICENSE) - github.com/coocood/freecache [MIT License](https://github.com/coocood/freecache/blob/master/LICENSE) - github.com/coreos/go-semver [Apache License 2.0](https://github.com/coreos/go-semver/blob/main/LICENSE) @@ -263,6 +264,7 @@ following works: - github.com/mitchellh/go-homedir [MIT License](https://github.com/mitchellh/go-homedir/blob/master/LICENSE) - github.com/mitchellh/mapstructure [MIT License](https://github.com/mitchellh/mapstructure/blob/master/LICENSE) - github.com/mitchellh/reflectwalk [MIT License](https://github.com/mitchellh/reflectwalk/blob/master/LICENSE) +- github.com/moby/docker-image-spec [Apache License 2.0](https://github.com/moby/docker-image-spec/blob/main/LICENSE) - github.com/moby/ipvs [Apache License 2.0](https://github.com/moby/ipvs/blob/master/LICENSE) - github.com/moby/patternmatcher [Apache License 2.0](https://github.com/moby/patternmatcher/blob/main/LICENSE) - github.com/moby/sys/sequential [Apache License 2.0](https://github.com/moby/sys/blob/main/LICENSE) diff --git a/go.mod b/go.mod index d97dd455dd9e8..0926a4ff82daa 100644 --- a/go.mod +++ b/go.mod @@ -72,7 +72,7 @@ require ( github.com/digitalocean/go-libvirt v0.0.0-20240513153900-2d13115a1625 github.com/dimchansky/utfbom v1.1.1 github.com/djherbis/times v1.6.0 - github.com/docker/docker v25.0.5+incompatible + github.com/docker/docker v27.1.1+incompatible github.com/docker/go-connections v0.5.0 github.com/dynatrace-oss/dynatrace-metric-utils-go v0.5.0 github.com/eclipse/paho.golang v0.21.0 @@ -186,8 +186,8 @@ require ( github.com/srebhan/protobufquery v0.0.0-20230803132024-ae4c0d878e55 github.com/stretchr/testify v1.9.0 github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 - github.com/testcontainers/testcontainers-go v0.31.0 - github.com/testcontainers/testcontainers-go/modules/kafka v0.31.0 + github.com/testcontainers/testcontainers-go v0.32.0 + github.com/testcontainers/testcontainers-go/modules/kafka v0.32.0 github.com/thomasklein94/packer-plugin-libvirt v0.5.0 github.com/tidwall/gjson v1.17.0 github.com/tinylib/msgp v1.2.0 @@ -261,8 +261,8 @@ require ( github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver v1.5.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/Microsoft/hcsshim v0.11.4 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/Microsoft/hcsshim v0.11.5 // indirect github.com/alecthomas/participle v0.4.1 // indirect github.com/andybalholm/brotli v1.1.0 // indirect github.com/antlr4-go/antlr/v4 v4.13.0 // indirect @@ -297,7 +297,8 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect - github.com/containerd/containerd v1.7.15 // indirect + github.com/containerd/containerd v1.7.18 // indirect + github.com/containerd/errdefs v0.1.0 // indirect github.com/containerd/log v0.1.0 // indirect github.com/couchbase/gomemcached v0.1.3 // indirect github.com/couchbase/goutils v0.1.0 // indirect @@ -308,7 +309,7 @@ require ( github.com/dennwc/varint v1.0.0 // indirect github.com/devigned/tab v0.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/distribution/reference v0.5.0 // indirect + github.com/distribution/reference v0.6.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect @@ -402,6 +403,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/patternmatcher v0.6.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect github.com/moby/sys/user v0.1.0 // indirect diff --git a/go.sum b/go.sum index 297b75bcb5e7f..b3324010e7b83 100644 --- a/go.sum +++ b/go.sum @@ -744,10 +744,10 @@ github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBa github.com/Mellanox/rdmamap v1.1.0 h1:A/W1wAXw+6vm58f3VklrIylgV+eDJlPVIMaIKuxgUT4= github.com/Mellanox/rdmamap v1.1.0/go.mod h1:fN+/V9lf10ABnDCwTaXRjeeWijLt2iVLETnK+sx/LY8= github.com/Microsoft/go-winio v0.4.15/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= -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/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= -github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= +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.5 h1:haEcLNpj9Ka1gd3B3tAEs9CpE0c+1IhoL59w/exYU38= +github.com/Microsoft/hcsshim v0.11.5/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA09d4bExKcU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PaesslerAG/gval v1.2.2 h1:Y7iBzhgE09IGTt5QgGQ2IdaYYYOU134YGHBThD+wm9E= github.com/PaesslerAG/gval v1.2.2/go.mod h1:XRFLwvmkTEdYziLdaCeCa5ImcGVrfQbeNUbVR+C6xac= @@ -1014,8 +1014,10 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/compose-spec/compose-go v1.20.2 h1:u/yfZHn4EaHGdidrZycWpxXgFffjYULlTbRfJ51ykjQ= github.com/compose-spec/compose-go v1.20.2/go.mod h1:+MdqXV4RA7wdFsahh/Kb8U0pAJqkg7mr4PM9tFKU8RM= -github.com/containerd/containerd v1.7.15 h1:afEHXdil9iAm03BmhjzKyXnnEBtjaLJefdU7DV0IFes= -github.com/containerd/containerd v1.7.15/go.mod h1:ISzRRTMF8EXNpJlTzyr2XMhN+j9K302C21/+cr3kUnY= +github.com/containerd/containerd v1.7.18 h1:jqjZTQNfXGoEaZdW1WwPU0RqSn1Bm2Ay/KJPUuO8nao= +github.com/containerd/containerd v1.7.18/go.mod h1:IYEk9/IO6wAPUz2bCMVUbsfXjzw5UNP5fLz4PsUygQ4= +github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= +github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/coocood/freecache v1.2.4 h1:UdR6Yz/X1HW4fZOuH0Z94KwG851GWOSknua5VUbb/5M= @@ -1068,16 +1070,16 @@ github.com/digitalocean/godo v1.104.1 h1:SZNxjAsskM/su0YW9P8Wx3gU0W1Z13b6tZlYNpl github.com/digitalocean/godo v1.104.1/go.mod h1:VAI/L5YDzMuPRU01lEEUSQ/sp5Z//1HnnFv/RBTEdbg= github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U= github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= -github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= -github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c= github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v24.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE= -github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY= +github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= @@ -1853,6 +1855,8 @@ github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4/go.mod h1 github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/ipvs v1.1.0 h1:ONN4pGaZQgAx+1Scz5RvWV4Q7Gb+mvfRh3NsPS+1XQQ= github.com/moby/ipvs v1.1.0/go.mod h1:4VJMWuf098bsUMmZEiD4Tjk/O7mOn3l1PTD3s4OoYAs= github.com/moby/moby v24.0.6+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc= @@ -2222,10 +2226,10 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69 github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 h1:Oj2e7Sae4XrOsk3ij21QjjEgAcVSeo9nkp0dI//cD2o= github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62/go.mod h1:qUzPVlSj2UgxJkVbH0ZwuuiR46U8RBMDT5KLY78Ifpw= github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0= -github.com/testcontainers/testcontainers-go v0.31.0 h1:W0VwIhcEVhRflwL9as3dhY6jXjVCA27AkmbnZ+UTh3U= -github.com/testcontainers/testcontainers-go v0.31.0/go.mod h1:D2lAoA0zUFiSY+eAflqK5mcUx/A5hrrORaEQrd0SefI= -github.com/testcontainers/testcontainers-go/modules/kafka v0.31.0 h1:8B1u+sDwYhTUoMI271wPjnCg9mz3dHGLMWpP7YyF7kE= -github.com/testcontainers/testcontainers-go/modules/kafka v0.31.0/go.mod h1:W1+yLUfUl8VLTzvmApP2FBHgCk8I5SKKjDWjxWEc33U= +github.com/testcontainers/testcontainers-go v0.32.0 h1:ug1aK08L3gCHdhknlTTwWjPHPS+/alvLJU/DRxTD/ME= +github.com/testcontainers/testcontainers-go v0.32.0/go.mod h1:CRHrzHLQhlXUsa5gXjTOfqIEJcrK5+xMDmBr/WMI88E= +github.com/testcontainers/testcontainers-go/modules/kafka v0.32.0 h1:OeqTsdtPhwVQbq0pP35okVY2Qb6vb/5LaOBqewTWlGk= +github.com/testcontainers/testcontainers-go/modules/kafka v0.32.0/go.mod h1:GCPw9ky5rQpMk81DyNaETjbfZiAwA7j5LLeVPnIvgII= github.com/thomasklein94/packer-plugin-libvirt v0.5.0 h1:aj2HLHZZM/ClGLIwVp9rrgh+2TOU/w4EiaZHAwCpOgs= github.com/thomasklein94/packer-plugin-libvirt v0.5.0/go.mod h1:GwN82FQ6KxCNKtS8LNUgLbwTZs90GGhBzCmTNkrTCrY= github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= diff --git a/plugins/inputs/docker/client.go b/plugins/inputs/docker/client.go index 73ae6b658af16..5c9afc6f2c287 100644 --- a/plugins/inputs/docker/client.go +++ b/plugins/inputs/docker/client.go @@ -19,7 +19,7 @@ var ( type Client interface { Info(ctx context.Context) (system.Info, error) ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) - ContainerStats(ctx context.Context, containerID string, stream bool) (types.ContainerStats, error) + ContainerStats(ctx context.Context, containerID string, stream bool) (container.StatsResponseReader, error) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) @@ -65,7 +65,7 @@ func (c *SocketClient) Info(ctx context.Context) (system.Info, error) { func (c *SocketClient) ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) { return c.client.ContainerList(ctx, options) } -func (c *SocketClient) ContainerStats(ctx context.Context, containerID string, stream bool) (types.ContainerStats, error) { +func (c *SocketClient) ContainerStats(ctx context.Context, containerID string, stream bool) (container.StatsResponseReader, error) { return c.client.ContainerStats(ctx, containerID, stream) } func (c *SocketClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { diff --git a/plugins/inputs/docker/docker.go b/plugins/inputs/docker/docker.go index 79ad56c56f28a..189b48528416d 100644 --- a/plugins/inputs/docker/docker.go +++ b/plugins/inputs/docker/docker.go @@ -471,7 +471,7 @@ func (d *Docker) gatherContainer( container types.Container, acc telegraf.Accumulator, ) error { - var v *types.StatsJSON + var v *typeContainer.StatsResponse cname := parseContainerName(container.Names) @@ -533,7 +533,7 @@ func (d *Docker) gatherContainerInspect( acc telegraf.Accumulator, tags map[string]string, daemonOSType string, - v *types.StatsJSON, + v *typeContainer.StatsResponse, ) error { ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout)) defer cancel() @@ -605,7 +605,7 @@ func (d *Docker) gatherContainerInspect( } func (d *Docker) parseContainerStats( - stat *types.StatsJSON, + stat *typeContainer.StatsResponse, acc telegraf.Accumulator, tags map[string]string, id string, @@ -782,7 +782,7 @@ func (d *Docker) parseContainerStats( } // Make a map of devices to their block io stats -func getDeviceStatMap(blkioStats types.BlkioStats) map[string]map[string]interface{} { +func getDeviceStatMap(blkioStats typeContainer.BlkioStats) map[string]map[string]interface{} { deviceStatMap := make(map[string]map[string]interface{}) for _, metric := range blkioStats.IoServiceBytesRecursive { @@ -845,7 +845,7 @@ func getDeviceStatMap(blkioStats types.BlkioStats) map[string]map[string]interfa func (d *Docker) gatherBlockIOMetrics( acc telegraf.Accumulator, - stat *types.StatsJSON, + stat *typeContainer.StatsResponse, tags map[string]string, tm time.Time, id string, diff --git a/plugins/inputs/docker/docker_test.go b/plugins/inputs/docker/docker_test.go index 9e0ac8ce49a72..ee39cf43d41bc 100644 --- a/plugins/inputs/docker/docker_test.go +++ b/plugins/inputs/docker/docker_test.go @@ -24,7 +24,7 @@ import ( type MockClient struct { InfoF func() (system.Info, error) ContainerListF func(options typeContainer.ListOptions) ([]types.Container, error) - ContainerStatsF func(containerID string) (types.ContainerStats, error) + ContainerStatsF func(containerID string) (typeContainer.StatsResponseReader, error) ContainerInspectF func() (types.ContainerJSON, error) ServiceListF func() ([]swarm.Service, error) TaskListF func() ([]swarm.Task, error) @@ -42,7 +42,7 @@ func (c *MockClient) ContainerList(_ context.Context, options typeContainer.List return c.ContainerListF(options) } -func (c *MockClient) ContainerStats(_ context.Context, containerID string, _ bool) (types.ContainerStats, error) { +func (c *MockClient) ContainerStats(_ context.Context, containerID string, _ bool) (typeContainer.StatsResponseReader, error) { return c.ContainerStatsF(containerID) } @@ -81,7 +81,7 @@ var baseClient = MockClient{ ContainerListF: func(typeContainer.ListOptions) ([]types.Container, error) { return containerList, nil }, - ContainerStatsF: func(s string) (types.ContainerStats, error) { + ContainerStatsF: func(s string) (typeContainer.StatsResponseReader, error) { return containerStats(s), nil }, ContainerInspectF: func() (types.ContainerJSON, error) { @@ -429,7 +429,7 @@ func TestDocker_WindowsMemoryContainerStats(t *testing.T) { ContainerListF: func(typeContainer.ListOptions) ([]types.Container, error) { return containerList, nil }, - ContainerStatsF: func(string) (types.ContainerStats, error) { + ContainerStatsF: func(string) (typeContainer.StatsResponseReader, error) { return containerStatsWindows(), nil }, ContainerInspectF: func() (types.ContainerJSON, error) { @@ -684,7 +684,7 @@ func TestContainerNames(t *testing.T) { client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) { return containerList, nil } - client.ContainerStatsF = func(s string) (types.ContainerStats, error) { + client.ContainerStatsF = func(s string) (typeContainer.StatsResponseReader, error) { return containerStats(s), nil } @@ -1219,8 +1219,8 @@ func TestContainerName(t *testing.T) { }) return containers, nil } - client.ContainerStatsF = func(string) (types.ContainerStats, error) { - return types.ContainerStats{ + client.ContainerStatsF = func(string) (typeContainer.StatsResponseReader, error) { + return typeContainer.StatsResponseReader{ Body: io.NopCloser(strings.NewReader(`{"name": "logspout"}`)), }, nil } @@ -1239,8 +1239,8 @@ func TestContainerName(t *testing.T) { }) return containers, nil } - client.ContainerStatsF = func(string) (types.ContainerStats, error) { - return types.ContainerStats{ + client.ContainerStatsF = func(string) (typeContainer.StatsResponseReader, error) { + return typeContainer.StatsResponseReader{ Body: io.NopCloser(strings.NewReader(`{}`)), }, nil } @@ -1304,7 +1304,7 @@ func TestHostnameFromID(t *testing.T) { func Test_parseContainerStatsPerDeviceAndTotal(t *testing.T) { type args struct { - stat *types.StatsJSON + stat *typeContainer.StatsResponse tags map[string]string id string perDeviceInclude []string diff --git a/plugins/inputs/docker/docker_testdata.go b/plugins/inputs/docker/docker_testdata.go index 85040e759e538..08510224aec73 100644 --- a/plugins/inputs/docker/docker_testdata.go +++ b/plugins/inputs/docker/docker_testdata.go @@ -243,8 +243,8 @@ var NodeList = []swarm.Node{ }, } -func containerStats(s string) types.ContainerStats { - var stat types.ContainerStats +func containerStats(s string) container.StatsResponseReader { + var stat container.StatsResponseReader var name string switch s { case "e2173b9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296b7dfb": @@ -370,10 +370,10 @@ func containerStats(s string) types.ContainerStats { return stat } -func testStats() *types.StatsJSON { - stats := &types.StatsJSON{} +func testStats() *container.StatsResponse { + stats := &container.StatsResponse{} stats.Read = time.Now() - stats.Networks = make(map[string]types.NetworkStats) + stats.Networks = make(map[string]container.NetworkStats) stats.CPUStats.OnlineCPUs = 2 stats.CPUStats.CPUUsage.PercpuUsage = []uint64{1, 1002, 0, 0} stats.CPUStats.CPUUsage.UsageInUsermode = 100 @@ -421,7 +421,7 @@ func testStats() *types.StatsJSON { stats.MemoryStats.Failcnt = 1 stats.MemoryStats.Limit = 2000 - stats.Networks["eth0"] = types.NetworkStats{ + stats.Networks["eth0"] = container.NetworkStats{ RxDropped: 1, RxBytes: 2, RxErrors: 3, @@ -432,7 +432,7 @@ func testStats() *types.StatsJSON { TxBytes: 4, } - stats.Networks["eth1"] = types.NetworkStats{ + stats.Networks["eth1"] = container.NetworkStats{ RxDropped: 5, RxBytes: 6, RxErrors: 7, @@ -443,19 +443,19 @@ func testStats() *types.StatsJSON { TxBytes: 8, } - sbr := types.BlkioStatEntry{ + sbr := container.BlkioStatEntry{ Major: 6, Minor: 0, Op: "read", Value: 100, } - sr := types.BlkioStatEntry{ + sr := container.BlkioStatEntry{ Major: 6, Minor: 0, Op: "write", Value: 101, } - sr2 := types.BlkioStatEntry{ + sr2 := container.BlkioStatEntry{ Major: 6, Minor: 1, Op: "write", @@ -472,8 +472,8 @@ func testStats() *types.StatsJSON { return stats } -func containerStatsWindows() types.ContainerStats { - var stat types.ContainerStats +func containerStatsWindows() container.StatsResponseReader { + var stat container.StatsResponseReader jsonStat := ` { "read":"2017-01-11T08:32:46.2413794Z", diff --git a/plugins/inputs/docker/stats_helpers.go b/plugins/inputs/docker/stats_helpers.go index e5e21ee783154..a80b98fa948d4 100644 --- a/plugins/inputs/docker/stats_helpers.go +++ b/plugins/inputs/docker/stats_helpers.go @@ -2,9 +2,11 @@ // https://github.com/docker/cli/blob/master/cli/command/container/stats_helpers.go package docker -import "github.com/docker/docker/api/types" +import ( + "github.com/docker/docker/api/types/container" +) -func CalculateCPUPercentUnix(previousCPU, previousSystem uint64, v *types.StatsJSON) float64 { +func CalculateCPUPercentUnix(previousCPU, previousSystem uint64, v *container.StatsResponse) float64 { var ( cpuPercent = 0.0 // calculate the change for the cpu usage of the container in between readings @@ -23,7 +25,7 @@ func CalculateCPUPercentUnix(previousCPU, previousSystem uint64, v *types.StatsJ return cpuPercent } -func calculateCPUPercentWindows(v *types.StatsJSON) float64 { +func calculateCPUPercentWindows(v *container.StatsResponse) float64 { // Max number of 100ns intervals between the previous time read and now possIntervals := uint64(v.Read.Sub(v.PreRead).Nanoseconds()) // Start with number of ns intervals possIntervals /= 100 // Convert to number of 100ns intervals @@ -48,7 +50,7 @@ func calculateCPUPercentWindows(v *types.StatsJSON) float64 { // // This definition is designed to be consistent with past values and the latest docker CLI // * https://github.com/docker/cli/blob/6e2838e18645e06f3e4b6c5143898ccc44063e3b/cli/command/container/stats_helpers.go#L239 -func CalculateMemUsageUnixNoCache(mem types.MemoryStats) float64 { +func CalculateMemUsageUnixNoCache(mem container.MemoryStats) float64 { // Docker 19.03 and older if v, isOldDocker := mem.Stats["cache"]; isOldDocker && v < mem.Usage { return float64(mem.Usage - v) diff --git a/plugins/inputs/ecs/client.go b/plugins/inputs/ecs/client.go index f2d7d5fb92dcd..12f4bf2e2023a 100644 --- a/plugins/inputs/ecs/client.go +++ b/plugins/inputs/ecs/client.go @@ -7,7 +7,7 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" ) var ( @@ -24,7 +24,7 @@ var ( // Client is the ECS client contract type Client interface { Task() (*Task, error) - ContainerStats() (map[string]*types.StatsJSON, error) + ContainerStats() (map[string]*container.StatsResponse, error) } type httpClient interface { @@ -132,7 +132,7 @@ func (c *EcsClient) Task() (*Task, error) { } // ContainerStats calls the ECS stats endpoint and returns a populated container stats map -func (c *EcsClient) ContainerStats() (map[string]*types.StatsJSON, error) { +func (c *EcsClient) ContainerStats() (map[string]*container.StatsResponse, error) { req, err := http.NewRequest("GET", c.statsURL, nil) if err != nil { return nil, err @@ -155,9 +155,9 @@ func (c *EcsClient) ContainerStats() (map[string]*types.StatsJSON, error) { // PollSync executes Task and ContainerStats in parallel. If both succeed, both structs are returned. // If either errors, a single error is returned. -func PollSync(c Client) (*Task, map[string]*types.StatsJSON, error) { +func PollSync(c Client) (*Task, map[string]*container.StatsResponse, error) { var task *Task - var stats map[string]*types.StatsJSON + var stats map[string]*container.StatsResponse var err error if stats, err = c.ContainerStats(); err != nil { diff --git a/plugins/inputs/ecs/client_test.go b/plugins/inputs/ecs/client_test.go index 1e28b4a923253..f451768fdccf1 100644 --- a/plugins/inputs/ecs/client_test.go +++ b/plugins/inputs/ecs/client_test.go @@ -9,20 +9,20 @@ import ( "os" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/require" ) type pollMock struct { task func() (*Task, error) - stats func() (map[string]*types.StatsJSON, error) + stats func() (map[string]*container.StatsResponse, error) } func (p *pollMock) Task() (*Task, error) { return p.task() } -func (p *pollMock) ContainerStats() (map[string]*types.StatsJSON, error) { +func (p *pollMock) ContainerStats() (map[string]*container.StatsResponse, error) { return p.stats() } @@ -31,7 +31,7 @@ func TestEcsClient_PollSync(t *testing.T) { name string mock *pollMock want *Task - want1 map[string]*types.StatsJSON + want1 map[string]*container.StatsResponse wantErr bool }{ { @@ -40,7 +40,7 @@ func TestEcsClient_PollSync(t *testing.T) { task: func() (*Task, error) { return &validMeta, nil }, - stats: func() (map[string]*types.StatsJSON, error) { + stats: func() (map[string]*container.StatsResponse, error) { return validStats, nil }, }, @@ -53,7 +53,7 @@ func TestEcsClient_PollSync(t *testing.T) { task: func() (*Task, error) { return nil, errors.New("err") }, - stats: func() (map[string]*types.StatsJSON, error) { + stats: func() (map[string]*container.StatsResponse, error) { return validStats, nil }, }, @@ -65,7 +65,7 @@ func TestEcsClient_PollSync(t *testing.T) { task: func() (*Task, error) { return &validMeta, nil }, - stats: func() (map[string]*types.StatsJSON, error) { + stats: func() (map[string]*container.StatsResponse, error) { return nil, errors.New("err") }, }, @@ -172,7 +172,7 @@ func TestEcsClient_ContainerStats(t *testing.T) { tests := []struct { name string client httpClient - want map[string]*types.StatsJSON + want map[string]*container.StatsResponse wantErr bool }{ { diff --git a/plugins/inputs/ecs/ecs_test.go b/plugins/inputs/ecs/ecs_test.go index 9407d15770194..ec17bc4000cfb 100644 --- a/plugins/inputs/ecs/ecs_test.go +++ b/plugins/inputs/ecs/ecs_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/require" ) @@ -28,13 +28,13 @@ func mustParseNano(value string) time.Time { return t } -var validStats = map[string]*types.StatsJSON{ +var validStats = map[string]*container.StatsResponse{ pauseStatsKey: { - Stats: types.Stats{ + Stats: container.Stats{ Read: pauseStatsRead, PreRead: pauseStatsPreRead, - BlkioStats: types.BlkioStats{ - IoServiceBytesRecursive: []types.BlkioStatEntry{ + BlkioStats: container.BlkioStats{ + IoServiceBytesRecursive: []container.BlkioStatEntry{ { Major: 202, Minor: 26368, @@ -148,7 +148,7 @@ var validStats = map[string]*types.StatsJSON{ Value: 790528, }, }, - IoServicedRecursive: []types.BlkioStatEntry{ + IoServicedRecursive: []container.BlkioStatEntry{ { Major: 202, Minor: 26368, @@ -263,8 +263,8 @@ var validStats = map[string]*types.StatsJSON{ }, }, }, - CPUStats: types.CPUStats{ - CPUUsage: types.CPUUsage{ + CPUStats: container.CPUStats{ + CPUUsage: container.CPUUsage{ PercpuUsage: []uint64{ 26426156, 0, @@ -287,10 +287,10 @@ var validStats = map[string]*types.StatsJSON{ }, SystemUsage: 2336100000000, OnlineCPUs: 1, - ThrottlingData: types.ThrottlingData{}, + ThrottlingData: container.ThrottlingData{}, }, - PreCPUStats: types.CPUStats{ - CPUUsage: types.CPUUsage{ + PreCPUStats: container.CPUStats{ + CPUUsage: container.CPUUsage{ PercpuUsage: []uint64{ 26426156, 0, @@ -313,9 +313,9 @@ var validStats = map[string]*types.StatsJSON{ }, SystemUsage: 2335090000000, OnlineCPUs: 1, - ThrottlingData: types.ThrottlingData{}, + ThrottlingData: container.ThrottlingData{}, }, - MemoryStats: types.MemoryStats{ + MemoryStats: container.MemoryStats{ Stats: map[string]uint64{ "cache": 790528, "mapped_file": 618496, @@ -344,7 +344,7 @@ var validStats = map[string]*types.StatsJSON{ Limit: 1033658368, }, }, - Networks: map[string]types.NetworkStats{ + Networks: map[string]container.NetworkStats{ "eth0": { RxBytes: uint64(5338), RxDropped: uint64(0), @@ -368,11 +368,11 @@ var validStats = map[string]*types.StatsJSON{ }, }, nginxStatsKey: { - Stats: types.Stats{ + Stats: container.Stats{ Read: nginxStatsRead, PreRead: nginxStatsPreRead, - BlkioStats: types.BlkioStats{ - IoServiceBytesRecursive: []types.BlkioStatEntry{ + BlkioStats: container.BlkioStats{ + IoServiceBytesRecursive: []container.BlkioStatEntry{ { Major: 202, Minor: 26368, @@ -486,7 +486,7 @@ var validStats = map[string]*types.StatsJSON{ Value: 5730304, }, }, - IoServicedRecursive: []types.BlkioStatEntry{ + IoServicedRecursive: []container.BlkioStatEntry{ { Major: 202, Minor: 26368, @@ -601,8 +601,8 @@ var validStats = map[string]*types.StatsJSON{ }, }, }, - CPUStats: types.CPUStats{ - CPUUsage: types.CPUUsage{ + CPUStats: container.CPUStats{ + CPUUsage: container.CPUUsage{ PercpuUsage: []uint64{ 65599511, 0, @@ -626,10 +626,10 @@ var validStats = map[string]*types.StatsJSON{ }, SystemUsage: 2336100000000, OnlineCPUs: 1, - ThrottlingData: types.ThrottlingData{}, + ThrottlingData: container.ThrottlingData{}, }, - PreCPUStats: types.CPUStats{ - CPUUsage: types.CPUUsage{ + PreCPUStats: container.CPUStats{ + CPUUsage: container.CPUUsage{ PercpuUsage: []uint64{ 65599511, 0, @@ -653,9 +653,9 @@ var validStats = map[string]*types.StatsJSON{ }, SystemUsage: 2335090000000, OnlineCPUs: 1, - ThrottlingData: types.ThrottlingData{}, + ThrottlingData: container.ThrottlingData{}, }, - MemoryStats: types.MemoryStats{ + MemoryStats: container.MemoryStats{ Stats: map[string]uint64{ "cache": 5787648, "mapped_file": 3616768, diff --git a/plugins/inputs/ecs/stats.go b/plugins/inputs/ecs/stats.go index 9d233e25f9e10..fbc56f03f7570 100644 --- a/plugins/inputs/ecs/stats.go +++ b/plugins/inputs/ecs/stats.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs/docker" @@ -45,7 +45,7 @@ func metastats(id string, c *Container, acc telegraf.Accumulator, tags map[strin acc.AddFields("ecs_container_meta", metafields, tags, tm) } -func memstats(id string, stats *types.StatsJSON, acc telegraf.Accumulator, tags map[string]string, tm time.Time) { +func memstats(id string, stats *container.StatsResponse, acc telegraf.Accumulator, tags map[string]string, tm time.Time) { memfields := map[string]interface{}{ "container_id": id, } @@ -102,7 +102,7 @@ func memstats(id string, stats *types.StatsJSON, acc telegraf.Accumulator, tags acc.AddFields("ecs_container_mem", memfields, tags, tm) } -func cpustats(id string, stats *types.StatsJSON, acc telegraf.Accumulator, tags map[string]string, tm time.Time) { +func cpustats(id string, stats *container.StatsResponse, acc telegraf.Accumulator, tags map[string]string, tm time.Time) { cpufields := map[string]interface{}{ "usage_total": stats.CPUStats.CPUUsage.TotalUsage, "usage_in_usermode": stats.CPUStats.CPUUsage.UsageInUsermode, @@ -143,7 +143,7 @@ func cpustats(id string, stats *types.StatsJSON, acc telegraf.Accumulator, tags } } -func netstats(id string, stats *types.StatsJSON, acc telegraf.Accumulator, tags map[string]string, tm time.Time) { +func netstats(id string, stats *container.StatsResponse, acc telegraf.Accumulator, tags map[string]string, tm time.Time) { totalNetworkStatMap := make(map[string]interface{}) for network, netstats := range stats.Networks { netfields := map[string]interface{}{ @@ -195,7 +195,7 @@ func netstats(id string, stats *types.StatsJSON, acc telegraf.Accumulator, tags } } -func blkstats(id string, stats *types.StatsJSON, acc telegraf.Accumulator, tags map[string]string, tm time.Time) { +func blkstats(id string, stats *container.StatsResponse, acc telegraf.Accumulator, tags map[string]string, tm time.Time) { blkioStats := stats.BlkioStats // Make a map of devices to their block io stats deviceStatMap := make(map[string]map[string]interface{}) diff --git a/plugins/inputs/ecs/types.go b/plugins/inputs/ecs/types.go index 1687c3f054c8f..2e171d4d6dadd 100644 --- a/plugins/inputs/ecs/types.go +++ b/plugins/inputs/ecs/types.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" ) // Task is the ECS task representation @@ -36,7 +36,7 @@ type Container struct { Limits map[string]float64 CreatedAt time.Time StartedAt time.Time - Stats types.StatsJSON + Stats container.StatsResponse Type string Networks []Network } @@ -54,8 +54,8 @@ func unmarshalTask(r io.Reader) (*Task, error) { } // docker parsers -func unmarshalStats(r io.Reader) (map[string]*types.StatsJSON, error) { - var statsMap map[string]*types.StatsJSON +func unmarshalStats(r io.Reader) (map[string]*container.StatsResponse, error) { + var statsMap map[string]*container.StatsResponse if err := json.NewDecoder(r).Decode(&statsMap); err != nil { return nil, err } @@ -63,7 +63,7 @@ func unmarshalStats(r io.Reader) (map[string]*types.StatsJSON, error) { } // interleaves Stats in to the Container objects in the Task -func mergeTaskStats(task *Task, stats map[string]*types.StatsJSON) { +func mergeTaskStats(task *Task, stats map[string]*container.StatsResponse) { for i := range task.Containers { c := &task.Containers[i] if strings.Trim(c.ID, " ") == "" { diff --git a/plugins/inputs/kafka_consumer/kafka_consumer_test.go b/plugins/inputs/kafka_consumer/kafka_consumer_test.go index 40f1b4cf138e3..e9f75dbd0fc86 100644 --- a/plugins/inputs/kafka_consumer/kafka_consumer_test.go +++ b/plugins/inputs/kafka_consumer/kafka_consumer_test.go @@ -10,7 +10,6 @@ import ( "github.com/IBM/sarama" "github.com/stretchr/testify/require" - "github.com/testcontainers/testcontainers-go" kafkacontainer "github.com/testcontainers/testcontainers-go/modules/kafka" "github.com/influxdata/telegraf" @@ -490,10 +489,7 @@ func TestKafkaRoundTripIntegration(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ctx := context.Background() - kafkaContainer, err := kafkacontainer.RunContainer(ctx, - kafkacontainer.WithClusterID("test-cluster"), - testcontainers.WithImage("confluentinc/confluent-local:7.5.0"), - ) + kafkaContainer, err := kafkacontainer.Run(ctx, "confluentinc/confluent-local:7.5.0") require.NoError(t, err) defer kafkaContainer.Terminate(ctx) //nolint:errcheck // ignored diff --git a/plugins/inputs/redis_sentinel/redis_sentinel_test.go b/plugins/inputs/redis_sentinel/redis_sentinel_test.go index 938c05d1af4bd..855763621ff6c 100644 --- a/plugins/inputs/redis_sentinel/redis_sentinel_test.go +++ b/plugins/inputs/redis_sentinel/redis_sentinel_test.go @@ -27,7 +27,7 @@ func TestRedisSentinelConnectIntegration(t *testing.T) { } ctx := context.Background() - net, err := network.New(ctx, network.WithCheckDuplicate()) + net, err := network.New(ctx) require.NoError(t, err) defer func() { require.NoError(t, net.Remove(ctx), "terminating network failed") diff --git a/plugins/outputs/kafka/kafka_test.go b/plugins/outputs/kafka/kafka_test.go index 5e28256c40f66..06c666828b756 100644 --- a/plugins/outputs/kafka/kafka_test.go +++ b/plugins/outputs/kafka/kafka_test.go @@ -7,7 +7,6 @@ import ( "github.com/IBM/sarama" "github.com/stretchr/testify/require" - "github.com/testcontainers/testcontainers-go" kafkacontainer "github.com/testcontainers/testcontainers-go/modules/kafka" "github.com/influxdata/telegraf" @@ -27,10 +26,7 @@ func TestConnectAndWriteIntegration(t *testing.T) { } ctx := context.Background() - kafkaContainer, err := kafkacontainer.RunContainer(ctx, - kafkacontainer.WithClusterID("test-cluster"), - testcontainers.WithImage("confluentinc/confluent-local:7.5.0"), - ) + kafkaContainer, err := kafkacontainer.Run(ctx, "confluentinc/confluent-local:7.5.0") require.NoError(t, err) defer kafkaContainer.Terminate(ctx) //nolint:errcheck // ignored diff --git a/testutil/container_test.go b/testutil/container_test.go index fb49f676a52b2..0a6f0524aed23 100644 --- a/testutil/container_test.go +++ b/testutil/container_test.go @@ -25,6 +25,7 @@ func TestMappedPortLookupIntegration(t *testing.T) { if testing.Short() { t.Skip("Skipping integration test in short mode") } + t.Skip("Broken due to testcontainers/testcontainers-go#2652") cases := []struct { name string