diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6c76fbe63072..d830458da194 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -351,9 +351,7 @@ jobs: - exporter-1 - exporter-2 - exporter-3 - - extension-0 - - extension-1 - - extension-2 + - extension - connector - internal - pkg @@ -382,7 +380,7 @@ jobs: integration-tests: if: ${{ github.actor != 'dependabot[bot]' && always() }} - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 needs: [setup-environment, integration-tests-matrix] steps: - name: Print result diff --git a/Makefile b/Makefile index 0556e485253f..341c909dbfc3 100644 --- a/Makefile +++ b/Makefile @@ -42,10 +42,7 @@ EXPORTER_MODS_1 := $(shell find ./exporter/[d-i]* $(FIND_MOD_ARGS) -exec $(TO_MO EXPORTER_MODS_2 := $(shell find ./exporter/[k-o]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) EXPORTER_MODS_3 := $(shell find ./exporter/[p-z]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) EXPORTER_MODS := $(EXPORTER_MODS_0) $(EXPORTER_MODS_1) $(EXPORTER_MODS_2) $(EXPORTER_MODS_3) -EXTENSION_MODS_0 := $(shell find ./extension/[a-d]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) -EXTENSION_MODS_1 := $(shell find ./extension/[e]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) -EXTENSION_MODS_2 := $(shell find ./extension/[f-z]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) -EXTENSION_MODS := $(EXTENSION_MODS_0) $(EXTENSION_MODS_1) $(EXTENSION_MODS_2) +EXTENSION_MODS := $(shell find ./extension/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) CONNECTOR_MODS := $(shell find ./connector/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) INTERNAL_MODS := $(shell find ./internal/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) PKG_MODS := $(shell find ./pkg/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) @@ -81,9 +78,7 @@ all-groups: @echo "\nexporter-1: $(EXPORTER_MODS_1)" @echo "\nexporter-2: $(EXPORTER_MODS_2)" @echo "\nexporter-3: $(EXPORTER_MODS_3)" - @echo "\nextension-0: $(EXTENSION_MODS_0)" - @echo "\nextension-1: $(EXTENSION_MODS_1)" - @echo "\nextension-2: $(EXTENSION_MODS_2)" + @echo "\nextension: $(EXTENSION_MODS)" @echo "\nconnector: $(CONNECTOR_MODS)" @echo "\ninternal: $(INTERNAL_MODS)" @echo "\npkg: $(PKG_MODS)" @@ -250,15 +245,6 @@ for-exporter-3-target: $(EXPORTER_MODS_3) .PHONY: for-extension-target for-extension-target: $(EXTENSION_MODS) -.PHONY: for-extension-0-target -for-extension-0-target: $(EXTENSION_MODS_0) - -.PHONY: for-extension-1-target -for-extension-1-target: $(EXTENSION_MODS_1) - -.PHONY: for-extension-2-target -for-extension-2-target: $(EXTENSION_MODS_2) - .PHONY: for-connector-target for-connector-target: $(CONNECTOR_MODS) diff --git a/Makefile.Common b/Makefile.Common index 0d65c3be5c96..1bce621096fe 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -29,11 +29,9 @@ GO_BUILD_TAGS="" GO_BUILD_LDFLAGS="-s -w" GOTEST_TIMEOUT?= 600s GOTEST_OPT?= -race -timeout $(GOTEST_TIMEOUT) -parallel 4 --tags=$(GO_BUILD_TAGS) -GOTEST_INTEGRATION_OPT?= -race -timeout 360s -parallel 4 -skip Sudo -GOTEST_INTEGRATION_OPT_SUDO?= -race -timeout 360s -parallel 4 -exec sudo -run Sudo +GOTEST_INTEGRATION_OPT?= -race -timeout 360s -parallel 4 GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS) -GOTEST_OPT_WITH_INTEGRATION_SUDO=$(GOTEST_INTEGRATION_OPT_SUDO) -tags=integration,$(GO_BUILD_TAGS) GOTEST_OPT_WITH_INTEGRATION_COVERAGE=$(GOTEST_OPT_WITH_INTEGRATION) -coverprofile=integration-coverage.txt -covermode=atomic GOCMD?= go GOOS=$(shell $(GOCMD) env GOOS) @@ -156,13 +154,12 @@ endif runbuilttest: $(GOTESTSUM) ifneq (,$(wildcard ./builtunitetest.test)) $(GOTESTSUM) --raw-command -- $(GOCMD) tool test2json -p "./..." -t ./builtunitetest.test -test.v -test.failfast -test.timeout $(GOTEST_TIMEOUT) -endif +endif .PHONY: mod-integration-test mod-integration-test: $(GOTESTSUM) @echo "running $(GOCMD) integration test ./... in `pwd`" $(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION) - $(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION_SUDO) @if [ -e integration-coverage.txt ]; then \ $(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \ fi diff --git a/extension/cgroupruntimeextension/go.mod b/extension/cgroupruntimeextension/go.mod index 52a28502f7d5..bd0d101472a6 100644 --- a/extension/cgroupruntimeextension/go.mod +++ b/extension/cgroupruntimeextension/go.mod @@ -4,7 +4,6 @@ go 1.22.4 require ( github.com/KimMachineGun/automemlimit v0.7.0 - github.com/containerd/cgroups/v3 v3.0.5 github.com/rdforte/gomaxecs v1.1.0 github.com/stretchr/testify v1.10.0 go.opentelemetry.io/collector/component v0.117.0 @@ -15,18 +14,13 @@ require ( go.uber.org/automaxprocs v1.6.0 go.uber.org/goleak v1.3.0 go.uber.org/zap v1.27.0 - golang.org/x/sys v0.29.0 ) require ( - github.com/cilium/ebpf v0.16.0 // indirect - github.com/containerd/log v0.1.0 // indirect - github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect - github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect @@ -34,10 +28,9 @@ require ( github.com/knadh/koanf/v2 v2.1.2 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/opencontainers/runtime-spec v1.2.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.117.0 // indirect go.opentelemetry.io/collector/pdata v1.23.0 // indirect go.opentelemetry.io/otel v1.32.0 // indirect @@ -46,8 +39,8 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/net v0.33.0 // indirect + golang.org/x/sys v0.29.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect google.golang.org/grpc v1.69.2 // indirect diff --git a/extension/cgroupruntimeextension/go.sum b/extension/cgroupruntimeextension/go.sum index 0469c8ea2373..e5b3fa147065 100644 --- a/extension/cgroupruntimeextension/go.sum +++ b/extension/cgroupruntimeextension/go.sum @@ -1,14 +1,5 @@ github.com/KimMachineGun/automemlimit v0.7.0 h1:7G06p/dMSf7G8E6oq+f2uOPuVncFyIlDI/pBWK49u88= github.com/KimMachineGun/automemlimit v0.7.0/go.mod h1:QZxpHaGOQoYvFhv/r4u3U0JTC2ZcOwbSr11UZF46UBM= -github.com/cilium/ebpf v0.16.0 h1:+BiEnHL6Z7lXnlGUsXQPPAE7+kenAd4ES8MQ5min0Ok= -github.com/cilium/ebpf v0.16.0/go.mod h1:L7u2Blt2jMM/vLAVgjxluxtBKlz3/GWjB0dMOEngfwE= -github.com/containerd/cgroups/v3 v3.0.5 h1:44na7Ud+VwyE7LIoJ8JTNQOa549a8543BmzaJHo6Bzo= -github.com/containerd/cgroups/v3 v3.0.5/go.mod h1:SA5DLYnXO8pTGYiAHXz94qvLQTKfVM5GEVisn4jpins= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -16,13 +7,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= -github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= -github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= @@ -31,10 +17,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA= -github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= -github.com/jsimonetti/rtnetlink/v2 v2.0.1 h1:xda7qaHDSVOsADNouv7ukSuicKZO7GgVUCXxpaIEIlM= -github.com/jsimonetti/rtnetlink/v2 v2.0.1/go.mod h1:7MoNYNbb3UaDHtF8udiJo/RH6VsTKP1pqKLUTVCvToE= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= @@ -47,16 +29,10 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g= -github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw= -github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U= -github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= -github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -67,10 +43,6 @@ github.com/rdforte/gomaxecs v1.1.0 h1:fpDkJtuBRtRQjcxAKdARjwjYzxlmmGkSmcqzF0UKuO github.com/rdforte/gomaxecs v1.1.0/go.mod h1:8agrawOmcvb+oBa6EnV2oADDtnDtkVx1Q0H/Ht7GiFc= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -110,8 +82,6 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo= -golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak= 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/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -123,12 +93,9 @@ golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= 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.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.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-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -152,6 +119,5 @@ google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojt gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/extension/cgroupruntimeextension/integration_test.go b/extension/cgroupruntimeextension/integration_test.go deleted file mode 100644 index 29032012a295..000000000000 --- a/extension/cgroupruntimeextension/integration_test.go +++ /dev/null @@ -1,406 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 -//go:build integration && linux -// +build integration,linux - -// Privileged access is required to set cgroup's memory and cpu max values - -package cgroupruntimeextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/cgroupruntimeextension" - -import ( - "context" - "fmt" - "math" - "net/http" - "net/http/httptest" - "os" - "path" - "path/filepath" - "runtime" - "runtime/debug" - "strconv" - "strings" - "testing" - - "github.com/containerd/cgroups/v3/cgroup2" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" - "go.opentelemetry.io/collector/extension/extensiontest" - "golang.org/x/sys/unix" -) - -const ( - defaultCgroup2Path = "/sys/fs/cgroup" - ecsMetadataURI = "ECS_CONTAINER_METADATA_URI_V4" -) - -// checkCgroupSystem skips the test if is not run in a cgroupv2 system -func checkCgroupSystem(tb testing.TB) { - var st unix.Statfs_t - err := unix.Statfs(defaultCgroup2Path, &st) - if err != nil { - tb.Skip("cannot statfs cgroup root") - } - - isUnified := st.Type == unix.CGROUP2_SUPER_MAGIC - if !isUnified { - tb.Skip("System running in hybrid or cgroupv1 mode") - } -} - -func pointerInt64(val int64) *int64 { - return &val -} - -func pointerUint64(uval uint64) *uint64 { - return &uval -} - -// setupMemoryCgroupCleanUp returns a cleanup function that restores the cgroup's max memory to its initial value -func setupMemoryCgroupCleanUp(t *testing.T, manager *cgroup2.Manager, cgroupPath string) func() { - stats, err := manager.Stat() - require.NoError(t, err) - - initialMaxMemory := stats.GetMemory().GetUsageLimit() - memoryCgroupCleanUp := func() { - err = manager.Update(&cgroup2.Resources{ - Memory: &cgroup2.Memory{ - Max: pointerInt64(int64(initialMaxMemory)), - }, - }) - assert.NoError(t, err) - } - - if initialMaxMemory == math.MaxUint64 { - // fallback solution to set cgroup's max memory to "max" - memoryCgroupCleanUp = func() { - err = os.WriteFile(path.Join(defaultCgroup2Path, cgroupPath, "memory.max"), []byte("max"), 0o600) - assert.NoError(t, err) - } - } - return memoryCgroupCleanUp -} - -// cgroupMaxCpu returns the CPU max definition for a given cgroup slice path -// File format: cpu_quote cpu_period -func cgroupMaxCPU(filename string) (quota int64, period uint64, err error) { - out, err := os.ReadFile(filepath.Join(defaultCgroup2Path, filename, "cpu.max")) - if err != nil { - return 0, 0, err - } - values := strings.Split(strings.TrimSpace(string(out)), " ") - if values[0] == "max" { - quota = math.MaxInt64 - } else { - quota, _ = strconv.ParseInt(values[0], 10, 64) - } - period, _ = strconv.ParseUint(values[1], 10, 64) - return quota, period, err -} - -// startExtension starts the extension with the given config -func startExtension(t *testing.T, config *Config) { - factory := NewFactory() - ctx := context.Background() - extension, err := factory.Create(ctx, extensiontest.NewNopSettings(), config) - require.NoError(t, err) - - err = extension.Start(ctx, componenttest.NewNopHost()) - require.NoError(t, err) -} - -func TestCgroupV2SudoIntegration(t *testing.T) { - checkCgroupSystem(t) - - tests := []struct { - name string - // nil CPU quota == "max" cgroup string value - cgroupCPUQuota *int64 - cgroupCPUPeriod uint64 - cgroupMaxMemory int64 - config *Config - expectedGoMaxProcs int - expectedGoMemLimit int64 - }{ - { - name: "90% the max cgroup memory and 12 GOMAXPROCS", - cgroupCPUQuota: pointerInt64(100000), - cgroupCPUPeriod: 8000, - // 128 Mb - cgroupMaxMemory: 134217728, - config: &Config{ - GoMaxProcs: GoMaxProcsConfig{ - Enabled: true, - }, - GoMemLimit: GoMemLimitConfig{ - Enabled: true, - Ratio: 0.9, - }, - }, - // 100000 / 8000 - expectedGoMaxProcs: 12, - // 134217728 * 0.9 - expectedGoMemLimit: 120795955, - }, - { - name: "50% of the max cgroup memory and 1 GOMAXPROCS", - cgroupCPUQuota: pointerInt64(100000), - cgroupCPUPeriod: 100000, - // 128 Mb - cgroupMaxMemory: 134217728, - config: &Config{ - GoMaxProcs: GoMaxProcsConfig{ - Enabled: true, - }, - GoMemLimit: GoMemLimitConfig{ - Enabled: true, - Ratio: 0.5, - }, - }, - // 100000 / 100000 - expectedGoMaxProcs: 1, - // 134217728 * 0.5 - expectedGoMemLimit: 67108864, - }, - { - name: "10% of the max cgroup memory, max cpu, default GOMAXPROCS", - cgroupCPUQuota: nil, - cgroupCPUPeriod: 100000, - // 128 Mb - cgroupMaxMemory: 134217728, - config: &Config{ - GoMaxProcs: GoMaxProcsConfig{ - Enabled: true, - }, - GoMemLimit: GoMemLimitConfig{ - Enabled: true, - Ratio: 0.1, - }, - }, - // GOMAXPROCS is set to the value of `cpu.max / cpu.period` - // If cpu.max is set to max, GOMAXPROCS should not be - // modified - expectedGoMaxProcs: runtime.GOMAXPROCS(-1), - // 134217728 * 0.1 - expectedGoMemLimit: 13421772, - }, - } - - cgroupPath, err := cgroup2.PidGroupPath(os.Getpid()) - assert.NoError(t, err) - manager, err := cgroup2.Load(cgroupPath) - assert.NoError(t, err) - - // Startup resource values - memoryCgroupCleanUp := setupMemoryCgroupCleanUp(t, manager, cgroupPath) - - initialCPUQuota, initialCPUPeriod, err := cgroupMaxCPU(cgroupPath) - require.NoError(t, err) - cpuCgroupCleanUp := func() { - fmt.Println(initialCPUQuota) - err = manager.Update(&cgroup2.Resources{ - CPU: &cgroup2.CPU{ - Max: cgroup2.NewCPUMax(pointerInt64(initialCPUQuota), pointerUint64(initialCPUPeriod)), - }, - }) - assert.NoError(t, err) - } - - if initialCPUQuota == math.MaxInt64 { - // fallback solution to set cgroup's max cpu to "max" - cpuCgroupCleanUp = func() { - err = os.WriteFile(path.Join(defaultCgroup2Path, cgroupPath, "cpu.max"), []byte("max"), 0o600) - assert.NoError(t, err) - } - } - - initialGoMem := debug.SetMemoryLimit(-1) - initialGoProcs := runtime.GOMAXPROCS(-1) - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - // restore startup cgroup initial resource values - t.Cleanup(func() { - debug.SetMemoryLimit(initialGoMem) - runtime.GOMAXPROCS(initialGoProcs) - memoryCgroupCleanUp() - cpuCgroupCleanUp() - }) - - err = manager.Update(&cgroup2.Resources{ - Memory: &cgroup2.Memory{ - // Default max memory must be - // overwritten - // to automemlimit change the GOMEMLIMIT - // value - Max: pointerInt64(test.cgroupMaxMemory), - }, - CPU: &cgroup2.CPU{ - Max: cgroup2.NewCPUMax(test.cgroupCPUQuota, pointerUint64(test.cgroupCPUPeriod)), - }, - }) - require.NoError(t, err) - - startExtension(t, test.config) - - assert.Equal(t, test.expectedGoMaxProcs, runtime.GOMAXPROCS(-1)) - assert.Equal(t, test.expectedGoMemLimit, debug.SetMemoryLimit(-1)) - }) - } -} - -func testServerECSMetadata(t *testing.T, containerCPU, taskCPU int) *httptest.Server { - t.Helper() - - mux := http.NewServeMux() - mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { - _, err := w.Write([]byte(fmt.Sprintf(`{"Limits":{"CPU":%d},"DockerId":"container-id"}`, containerCPU))) - assert.NoError(t, err) - }) - mux.HandleFunc("/task", func(w http.ResponseWriter, _ *http.Request) { - _, err := w.Write([]byte(fmt.Sprintf( - `{"Containers":[{"DockerId":"container-id","Limits":{"CPU":%d}}],"Limits":{"CPU":%d}}`, - containerCPU, - taskCPU, - ))) - assert.NoError(t, err) - }) - - return httptest.NewServer(mux) -} - -func TestECSCgroupV2SudoIntegration(t *testing.T) { - checkCgroupSystem(t) - - tests := []struct { - name string - containerCPU int - taskCPU int - cgroupMaxMemory int64 - config *Config - expectedGoMaxProcs int - expectedGoMemLimit int64 - }{ - { - name: "90% the max cgroup memory and 4 GOMAXPROCS w/ 4096 container cpu 16 task cpu", - containerCPU: 4096, - taskCPU: 16, - // 128 Mb - cgroupMaxMemory: 134217728, - config: &Config{ - GoMaxProcs: GoMaxProcsConfig{ - Enabled: true, - }, - GoMemLimit: GoMemLimitConfig{ - Enabled: true, - Ratio: 0.9, - }, - }, - expectedGoMaxProcs: 4, - // 134217728 * 0.9 - expectedGoMemLimit: 120795955, - }, - { - name: "50% of the max cgroup memory and 1 GOMAXPROCS w/ 2048 container cpu 2 task cpu", - containerCPU: 2048, - taskCPU: 2, - // 128 Mb - cgroupMaxMemory: 134217728, - config: &Config{ - GoMaxProcs: GoMaxProcsConfig{ - Enabled: true, - }, - GoMemLimit: GoMemLimitConfig{ - Enabled: true, - Ratio: 0.5, - }, - }, - expectedGoMaxProcs: 2, - // 134217728 * 0.5 - expectedGoMemLimit: 67108864, - }, - { - name: "50% of the max cgroup memory and 1 GOMAXPROCS w/ 1024 container cpu 4 task cpu", - containerCPU: 1024, - taskCPU: 4, - // 128 Mb - cgroupMaxMemory: 134217728, - config: &Config{ - GoMaxProcs: GoMaxProcsConfig{ - Enabled: true, - }, - GoMemLimit: GoMemLimitConfig{ - Enabled: true, - Ratio: 0.5, - }, - }, - expectedGoMaxProcs: 1, - // 134217728 * 0.5 - expectedGoMemLimit: 67108864, - }, - { - name: "10% of the max cgroup memory and 4 GOMAXPROCS w/ 4096 container cpu 0 task cpu", - containerCPU: 4096, - taskCPU: 0, - // 128 Mb - cgroupMaxMemory: 134217728, - config: &Config{ - GoMaxProcs: GoMaxProcsConfig{ - Enabled: true, - }, - GoMemLimit: GoMemLimitConfig{ - Enabled: true, - Ratio: 0.1, - }, - }, - expectedGoMaxProcs: 4, - // 134217728 * 0.1 - expectedGoMemLimit: 13421772, - }, - } - - cgroupPath, err := cgroup2.PidGroupPath(os.Getpid()) - assert.NoError(t, err) - manager, err := cgroup2.Load(cgroupPath) - assert.NoError(t, err) - - // Startup resource values - memoryCgroupCleanUp := setupMemoryCgroupCleanUp(t, manager, cgroupPath) - - initialGoMem := debug.SetMemoryLimit(-1) - initialGoProcs := runtime.GOMAXPROCS(-1) - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - // running in ECS environment, set the ECS metedata URI environment variable - // to get the Cgroup CPU quota from the httptest server - server := testServerECSMetadata(t, test.containerCPU, test.taskCPU) - t.Setenv(ecsMetadataURI, server.URL) - // restore startup cgroup initial resource values - t.Cleanup(func() { - debug.SetMemoryLimit(initialGoMem) - runtime.GOMAXPROCS(initialGoProcs) - memoryCgroupCleanUp() - server.Close() - os.Unsetenv(ecsMetadataURI) - }) - - err = manager.Update(&cgroup2.Resources{ - Memory: &cgroup2.Memory{ - // Default max memory must be - // overwritten - // to automemlimit change the GOMEMLIMIT - // value - Max: pointerInt64(test.cgroupMaxMemory), - }, - }) - require.NoError(t, err) - - startExtension(t, test.config) - - assert.Equal(t, test.expectedGoMaxProcs, runtime.GOMAXPROCS(-1)) - assert.Equal(t, test.expectedGoMemLimit, debug.SetMemoryLimit(-1)) - }) - } -}