From a293e1fa0ef9ddba94a9a961a39cb82adcf0139a Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 6 Aug 2024 14:07:54 +0100 Subject: [PATCH 01/49] updating performance test to 1s --- test/testdata/configs/nginx-agent.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testdata/configs/nginx-agent.conf b/test/testdata/configs/nginx-agent.conf index 3f68fab64f..a58429c47a 100644 --- a/test/testdata/configs/nginx-agent.conf +++ b/test/testdata/configs/nginx-agent.conf @@ -14,4 +14,4 @@ dataplane: poll_interval: 30s metrics: bulk_size: 20 - poll_interval: 5s + poll_interval: 1s From 7d052b572ab6d0c9a3213f7355beb8a7b6d0b6ad Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 6 Aug 2024 14:53:00 +0100 Subject: [PATCH 02/49] reopen file leak detected --- go.mod | 1 + go.sum | 2 + src/core/metrics/collectors/leak_test.go | 10 + src/core/metrics/sources/leak_test.go | 10 + .../metrics/sources/nginx_access_log_test.go | 10 +- .../metrics/sources/nginx_error_log_test.go | 7 +- src/core/tailer/tailer.go | 2 +- test/integration/go.sum | 4 +- test/performance/go.sum | 2 + .../nginx/agent/v2/src/core/tailer/tailer.go | 2 +- vendor/go.uber.org/goleak/.gitignore | 5 + vendor/go.uber.org/goleak/.golangci.yml | 28 ++ vendor/go.uber.org/goleak/CHANGELOG.md | 74 +++++ vendor/go.uber.org/goleak/LICENSE | 21 ++ vendor/go.uber.org/goleak/Makefile | 45 +++ vendor/go.uber.org/goleak/README.md | 74 +++++ vendor/go.uber.org/goleak/doc.go | 22 ++ .../go.uber.org/goleak/internal/stack/doc.go | 22 ++ .../go.uber.org/goleak/internal/stack/scan.go | 56 ++++ .../goleak/internal/stack/stacks.go | 298 ++++++++++++++++++ vendor/go.uber.org/goleak/leaks.go | 108 +++++++ vendor/go.uber.org/goleak/options.go | 198 ++++++++++++ vendor/go.uber.org/goleak/testmain.go | 69 ++++ vendor/go.uber.org/goleak/tracestack_new.go | 30 ++ vendor/modules.txt | 4 + 25 files changed, 1096 insertions(+), 8 deletions(-) create mode 100644 src/core/metrics/collectors/leak_test.go create mode 100644 src/core/metrics/sources/leak_test.go create mode 100644 vendor/go.uber.org/goleak/.gitignore create mode 100644 vendor/go.uber.org/goleak/.golangci.yml create mode 100644 vendor/go.uber.org/goleak/CHANGELOG.md create mode 100644 vendor/go.uber.org/goleak/LICENSE create mode 100644 vendor/go.uber.org/goleak/Makefile create mode 100644 vendor/go.uber.org/goleak/README.md create mode 100644 vendor/go.uber.org/goleak/doc.go create mode 100644 vendor/go.uber.org/goleak/internal/stack/doc.go create mode 100644 vendor/go.uber.org/goleak/internal/stack/scan.go create mode 100644 vendor/go.uber.org/goleak/internal/stack/stacks.go create mode 100644 vendor/go.uber.org/goleak/leaks.go create mode 100644 vendor/go.uber.org/goleak/options.go create mode 100644 vendor/go.uber.org/goleak/testmain.go create mode 100644 vendor/go.uber.org/goleak/tracestack_new.go diff --git a/go.mod b/go.mod index d27d605dd3..7ec7455407 100644 --- a/go.mod +++ b/go.mod @@ -40,6 +40,7 @@ require ( github.com/nginx/agent/sdk/v2 v2.30.3 github.com/prometheus/client_golang v1.19.1 github.com/rs/cors v1.11.0 + go.uber.org/goleak v1.3.0 go.uber.org/mock v0.4.0 golang.org/x/sys v0.22.0 golang.org/x/text v0.16.0 diff --git a/go.sum b/go.sum index ee16c71866..c2bdf05e17 100644 --- a/go.sum +++ b/go.sum @@ -180,6 +180,8 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/src/core/metrics/collectors/leak_test.go b/src/core/metrics/collectors/leak_test.go new file mode 100644 index 0000000000..6e69910376 --- /dev/null +++ b/src/core/metrics/collectors/leak_test.go @@ -0,0 +1,10 @@ +package collectors + +import ( + "testing" + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} \ No newline at end of file diff --git a/src/core/metrics/sources/leak_test.go b/src/core/metrics/sources/leak_test.go new file mode 100644 index 0000000000..a63efbbd5b --- /dev/null +++ b/src/core/metrics/sources/leak_test.go @@ -0,0 +1,10 @@ +package sources + +import ( + "testing" + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} \ No newline at end of file diff --git a/src/core/metrics/sources/nginx_access_log_test.go b/src/core/metrics/sources/nginx_access_log_test.go index 7ddc72a894..d1601c2149 100644 --- a/src/core/metrics/sources/nginx_access_log_test.go +++ b/src/core/metrics/sources/nginx_access_log_test.go @@ -743,6 +743,7 @@ func TestAccessLogStats(t *testing.T) { logFormat string logLines []string expectedStats *proto.StatsEntity + timeout time.Duration }{ { "default_access_log_test", @@ -771,6 +772,7 @@ func TestAccessLogStats(t *testing.T) { }, }, }, + time.Minute, }, { "invalid_access_log", @@ -803,6 +805,7 @@ func TestAccessLogStats(t *testing.T) { }, }, }, + time.Second, }, { "full_access_log_test", @@ -1047,6 +1050,7 @@ func TestAccessLogStats(t *testing.T) { }, }, }, + time.Second, }, { "custom_access_log_test", @@ -1075,6 +1079,7 @@ func TestAccessLogStats(t *testing.T) { }, }, }, + time.Second, }, } @@ -1085,9 +1090,10 @@ func TestAccessLogStats(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { accessLogFile, _ := os.CreateTemp(os.TempDir(), "access.log") - + ctx, cncl := context.WithTimeout(context.Background(), test.timeout) + defer cncl() nginxAccessLog := NewNginxAccessLog(&metrics.CommonDim{}, OSSNamespace, binary, OSSNginxType, collectionDuration) - go nginxAccessLog.logStats(context.TODO(), accessLogFile.Name(), test.logFormat) + go nginxAccessLog.logStats(ctx, accessLogFile.Name(), test.logFormat) time.Sleep(sleepDuration) diff --git a/src/core/metrics/sources/nginx_error_log_test.go b/src/core/metrics/sources/nginx_error_log_test.go index 0141c30a80..1fe8f022a2 100644 --- a/src/core/metrics/sources/nginx_error_log_test.go +++ b/src/core/metrics/sources/nginx_error_log_test.go @@ -73,6 +73,7 @@ func TestErrorLogStats(t *testing.T) { name string logLines []string expectedStats *proto.StatsEntity + timeout time.Duration }{ { "default_error_log_test", @@ -103,6 +104,7 @@ func TestErrorLogStats(t *testing.T) { }, }, }, + time.Second, }, } @@ -113,9 +115,10 @@ func TestErrorLogStats(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { errorLogFile, _ := os.CreateTemp(os.TempDir(), "error.log") - + ctx, cncl := context.WithTimeout(context.Background(), test.timeout) + defer cncl() nginxErrorLog := NewNginxErrorLog(&metrics.CommonDim{}, OSSNamespace, binary, OSSNginxType, collectionDuration) - go nginxErrorLog.logStats(context.TODO(), errorLogFile.Name()) + go nginxErrorLog.logStats(ctx, errorLogFile.Name()) time.Sleep(sleepDuration) diff --git a/src/core/tailer/tailer.go b/src/core/tailer/tailer.go index 67b3074934..ab9f0e1768 100644 --- a/src/core/tailer/tailer.go +++ b/src/core/tailer/tailer.go @@ -20,7 +20,7 @@ import ( var tailConfig = tail.Config{ Follow: true, - ReOpen: true, + ReOpen: false, MustExist: true, Poll: true, Location: &tail.SeekInfo{ diff --git a/test/integration/go.sum b/test/integration/go.sum index d46b7873ce..ad1188a24f 100644 --- a/test/integration/go.sum +++ b/test/integration/go.sum @@ -600,8 +600,8 @@ go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lI go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/test/performance/go.sum b/test/performance/go.sum index 91dbd3920d..f781ad5759 100644 --- a/test/performance/go.sum +++ b/test/performance/go.sum @@ -201,6 +201,8 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go index 67b3074934..ab9f0e1768 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go @@ -20,7 +20,7 @@ import ( var tailConfig = tail.Config{ Follow: true, - ReOpen: true, + ReOpen: false, MustExist: true, Poll: true, Location: &tail.SeekInfo{ diff --git a/vendor/go.uber.org/goleak/.gitignore b/vendor/go.uber.org/goleak/.gitignore new file mode 100644 index 0000000000..0fff519a4a --- /dev/null +++ b/vendor/go.uber.org/goleak/.gitignore @@ -0,0 +1,5 @@ +vendor/ +/bin +/lint.log +/cover.out +/cover.html diff --git a/vendor/go.uber.org/goleak/.golangci.yml b/vendor/go.uber.org/goleak/.golangci.yml new file mode 100644 index 0000000000..f84e6da8bc --- /dev/null +++ b/vendor/go.uber.org/goleak/.golangci.yml @@ -0,0 +1,28 @@ +output: + # Make output more digestible with quickfix in vim/emacs/etc. + sort-results: true + print-issued-lines: false + +linters: + enable: + - gofumpt + - nolintlint + - revive + +linters-settings: + govet: + # These govet checks are disabled by default, but they're useful. + enable: + - niliness + - reflectvaluecompare + - sortslice + - unusedwrite + +issues: + # Print all issues reported by all linters. + max-issues-per-linter: 0 + max-same-issues: 0 + + # Don't ignore some of the issues that golangci-lint considers okay. + # This includes documenting all exported entities. + exclude-use-default: false diff --git a/vendor/go.uber.org/goleak/CHANGELOG.md b/vendor/go.uber.org/goleak/CHANGELOG.md new file mode 100644 index 0000000000..5cd3f88a58 --- /dev/null +++ b/vendor/go.uber.org/goleak/CHANGELOG.md @@ -0,0 +1,74 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [1.3.0] +### Fixed +- Built-in ignores now match function names more accurately. + They will no longer ignore stacks because of file names + that look similar to function names. (#112) +### Added +- Add an `IgnoreAnyFunction` option to ignore stack traces + that have the provided function anywhere in the stack. (#113) +- Ignore `testing.runFuzzing` and `testing.runFuzzTests` alongside + other already-ignored test functions (`testing.RunTests`, etc). (#105) +### Changed +- Miscellaneous CI-related fixes. (#103, #108, #114) + +[1.3.0]: https://github.com/uber-go/goleak/compare/v1.2.1...v1.3.0 + +## [1.2.1] +### Changed +- Drop golang/x/lint dependency. + +[1.2.1]: https://github.com/uber-go/goleak/compare/v1.2.0...v1.2.1 + +## [1.2.0] +### Added +- Add Cleanup option that can be used for registering cleanup callbacks. (#78) + +### Changed +- Mark VerifyNone as a test helper. (#75) + +Thanks to @tallclair for their contribution to this release. + +[1.2.0]: https://github.com/uber-go/goleak/compare/v1.1.12...v1.2.0 + +## [1.1.12] +### Fixed +- Fixed logic for ignoring trace related goroutines on Go versions 1.16 and above. + +[1.1.12]: https://github.com/uber-go/goleak/compare/v1.1.11...v1.1.12 + +## [1.1.11] +### Fixed +- Documentation fix on how to test. +- Update dependency on stretchr/testify to v1.7.0. (#59) +- Update dependency on golang.org/x/tools to address CVE-2020-14040. (#62) + +[1.1.11]: https://github.com/uber-go/goleak/compare/v1.1.10...v1.1.11 + +## [1.1.10] +### Added +- [#49]: Add option to ignore current goroutines, which checks for any additional leaks and allows for incremental adoption of goleak in larger projects. + +Thanks to @denis-tingajkin for their contributions to this release. + +[#49]: https://github.com/uber-go/goleak/pull/49 +[1.1.10]: https://github.com/uber-go/goleak/compare/v1.0.0...v1.1.10 + +## [1.0.0] +### Changed +- Migrate to Go modules. + +### Fixed +- Ignore trace related goroutines that cause false positives with -trace. + +[1.0.0]: https://github.com/uber-go/goleak/compare/v0.10.0...v1.0.0 + +## [0.10.0] +- Initial release. + +[0.10.0]: https://github.com/uber-go/goleak/compare/v0.10.0...HEAD diff --git a/vendor/go.uber.org/goleak/LICENSE b/vendor/go.uber.org/goleak/LICENSE new file mode 100644 index 0000000000..6c9bde216e --- /dev/null +++ b/vendor/go.uber.org/goleak/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/go.uber.org/goleak/Makefile b/vendor/go.uber.org/goleak/Makefile new file mode 100644 index 0000000000..eb7154af3a --- /dev/null +++ b/vendor/go.uber.org/goleak/Makefile @@ -0,0 +1,45 @@ +# Directory containing the Makefile. +PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + +export GOBIN = $(PROJECT_ROOT)/bin +export PATH := $(GOBIN):$(PATH) + +GO_FILES = $(shell find . \ + -path '*/.*' -prune -o \ + '(' -type f -a -name '*.go' ')' -print) + +# Additional test flags. +TEST_FLAGS ?= + +.PHONY: all +all: lint build test + +.PHONY: lint +lint: golangci-lint tidy-lint + +.PHONY: build +build: + go build ./... + +.PHONY: test +test: + go test -v -race ./... + go test -v -trace=/dev/null . + +.PHONY: cover +cover: + go test -race -coverprofile=cover.out -coverpkg=./... ./... + go tool cover -html=cover.out -o cover.html + +.PHONY: golangci-lint +golangci-lint: + golangci-lint run + +.PHONY: tidy +tidy: + go mod tidy + +.PHONY: tidy-lint +tidy-lint: + go mod tidy + git diff --exit-code -- go.mod go.sum diff --git a/vendor/go.uber.org/goleak/README.md b/vendor/go.uber.org/goleak/README.md new file mode 100644 index 0000000000..de3d7d51df --- /dev/null +++ b/vendor/go.uber.org/goleak/README.md @@ -0,0 +1,74 @@ +# goleak [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] + +Goroutine leak detector to help avoid Goroutine leaks. + +## Installation + +You can use `go get` to get the latest version: + +`go get -u go.uber.org/goleak` + +`goleak` also supports semver releases. + +Note that go-leak only [supports][release] the two most recent minor versions of Go. + +## Quick Start + +To verify that there are no unexpected goroutines running at the end of a test: + +```go +func TestA(t *testing.T) { + defer goleak.VerifyNone(t) + + // test logic here. +} +``` + +Instead of checking for leaks at the end of every test, `goleak` can also be run +at the end of every test package by creating a `TestMain` function for your +package: + +```go +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} +``` + +## Determine Source of Package Leaks + +When verifying leaks using `TestMain`, the leak test is only run once after all tests +have been run. This is typically enough to ensure there's no goroutines leaked from +tests, but when there are leaks, it's hard to determine which test is causing them. + +You can use the following bash script to determine the source of the failing test: + +```sh +# Create a test binary which will be used to run each test individually +$ go test -c -o tests + +# Run each test individually, printing "." for successful tests, or the test name +# for failing tests. +$ for test in $(go test -list . | grep -E "^(Test|Example)"); do ./tests -test.run "^$test\$" &>/dev/null && echo -n "." || echo -e "\n$test failed"; done +``` + +This will only print names of failing tests which can be investigated individually. E.g., + +``` +..... +TestLeakyTest failed +....... +``` + +## Stability + +goleak is v1 and follows [SemVer](http://semver.org/) strictly. + +No breaking changes will be made to exported APIs before 2.0. + +[doc-img]: https://godoc.org/go.uber.org/goleak?status.svg +[doc]: https://godoc.org/go.uber.org/goleak +[ci-img]: https://github.com/uber-go/goleak/actions/workflows/ci.yml/badge.svg +[ci]: https://github.com/uber-go/goleak/actions/workflows/ci.yml +[cov-img]: https://codecov.io/gh/uber-go/goleak/branch/master/graph/badge.svg +[cov]: https://codecov.io/gh/uber-go/goleak +[release]: https://go.dev/doc/devel/release#policy diff --git a/vendor/go.uber.org/goleak/doc.go b/vendor/go.uber.org/goleak/doc.go new file mode 100644 index 0000000000..3832f8dbc5 --- /dev/null +++ b/vendor/go.uber.org/goleak/doc.go @@ -0,0 +1,22 @@ +// Copyright (c) 2018 Uber Technologies, Inc. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// Package goleak is a Goroutine leak detector. +package goleak // import "go.uber.org/goleak" diff --git a/vendor/go.uber.org/goleak/internal/stack/doc.go b/vendor/go.uber.org/goleak/internal/stack/doc.go new file mode 100644 index 0000000000..9179a56549 --- /dev/null +++ b/vendor/go.uber.org/goleak/internal/stack/doc.go @@ -0,0 +1,22 @@ +// Copyright (c) 2017-2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// Package stack is used for parsing stacks from `runtime.Stack`. +package stack diff --git a/vendor/go.uber.org/goleak/internal/stack/scan.go b/vendor/go.uber.org/goleak/internal/stack/scan.go new file mode 100644 index 0000000000..4b7ac8423e --- /dev/null +++ b/vendor/go.uber.org/goleak/internal/stack/scan.go @@ -0,0 +1,56 @@ +// Copyright (c) 2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package stack + +import ( + "bufio" + "io" +) + +// scanner provides a bufio.Scanner the ability to Unscan, +// which allows the current token to be read again +// after the next Scan. +type scanner struct { + *bufio.Scanner + + unscanned bool +} + +func newScanner(r io.Reader) *scanner { + return &scanner{Scanner: bufio.NewScanner(r)} +} + +func (s *scanner) Scan() bool { + if s.unscanned { + s.unscanned = false + return true + } + return s.Scanner.Scan() +} + +// Unscan stops the scanner from advancing its position +// for the next Scan. +// +// Bytes and Text will return the same token after next Scan +// that they do right now. +func (s *scanner) Unscan() { + s.unscanned = true +} diff --git a/vendor/go.uber.org/goleak/internal/stack/stacks.go b/vendor/go.uber.org/goleak/internal/stack/stacks.go new file mode 100644 index 0000000000..241a9b8448 --- /dev/null +++ b/vendor/go.uber.org/goleak/internal/stack/stacks.go @@ -0,0 +1,298 @@ +// Copyright (c) 2017-2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package stack + +import ( + "bytes" + "errors" + "fmt" + "io" + "runtime" + "strconv" + "strings" +) + +const _defaultBufferSize = 64 * 1024 // 64 KiB + +// Stack represents a single Goroutine's stack. +type Stack struct { + id int + state string // e.g. 'running', 'chan receive' + + // The first function on the stack. + firstFunction string + + // A set of all functions in the stack, + allFunctions map[string]struct{} + + // Full, raw stack trace. + fullStack string +} + +// ID returns the goroutine ID. +func (s Stack) ID() int { + return s.id +} + +// State returns the Goroutine's state. +func (s Stack) State() string { + return s.state +} + +// Full returns the full stack trace for this goroutine. +func (s Stack) Full() string { + return s.fullStack +} + +// FirstFunction returns the name of the first function on the stack. +func (s Stack) FirstFunction() string { + return s.firstFunction +} + +// HasFunction reports whether the stack has the given function +// anywhere in it. +func (s Stack) HasFunction(name string) bool { + _, ok := s.allFunctions[name] + return ok +} + +func (s Stack) String() string { + return fmt.Sprintf( + "Goroutine %v in state %v, with %v on top of the stack:\n%s", + s.id, s.state, s.firstFunction, s.Full()) +} + +func getStacks(all bool) []Stack { + trace := getStackBuffer(all) + stacks, err := newStackParser(bytes.NewReader(trace)).Parse() + if err != nil { + // Well-formed stack traces should never fail to parse. + // If they do, it's a bug in this package. + // Panic so we can fix it. + panic(fmt.Sprintf("Failed to parse stack trace: %v\n%s", err, trace)) + } + return stacks +} + +type stackParser struct { + scan *scanner + stacks []Stack + errors []error +} + +func newStackParser(r io.Reader) *stackParser { + return &stackParser{ + scan: newScanner(r), + } +} + +func (p *stackParser) Parse() ([]Stack, error) { + for p.scan.Scan() { + line := p.scan.Text() + + // If we see the goroutine header, start a new stack. + if strings.HasPrefix(line, "goroutine ") { + stack, err := p.parseStack(line) + if err != nil { + p.errors = append(p.errors, err) + continue + } + p.stacks = append(p.stacks, stack) + } + } + + p.errors = append(p.errors, p.scan.Err()) + return p.stacks, errors.Join(p.errors...) +} + +// parseStack parses a single stack trace from the given scanner. +// line is the first line of the stack trace, which should look like: +// +// goroutine 123 [runnable]: +func (p *stackParser) parseStack(line string) (Stack, error) { + id, state, err := parseGoStackHeader(line) + if err != nil { + return Stack{}, fmt.Errorf("parse header: %w", err) + } + + // Read the rest of the stack trace. + var ( + firstFunction string + fullStack bytes.Buffer + ) + funcs := make(map[string]struct{}) + for p.scan.Scan() { + line := p.scan.Text() + if strings.HasPrefix(line, "goroutine ") { + // If we see the goroutine header, + // it's the end of this stack. + // Unscan so the next Scan sees the same line. + p.scan.Unscan() + break + } + + fullStack.WriteString(line) + fullStack.WriteByte('\n') // scanner trims the newline + + if len(line) == 0 { + // Empty line usually marks the end of the stack + // but we don't want to have to rely on that. + // Just skip it. + continue + } + + funcName, creator, err := parseFuncName(line) + if err != nil { + return Stack{}, fmt.Errorf("parse function: %w", err) + } + if !creator { + // A function is part of a goroutine's stack + // only if it's not a "created by" function. + // + // The creator function is part of a different stack. + // We don't care about it right now. + funcs[funcName] = struct{}{} + if firstFunction == "" { + firstFunction = funcName + } + + } + + // The function name followed by a line in the form: + // + // example.com/path/to/package/file.go:123 +0x123 + // + // We don't care about the position so we can skip this line. + if p.scan.Scan() { + // Be defensive: + // Skip the line only if it starts with a tab. + bs := p.scan.Bytes() + if len(bs) > 0 && bs[0] == '\t' { + fullStack.Write(bs) + fullStack.WriteByte('\n') + } else { + // Put it back and let the next iteration handle it + // if it doesn't start with a tab. + p.scan.Unscan() + } + } + + if creator { + // The "created by" line is the last line of the stack. + // We can stop parsing now. + // + // Note that if tracebackancestors=N is set, + // there may be more a traceback of the creator function + // following the "created by" line, + // but it should not be considered part of this stack. + // e.g., + // + // created by testing.(*T).Run in goroutine 1 + // /usr/lib/go/src/testing/testing.go:1648 +0x3ad + // [originating from goroutine 1]: + // testing.(*T).Run(...) + // /usr/lib/go/src/testing/testing.go:1649 +0x3ad + // + break + } + } + + return Stack{ + id: id, + state: state, + firstFunction: firstFunction, + allFunctions: funcs, + fullStack: fullStack.String(), + }, nil +} + +// All returns the stacks for all running goroutines. +func All() []Stack { + return getStacks(true) +} + +// Current returns the stack for the current goroutine. +func Current() Stack { + return getStacks(false)[0] +} + +func getStackBuffer(all bool) []byte { + for i := _defaultBufferSize; ; i *= 2 { + buf := make([]byte, i) + if n := runtime.Stack(buf, all); n < i { + return buf[:n] + } + } +} + +// Parses a single function from the given line. +// The line is in one of these formats: +// +// example.com/path/to/package.funcName(args...) +// example.com/path/to/package.(*typeName).funcName(args...) +// created by example.com/path/to/package.funcName +// created by example.com/path/to/package.funcName in goroutine [...] +// +// Also reports whether the line was a "created by" line. +func parseFuncName(line string) (name string, creator bool, err error) { + if after, ok := strings.CutPrefix(line, "created by "); ok { + // The function name is the part after "created by " + // and before " in goroutine [...]". + idx := strings.Index(after, " in goroutine") + if idx >= 0 { + after = after[:idx] + } + name = after + creator = true + } else if idx := strings.LastIndexByte(line, '('); idx >= 0 { + // The function name is the part before the last '('. + name = line[:idx] + } + + if name == "" { + return "", false, fmt.Errorf("no function found: %q", line) + } + + return name, creator, nil +} + +// parseGoStackHeader parses a stack header that looks like: +// goroutine 643 [runnable]:\n +// And returns the goroutine ID, and the state. +func parseGoStackHeader(line string) (goroutineID int, state string, err error) { + // The scanner will have already trimmed the "\n", + // but we'll guard against it just in case. + // + // Trimming them separately makes them both optional. + line = strings.TrimSuffix(strings.TrimSuffix(line, ":"), "\n") + parts := strings.SplitN(line, " ", 3) + if len(parts) != 3 { + return 0, "", fmt.Errorf("unexpected format: %q", line) + } + + id, err := strconv.Atoi(parts[1]) + if err != nil { + return 0, "", fmt.Errorf("bad goroutine ID %q in line %q", parts[1], line) + } + + state = strings.TrimSuffix(strings.TrimPrefix(parts[2], "["), "]") + return id, state, nil +} diff --git a/vendor/go.uber.org/goleak/leaks.go b/vendor/go.uber.org/goleak/leaks.go new file mode 100644 index 0000000000..cc206f1815 --- /dev/null +++ b/vendor/go.uber.org/goleak/leaks.go @@ -0,0 +1,108 @@ +// Copyright (c) 2017 Uber Technologies, Inc. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package goleak + +import ( + "errors" + "fmt" + + "go.uber.org/goleak/internal/stack" +) + +// TestingT is the minimal subset of testing.TB that we use. +type TestingT interface { + Error(...interface{}) +} + +// filterStacks will filter any stacks excluded by the given opts. +// filterStacks modifies the passed in stacks slice. +func filterStacks(stacks []stack.Stack, skipID int, opts *opts) []stack.Stack { + filtered := stacks[:0] + for _, stack := range stacks { + // Always skip the running goroutine. + if stack.ID() == skipID { + continue + } + // Run any default or user-specified filters. + if opts.filter(stack) { + continue + } + filtered = append(filtered, stack) + } + return filtered +} + +// Find looks for extra goroutines, and returns a descriptive error if +// any are found. +func Find(options ...Option) error { + cur := stack.Current().ID() + + opts := buildOpts(options...) + if opts.cleanup != nil { + return errors.New("Cleanup can only be passed to VerifyNone or VerifyTestMain") + } + var stacks []stack.Stack + retry := true + for i := 0; retry; i++ { + stacks = filterStacks(stack.All(), cur, opts) + + if len(stacks) == 0 { + return nil + } + retry = opts.retry(i) + } + + return fmt.Errorf("found unexpected goroutines:\n%s", stacks) +} + +type testHelper interface { + Helper() +} + +// VerifyNone marks the given TestingT as failed if any extra goroutines are +// found by Find. This is a helper method to make it easier to integrate in +// tests by doing: +// +// defer VerifyNone(t) +// +// VerifyNone is currently incompatible with t.Parallel because it cannot +// associate specific goroutines with specific tests. Thus, non-leaking +// goroutines from other tests running in parallel could fail this check. +// If you need to run tests in parallel, use [VerifyTestMain] instead, +// which will verify that no leaking goroutines exist after ALL tests finish. +func VerifyNone(t TestingT, options ...Option) { + opts := buildOpts(options...) + var cleanup func(int) + cleanup, opts.cleanup = opts.cleanup, nil + + if h, ok := t.(testHelper); ok { + // Mark this function as a test helper, if available. + h.Helper() + } + + if err := Find(opts); err != nil { + t.Error(err) + } + + if cleanup != nil { + cleanup(0) + } +} diff --git a/vendor/go.uber.org/goleak/options.go b/vendor/go.uber.org/goleak/options.go new file mode 100644 index 0000000000..53fc0a1dec --- /dev/null +++ b/vendor/go.uber.org/goleak/options.go @@ -0,0 +1,198 @@ +// Copyright (c) 2017-2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package goleak + +import ( + "strings" + "time" + + "go.uber.org/goleak/internal/stack" +) + +// Option lets users specify custom verifications. +type Option interface { + apply(*opts) +} + +// We retry up to 20 times if we can't find the goroutine that +// we are looking for. In between each attempt, we will sleep for +// a short while to let any running goroutines complete. +const _defaultRetries = 20 + +type opts struct { + filters []func(stack.Stack) bool + maxRetries int + maxSleep time.Duration + cleanup func(int) +} + +// implement apply so that opts struct itself can be used as +// an Option. +func (o *opts) apply(opts *opts) { + opts.filters = o.filters + opts.maxRetries = o.maxRetries + opts.maxSleep = o.maxSleep + opts.cleanup = o.cleanup +} + +// optionFunc lets us easily write options without a custom type. +type optionFunc func(*opts) + +func (f optionFunc) apply(opts *opts) { f(opts) } + +// IgnoreTopFunction ignores any goroutines where the specified function +// is at the top of the stack. The function name should be fully qualified, +// e.g., go.uber.org/goleak.IgnoreTopFunction +func IgnoreTopFunction(f string) Option { + return addFilter(func(s stack.Stack) bool { + return s.FirstFunction() == f + }) +} + +// IgnoreAnyFunction ignores goroutines where the specified function +// is present anywhere in the stack. +// +// The function name must be fully qualified, e.g., +// +// go.uber.org/goleak.IgnoreAnyFunction +// +// For methods, the fully qualified form looks like: +// +// go.uber.org/goleak.(*MyType).MyMethod +func IgnoreAnyFunction(f string) Option { + return addFilter(func(s stack.Stack) bool { + return s.HasFunction(f) + }) +} + +// Cleanup sets up a cleanup function that will be executed at the +// end of the leak check. +// When passed to [VerifyTestMain], the exit code passed to cleanupFunc +// will be set to the exit code of TestMain. +// When passed to [VerifyNone], the exit code will be set to 0. +// This cannot be passed to [Find]. +func Cleanup(cleanupFunc func(exitCode int)) Option { + return optionFunc(func(opts *opts) { + opts.cleanup = cleanupFunc + }) +} + +// IgnoreCurrent records all current goroutines when the option is created, and ignores +// them in any future Find/Verify calls. +func IgnoreCurrent() Option { + excludeIDSet := map[int]bool{} + for _, s := range stack.All() { + excludeIDSet[s.ID()] = true + } + return addFilter(func(s stack.Stack) bool { + return excludeIDSet[s.ID()] + }) +} + +func maxSleep(d time.Duration) Option { + return optionFunc(func(opts *opts) { + opts.maxSleep = d + }) +} + +func addFilter(f func(stack.Stack) bool) Option { + return optionFunc(func(opts *opts) { + opts.filters = append(opts.filters, f) + }) +} + +func buildOpts(options ...Option) *opts { + opts := &opts{ + maxRetries: _defaultRetries, + maxSleep: 100 * time.Millisecond, + } + opts.filters = append(opts.filters, + isTestStack, + isSyscallStack, + isStdLibStack, + isTraceStack, + ) + for _, option := range options { + option.apply(opts) + } + return opts +} + +func (o *opts) filter(s stack.Stack) bool { + for _, filter := range o.filters { + if filter(s) { + return true + } + } + return false +} + +func (o *opts) retry(i int) bool { + if i >= o.maxRetries { + return false + } + + d := time.Duration(int(time.Microsecond) << uint(i)) + if d > o.maxSleep { + d = o.maxSleep + } + time.Sleep(d) + return true +} + +// isTestStack is a default filter installed to automatically skip goroutines +// that the testing package runs while the user's tests are running. +func isTestStack(s stack.Stack) bool { + // Until go1.7, the main goroutine ran RunTests, which started + // the test in a separate goroutine and waited for that test goroutine + // to end by waiting on a channel. + // Since go1.7, a separate goroutine is started to wait for signals. + // T.Parallel is for parallel tests, which are blocked until all serial + // tests have run with T.Parallel at the top of the stack. + // testing.runFuzzTests is for fuzz testing, it's blocked until the test + // function with all seed corpus have run. + // testing.runFuzzing is for fuzz testing, it's blocked until a failing + // input is found. + switch s.FirstFunction() { + case "testing.RunTests", "testing.(*T).Run", "testing.(*T).Parallel", "testing.runFuzzing", "testing.runFuzzTests": + // In pre1.7 and post-1.7, background goroutines started by the testing + // package are blocked waiting on a channel. + return strings.HasPrefix(s.State(), "chan receive") + } + return false +} + +func isSyscallStack(s stack.Stack) bool { + // Typically runs in the background when code uses CGo: + // https://github.com/golang/go/issues/16714 + return s.HasFunction("runtime.goexit") && strings.HasPrefix(s.State(), "syscall") +} + +func isStdLibStack(s stack.Stack) bool { + // Importing os/signal starts a background goroutine. + // The name of the function at the top has changed between versions. + if f := s.FirstFunction(); f == "os/signal.signal_recv" || f == "os/signal.loop" { + return true + } + + // Using signal.Notify will start a runtime goroutine. + return s.HasFunction("runtime.ensureSigM") +} diff --git a/vendor/go.uber.org/goleak/testmain.go b/vendor/go.uber.org/goleak/testmain.go new file mode 100644 index 0000000000..7b1a50b7af --- /dev/null +++ b/vendor/go.uber.org/goleak/testmain.go @@ -0,0 +1,69 @@ +// Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package goleak + +import ( + "fmt" + "io" + "os" +) + +// Variables for stubbing in unit tests. +var ( + _osExit = os.Exit + _osStderr io.Writer = os.Stderr +) + +// TestingM is the minimal subset of testing.M that we use. +type TestingM interface { + Run() int +} + +// VerifyTestMain can be used in a TestMain function for package tests to +// verify that there were no goroutine leaks. +// To use it, your TestMain function should look like: +// +// func TestMain(m *testing.M) { +// goleak.VerifyTestMain(m) +// } +// +// See https://golang.org/pkg/testing/#hdr-Main for more details. +// +// This will run all tests as per normal, and if they were successful, look +// for any goroutine leaks and fail the tests if any leaks were found. +func VerifyTestMain(m TestingM, options ...Option) { + exitCode := m.Run() + opts := buildOpts(options...) + + var cleanup func(int) + cleanup, opts.cleanup = opts.cleanup, nil + if cleanup == nil { + cleanup = _osExit + } + defer func() { cleanup(exitCode) }() + + if exitCode == 0 { + if err := Find(opts); err != nil { + fmt.Fprintf(_osStderr, "goleak: Errors on successful test run: %v\n", err) + exitCode = 1 + } + } +} diff --git a/vendor/go.uber.org/goleak/tracestack_new.go b/vendor/go.uber.org/goleak/tracestack_new.go new file mode 100644 index 0000000000..4fc6cefcea --- /dev/null +++ b/vendor/go.uber.org/goleak/tracestack_new.go @@ -0,0 +1,30 @@ +// Copyright (c) 2021-2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +//go:build go1.16 +// +build go1.16 + +package goleak + +import "go.uber.org/goleak/internal/stack" + +func isTraceStack(s stack.Stack) bool { + return s.HasFunction("runtime.ReadTrace") +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 73aa79e0b3..87663b50c3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -254,6 +254,10 @@ github.com/yusufpapurcu/wmi # go.uber.org/atomic v1.11.0 ## explicit; go 1.18 go.uber.org/atomic +# go.uber.org/goleak v1.3.0 +## explicit; go 1.20 +go.uber.org/goleak +go.uber.org/goleak/internal/stack # go.uber.org/mock v0.4.0 ## explicit; go 1.20 go.uber.org/mock/gomock From c2658d1d9981970990d8426ea8e9600852f46d79 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 6 Aug 2024 14:53:52 +0100 Subject: [PATCH 03/49] reopen file leak detected --- src/core/metrics/collectors/leak_test.go | 3 ++- src/core/metrics/sources/leak_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/metrics/collectors/leak_test.go b/src/core/metrics/collectors/leak_test.go index 6e69910376..8c7316bbd4 100644 --- a/src/core/metrics/collectors/leak_test.go +++ b/src/core/metrics/collectors/leak_test.go @@ -2,9 +2,10 @@ package collectors import ( "testing" + "go.uber.org/goleak" ) func TestMain(m *testing.M) { goleak.VerifyTestMain(m) -} \ No newline at end of file +} diff --git a/src/core/metrics/sources/leak_test.go b/src/core/metrics/sources/leak_test.go index a63efbbd5b..5d975baaed 100644 --- a/src/core/metrics/sources/leak_test.go +++ b/src/core/metrics/sources/leak_test.go @@ -2,9 +2,10 @@ package sources import ( "testing" + "go.uber.org/goleak" ) func TestMain(m *testing.M) { goleak.VerifyTestMain(m) -} \ No newline at end of file +} From 31a91ada8b0ef3bb742d739169342ece19e7e782 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 6 Aug 2024 15:06:24 +0100 Subject: [PATCH 04/49] leak test --- src/core/metrics/leak_test.go | 19 +++++++++++++++++++ src/core/metrics/sources/cgroup/leak_test.go | 18 ++++++++++++++++++ src/core/tailer/leak_test.go | 19 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/core/metrics/leak_test.go create mode 100644 src/core/metrics/sources/cgroup/leak_test.go create mode 100644 src/core/tailer/leak_test.go diff --git a/src/core/metrics/leak_test.go b/src/core/metrics/leak_test.go new file mode 100644 index 0000000000..d405302c81 --- /dev/null +++ b/src/core/metrics/leak_test.go @@ -0,0 +1,19 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + + package metrics + + import ( + "testing" + + "go.uber.org/goleak" + ) + + func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) + } + \ No newline at end of file diff --git a/src/core/metrics/sources/cgroup/leak_test.go b/src/core/metrics/sources/cgroup/leak_test.go new file mode 100644 index 0000000000..c1d1cbdbc3 --- /dev/null +++ b/src/core/metrics/sources/cgroup/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + + package cgroup + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/tailer/leak_test.go b/src/core/tailer/leak_test.go new file mode 100644 index 0000000000..4083003473 --- /dev/null +++ b/src/core/tailer/leak_test.go @@ -0,0 +1,19 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + + package tailer + + import ( + "testing" + + "go.uber.org/goleak" + ) + + func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) + } + \ No newline at end of file From a44026f096707908fa65b27564df6004858b3f30 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 6 Aug 2024 15:06:56 +0100 Subject: [PATCH 05/49] leak test --- src/core/metrics/leak_test.go | 21 ++++++++++---------- src/core/metrics/sources/cgroup/leak_test.go | 2 +- src/core/tailer/leak_test.go | 21 ++++++++++---------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/core/metrics/leak_test.go b/src/core/metrics/leak_test.go index d405302c81..e814bcd1c5 100644 --- a/src/core/metrics/leak_test.go +++ b/src/core/metrics/leak_test.go @@ -5,15 +5,14 @@ * LICENSE file in the root directory of this source tree. */ - package metrics +package metrics - import ( - "testing" - - "go.uber.org/goleak" - ) - - func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) - } - \ No newline at end of file +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/metrics/sources/cgroup/leak_test.go b/src/core/metrics/sources/cgroup/leak_test.go index c1d1cbdbc3..7755cf68cd 100644 --- a/src/core/metrics/sources/cgroup/leak_test.go +++ b/src/core/metrics/sources/cgroup/leak_test.go @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ - package cgroup +package cgroup import ( "testing" diff --git a/src/core/tailer/leak_test.go b/src/core/tailer/leak_test.go index 4083003473..f4b4c0a15f 100644 --- a/src/core/tailer/leak_test.go +++ b/src/core/tailer/leak_test.go @@ -5,15 +5,14 @@ * LICENSE file in the root directory of this source tree. */ - package tailer +package tailer - import ( - "testing" - - "go.uber.org/goleak" - ) - - func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) - } - \ No newline at end of file +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} From f27ac624bec36cb8ec53471d0f10a42271ef71ea Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 7 Aug 2024 15:29:08 +0100 Subject: [PATCH 06/49] debug instrumentation --- leak_test.go | 19 ++++++++++++++ src/core/config/leak_test.go | 19 ++++++++++++++ src/core/metrics/collectors/leak_test.go | 7 +++++ src/core/metrics/sources/common.go | 3 +++ src/core/metrics/sources/disk.go | 3 +++ src/core/metrics/sources/disk_io.go | 1 + src/core/metrics/sources/leak_test.go | 26 ++++++++++++------- src/core/metrics/sources/load.go | 3 +++ src/core/metrics/sources/mem.go | 2 +- src/core/metrics/sources/net_io.go | 3 +++ src/core/metrics/sources/nginx_access_log.go | 2 ++ src/core/metrics/sources/nginx_oss.go | 2 ++ src/core/metrics/sources/nginx_plus.go | 4 +++ src/core/metrics/sources/nginx_process.go | 2 ++ src/core/metrics/sources/nginx_worker.go | 2 ++ src/plugins/leak_test.go | 19 ++++++++++++++ .../v2/src/core/metrics/sources/common.go | 3 +++ .../agent/v2/src/core/metrics/sources/disk.go | 3 +++ .../v2/src/core/metrics/sources/disk_io.go | 1 + .../agent/v2/src/core/metrics/sources/load.go | 3 +++ .../agent/v2/src/core/metrics/sources/mem.go | 2 +- .../v2/src/core/metrics/sources/net_io.go | 3 +++ .../core/metrics/sources/nginx_access_log.go | 2 ++ .../v2/src/core/metrics/sources/nginx_oss.go | 2 ++ .../v2/src/core/metrics/sources/nginx_plus.go | 4 +++ .../src/core/metrics/sources/nginx_process.go | 2 ++ .../src/core/metrics/sources/nginx_worker.go | 2 ++ 27 files changed, 133 insertions(+), 11 deletions(-) create mode 100644 leak_test.go create mode 100644 src/core/config/leak_test.go create mode 100644 src/plugins/leak_test.go diff --git a/leak_test.go b/leak_test.go new file mode 100644 index 0000000000..1606157cec --- /dev/null +++ b/leak_test.go @@ -0,0 +1,19 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + + package main + + import ( + "testing" + + "go.uber.org/goleak" + ) + + func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) + } + \ No newline at end of file diff --git a/src/core/config/leak_test.go b/src/core/config/leak_test.go new file mode 100644 index 0000000000..2076d14d0d --- /dev/null +++ b/src/core/config/leak_test.go @@ -0,0 +1,19 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + + package config + + import ( + "testing" + + "go.uber.org/goleak" + ) + + func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) + } + \ No newline at end of file diff --git a/src/core/metrics/collectors/leak_test.go b/src/core/metrics/collectors/leak_test.go index 8c7316bbd4..824efcc085 100644 --- a/src/core/metrics/collectors/leak_test.go +++ b/src/core/metrics/collectors/leak_test.go @@ -1,3 +1,10 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + package collectors import ( diff --git a/src/core/metrics/sources/common.go b/src/core/metrics/sources/common.go index 3041ee5121..1a942a1e9f 100644 --- a/src/core/metrics/sources/common.go +++ b/src/core/metrics/sources/common.go @@ -13,6 +13,7 @@ import ( "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" + log "github.com/sirupsen/logrus" ) const ( @@ -91,6 +92,8 @@ func Delta(current, previous map[string]map[string]float64) map[string]map[strin func SendNginxDownStatus(ctx context.Context, dims []*proto.Dimension, m chan<- *metrics.StatsEntityWrapper) { simpleMetrics := []*proto.SimpleMetric{newFloatMetric("nginx.status", float64(0))} + log.Debugf("nginx down status %d", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE): diff --git a/src/core/metrics/sources/disk.go b/src/core/metrics/sources/disk.go index 4721330979..be915e7a1f 100644 --- a/src/core/metrics/sources/disk.go +++ b/src/core/metrics/sources/disk.go @@ -15,6 +15,7 @@ import ( "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" + log "github.com/sirupsen/logrus" ) const MOUNT_POINT = "mount_point" @@ -50,6 +51,8 @@ func (c *Disk) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metric "in_use": float64(usage.UsedPercentage), }) + log.Debugf("disk metrics collected: %v", len(simpleMetrics)) + select { case <-ctx.Done(): return diff --git a/src/core/metrics/sources/disk_io.go b/src/core/metrics/sources/disk_io.go index eaa961cd25..e85fcb1ba8 100644 --- a/src/core/metrics/sources/disk_io.go +++ b/src/core/metrics/sources/disk_io.go @@ -52,6 +52,7 @@ func (dio *DiskIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *me for k, v := range diffDiskIOStats { simpleMetrics := dio.convertSamplesToSimpleMetrics(v) + log.Debugf("disk io metrics collected: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/src/core/metrics/sources/leak_test.go b/src/core/metrics/sources/leak_test.go index 5d975baaed..b54ef3dce4 100644 --- a/src/core/metrics/sources/leak_test.go +++ b/src/core/metrics/sources/leak_test.go @@ -1,11 +1,19 @@ -package sources +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ -import ( - "testing" + package sources - "go.uber.org/goleak" -) - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -} + import ( + "testing" + + "go.uber.org/goleak" + ) + + func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) + } + \ No newline at end of file diff --git a/src/core/metrics/sources/load.go b/src/core/metrics/sources/load.go index ca1e7ab7d3..ec622716ec 100644 --- a/src/core/metrics/sources/load.go +++ b/src/core/metrics/sources/load.go @@ -15,6 +15,7 @@ import ( "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" "github.com/shirou/gopsutil/v3/load" + log "github.com/sirupsen/logrus" ) type Load struct { @@ -41,6 +42,8 @@ func (c *Load) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metric "15": loadStats.Load15, }) + log.Debugf("load metrics collected: %v", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper([]*proto.Dimension{}, simpleMetrics, proto.MetricsReport_SYSTEM): diff --git a/src/core/metrics/sources/mem.go b/src/core/metrics/sources/mem.go index 77e801ca8e..9a174869fd 100644 --- a/src/core/metrics/sources/mem.go +++ b/src/core/metrics/sources/mem.go @@ -61,7 +61,7 @@ func (c *VirtualMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan< "available": float64(memstats.Available), }) - log.Debugf("Memory metrics collected: %v", simpleMetrics) + log.Debugf("Memory metrics collected: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/src/core/metrics/sources/net_io.go b/src/core/metrics/sources/net_io.go index 9ac04d4bcb..141ab8cfdf 100644 --- a/src/core/metrics/sources/net_io.go +++ b/src/core/metrics/sources/net_io.go @@ -16,6 +16,7 @@ import ( "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" "github.com/shirou/gopsutil/v3/net" + log "github.com/sirupsen/logrus" ) const NETWORK_INTERFACE = "network_interface" @@ -82,6 +83,8 @@ func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *met } simpleMetrics := nio.convertSamplesToSimpleMetrics(v) + log.Debugf("net IO stats count: %d", len(simpleMetrics)) + select { case <-ctx.Done(): return diff --git a/src/core/metrics/sources/nginx_access_log.go b/src/core/metrics/sources/nginx_access_log.go index 5cf9b19c8d..ae1f972a7c 100644 --- a/src/core/metrics/sources/nginx_access_log.go +++ b/src/core/metrics/sources/nginx_access_log.go @@ -378,6 +378,8 @@ func (c *NginxAccessLog) logStats(ctx context.Context, logFile, logFormat string httpCounters, upstreamCounters, upstreamCacheCounters = map[string]float64{}, map[string]float64{}, map[string]float64{} gzipRatios, requestLengths, requestTimes, upstreamResponseLength, upstreamResponseTimes, upstreamConnectTimes, upstreamHeaderTimes = []float64{}, []float64{}, []float64{}, []float64{}, []float64{}, []float64{}, []float64{} + log.Debugf("access log stats count: %d", len(simpleMetrics)) + c.buf = append(c.buf, metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), simpleMetrics, proto.MetricsReport_INSTANCE)) mu.Unlock() diff --git a/src/core/metrics/sources/nginx_oss.go b/src/core/metrics/sources/nginx_oss.go index 8bdd16c33e..a0cb3d81c2 100644 --- a/src/core/metrics/sources/nginx_oss.go +++ b/src/core/metrics/sources/nginx_oss.go @@ -106,6 +106,8 @@ func (c *NginxOSS) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *me simpleMetrics = append(simpleMetrics, &proto.SimpleMetric{Name: "nginx.status", Value: 1.0}) + log.Debugf("oss metrics count %d", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), simpleMetrics, proto.MetricsReport_INSTANCE): diff --git a/src/core/metrics/sources/nginx_plus.go b/src/core/metrics/sources/nginx_plus.go index 3077083ba8..582a81c6bf 100644 --- a/src/core/metrics/sources/nginx_plus.go +++ b/src/core/metrics/sources/nginx_plus.go @@ -533,6 +533,8 @@ func (c *NginxPlus) commonMetrics(stats, prevStats *plusclient.Stats) *metrics.S "request.count": float64(requestCount), }) + log.Debugf("common metrics count %d", len(simpleMetrics)) + dims := c.baseDimensions.ToDimensions() return metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE) } @@ -559,6 +561,8 @@ func (c *NginxPlus) sslMetrics(stats, prevStats *plusclient.Stats) *metrics.Stat "ssl.reuses": float64(sslReuses), }) + log.Debugf("SSL metrics count %d", len(simpleMetrics)) + dims := c.baseDimensions.ToDimensions() return metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE) } diff --git a/src/core/metrics/sources/nginx_process.go b/src/core/metrics/sources/nginx_process.go index da533967e3..eb3a580db4 100644 --- a/src/core/metrics/sources/nginx_process.go +++ b/src/core/metrics/sources/nginx_process.go @@ -52,6 +52,8 @@ func (c *NginxProcess) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- "instance.count": c.getNginxCount(), }) + log.Debugf("instance metrics count %d", len(countSimpleMetric)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), countSimpleMetric, proto.MetricsReport_INSTANCE): diff --git a/src/core/metrics/sources/nginx_worker.go b/src/core/metrics/sources/nginx_worker.go index 12a64f8c58..1b19227ece 100644 --- a/src/core/metrics/sources/nginx_worker.go +++ b/src/core/metrics/sources/nginx_worker.go @@ -262,6 +262,8 @@ func (client *NginxWorkerClient) GetWorkerStats(childProcs []*proto.NginxDetails stats.Workers.KbsW = kbsw stats.Workers.FdsCount = fdSum + log.Debugf("worker stats for number of workers: %f", stats.Workers.Count) + return stats, nil } diff --git a/src/plugins/leak_test.go b/src/plugins/leak_test.go new file mode 100644 index 0000000000..2e53cc883e --- /dev/null +++ b/src/plugins/leak_test.go @@ -0,0 +1,19 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + + package plugins + + import ( + "testing" + + "go.uber.org/goleak" + ) + + func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) + } + \ No newline at end of file diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/common.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/common.go index 3041ee5121..1a942a1e9f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/common.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/common.go @@ -13,6 +13,7 @@ import ( "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" + log "github.com/sirupsen/logrus" ) const ( @@ -91,6 +92,8 @@ func Delta(current, previous map[string]map[string]float64) map[string]map[strin func SendNginxDownStatus(ctx context.Context, dims []*proto.Dimension, m chan<- *metrics.StatsEntityWrapper) { simpleMetrics := []*proto.SimpleMetric{newFloatMetric("nginx.status", float64(0))} + log.Debugf("nginx down status %d", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go index 4721330979..be915e7a1f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go @@ -15,6 +15,7 @@ import ( "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" + log "github.com/sirupsen/logrus" ) const MOUNT_POINT = "mount_point" @@ -50,6 +51,8 @@ func (c *Disk) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metric "in_use": float64(usage.UsedPercentage), }) + log.Debugf("disk metrics collected: %v", len(simpleMetrics)) + select { case <-ctx.Done(): return diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go index eaa961cd25..e85fcb1ba8 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go @@ -52,6 +52,7 @@ func (dio *DiskIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *me for k, v := range diffDiskIOStats { simpleMetrics := dio.convertSamplesToSimpleMetrics(v) + log.Debugf("disk io metrics collected: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go index ca1e7ab7d3..ec622716ec 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go @@ -15,6 +15,7 @@ import ( "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" "github.com/shirou/gopsutil/v3/load" + log "github.com/sirupsen/logrus" ) type Load struct { @@ -41,6 +42,8 @@ func (c *Load) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metric "15": loadStats.Load15, }) + log.Debugf("load metrics collected: %v", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper([]*proto.Dimension{}, simpleMetrics, proto.MetricsReport_SYSTEM): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go index 77e801ca8e..9a174869fd 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go @@ -61,7 +61,7 @@ func (c *VirtualMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan< "available": float64(memstats.Available), }) - log.Debugf("Memory metrics collected: %v", simpleMetrics) + log.Debugf("Memory metrics collected: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go index 9ac04d4bcb..141ab8cfdf 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go @@ -16,6 +16,7 @@ import ( "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" "github.com/shirou/gopsutil/v3/net" + log "github.com/sirupsen/logrus" ) const NETWORK_INTERFACE = "network_interface" @@ -82,6 +83,8 @@ func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *met } simpleMetrics := nio.convertSamplesToSimpleMetrics(v) + log.Debugf("net IO stats count: %d", len(simpleMetrics)) + select { case <-ctx.Done(): return diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go index 5cf9b19c8d..ae1f972a7c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go @@ -378,6 +378,8 @@ func (c *NginxAccessLog) logStats(ctx context.Context, logFile, logFormat string httpCounters, upstreamCounters, upstreamCacheCounters = map[string]float64{}, map[string]float64{}, map[string]float64{} gzipRatios, requestLengths, requestTimes, upstreamResponseLength, upstreamResponseTimes, upstreamConnectTimes, upstreamHeaderTimes = []float64{}, []float64{}, []float64{}, []float64{}, []float64{}, []float64{}, []float64{} + log.Debugf("access log stats count: %d", len(simpleMetrics)) + c.buf = append(c.buf, metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), simpleMetrics, proto.MetricsReport_INSTANCE)) mu.Unlock() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go index 8bdd16c33e..a0cb3d81c2 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go @@ -106,6 +106,8 @@ func (c *NginxOSS) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *me simpleMetrics = append(simpleMetrics, &proto.SimpleMetric{Name: "nginx.status", Value: 1.0}) + log.Debugf("oss metrics count %d", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), simpleMetrics, proto.MetricsReport_INSTANCE): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go index 3077083ba8..582a81c6bf 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go @@ -533,6 +533,8 @@ func (c *NginxPlus) commonMetrics(stats, prevStats *plusclient.Stats) *metrics.S "request.count": float64(requestCount), }) + log.Debugf("common metrics count %d", len(simpleMetrics)) + dims := c.baseDimensions.ToDimensions() return metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE) } @@ -559,6 +561,8 @@ func (c *NginxPlus) sslMetrics(stats, prevStats *plusclient.Stats) *metrics.Stat "ssl.reuses": float64(sslReuses), }) + log.Debugf("SSL metrics count %d", len(simpleMetrics)) + dims := c.baseDimensions.ToDimensions() return metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go index da533967e3..eb3a580db4 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go @@ -52,6 +52,8 @@ func (c *NginxProcess) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- "instance.count": c.getNginxCount(), }) + log.Debugf("instance metrics count %d", len(countSimpleMetric)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), countSimpleMetric, proto.MetricsReport_INSTANCE): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go index 12a64f8c58..1b19227ece 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go @@ -262,6 +262,8 @@ func (client *NginxWorkerClient) GetWorkerStats(childProcs []*proto.NginxDetails stats.Workers.KbsW = kbsw stats.Workers.FdsCount = fdSum + log.Debugf("worker stats for number of workers: %f", stats.Workers.Count) + return stats, nil } From 8e6f7667258f93010d70ff5628ad31fdf733e120 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 7 Aug 2024 15:32:17 +0100 Subject: [PATCH 07/49] debug instrumentation --- leak_test.go | 21 ++++++++++----------- src/core/config/leak_test.go | 21 ++++++++++----------- src/core/metrics/collectors/leak_test.go | 2 +- src/core/metrics/sources/leak_test.go | 21 ++++++++++----------- src/plugins/leak_test.go | 21 ++++++++++----------- 5 files changed, 41 insertions(+), 45 deletions(-) diff --git a/leak_test.go b/leak_test.go index 1606157cec..42f73ba31b 100644 --- a/leak_test.go +++ b/leak_test.go @@ -5,15 +5,14 @@ * LICENSE file in the root directory of this source tree. */ - package main +package main - import ( - "testing" - - "go.uber.org/goleak" - ) - - func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) - } - \ No newline at end of file +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/config/leak_test.go b/src/core/config/leak_test.go index 2076d14d0d..13e0f351f2 100644 --- a/src/core/config/leak_test.go +++ b/src/core/config/leak_test.go @@ -5,15 +5,14 @@ * LICENSE file in the root directory of this source tree. */ - package config +package config - import ( - "testing" - - "go.uber.org/goleak" - ) - - func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) - } - \ No newline at end of file +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/metrics/collectors/leak_test.go b/src/core/metrics/collectors/leak_test.go index 824efcc085..970818c307 100644 --- a/src/core/metrics/collectors/leak_test.go +++ b/src/core/metrics/collectors/leak_test.go @@ -4,7 +4,7 @@ * This source code is licensed under the Apache License, Version 2.0 license found in the * LICENSE file in the root directory of this source tree. */ - + package collectors import ( diff --git a/src/core/metrics/sources/leak_test.go b/src/core/metrics/sources/leak_test.go index b54ef3dce4..c5ef179178 100644 --- a/src/core/metrics/sources/leak_test.go +++ b/src/core/metrics/sources/leak_test.go @@ -5,15 +5,14 @@ * LICENSE file in the root directory of this source tree. */ - package sources +package sources - import ( - "testing" - - "go.uber.org/goleak" - ) - - func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) - } - \ No newline at end of file +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/plugins/leak_test.go b/src/plugins/leak_test.go index 2e53cc883e..374e99f47c 100644 --- a/src/plugins/leak_test.go +++ b/src/plugins/leak_test.go @@ -5,15 +5,14 @@ * LICENSE file in the root directory of this source tree. */ - package plugins +package plugins - import ( - "testing" - - "go.uber.org/goleak" - ) - - func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) - } - \ No newline at end of file +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} From 9f98b785e39a004c98286b433c6b6ceabac56a31 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 7 Aug 2024 16:53:50 +0100 Subject: [PATCH 08/49] wip: memory leaks --- src/core/leak_test.go | 18 ++++++ src/core/os.go | 9 ++- src/extensions/leak_test.go | 18 ++++++ src/extensions/nginx-app-protect/nap/nap.go | 8 +++ src/extensions/nginx-app-protect/nap/types.go | 3 + src/extensions/nginx_app_protect.go | 2 +- src/plugins/metrics_throlling.go | 58 +++++++++++-------- src/plugins/nginx_counter.go | 4 ++ src/plugins/nginx_counter_test.go | 2 + .../github.com/nginx/agent/v2/src/core/os.go | 9 ++- .../github.com/nginx/agent/v2/src/core/os.go | 9 ++- .../extensions/nginx-app-protect/nap/nap.go | 8 +++ .../extensions/nginx-app-protect/nap/types.go | 3 + .../v2/src/extensions/nginx_app_protect.go | 2 +- .../agent/v2/src/plugins/metrics_throlling.go | 58 +++++++++++-------- .../agent/v2/src/plugins/nginx_counter.go | 4 ++ 16 files changed, 159 insertions(+), 56 deletions(-) create mode 100644 src/core/leak_test.go create mode 100644 src/extensions/leak_test.go diff --git a/src/core/leak_test.go b/src/core/leak_test.go new file mode 100644 index 0000000000..aca7a3351b --- /dev/null +++ b/src/core/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package core + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/os.go b/src/core/os.go index e1f95cf324..012436d862 100644 --- a/src/core/os.go +++ b/src/core/os.go @@ -9,9 +9,12 @@ package core import ( "os" + "sync" "time" ) +var chmodMutex sync.Mutex + // FileExists determines if the specified file given by the file path exists on the system. // If the file does NOT exist on the system the bool will be false and the error will be nil, // if the error is not nil then it's possible the file might exist but an error verifying it's @@ -50,11 +53,13 @@ func EnableWritePermissionForSocket(path string) error { case <-timeout: return lastError default: + chmodMutex.Lock() lastError = os.Chmod(path, 0o660) + chmodMutex.Unlock() if lastError == nil { return nil } } - <-time.After(time.Microsecond * 100) + time.Sleep(time.Microsecond * 100) } -} +} \ No newline at end of file diff --git a/src/extensions/leak_test.go b/src/extensions/leak_test.go new file mode 100644 index 0000000000..dc97c1c105 --- /dev/null +++ b/src/extensions/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package extensions + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/extensions/nginx-app-protect/nap/nap.go b/src/extensions/nginx-app-protect/nap/nap.go index 2043859d77..545c2da5c0 100644 --- a/src/extensions/nginx-app-protect/nap/nap.go +++ b/src/extensions/nginx-app-protect/nap/nap.go @@ -106,12 +106,14 @@ func (nap *NginxAppProtect) Monitor(pollInterval time.Duration) chan NAPReportBu // a report message sent via the channel provided to it. func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterval time.Duration) { // Initial symlink sync + nap.mu.Lock() if nap.Release.VersioningDetails.NAPRelease != "" { err := nap.syncSymLink("", nap.Release.VersioningDetails.NAPBuild) if err != nil { log.Errorf("Error occurred while performing initial sync for NAP symlink - %v", err) } } + nap.mu.Unlock() ticker := time.NewTicker(pollInterval) @@ -127,8 +129,10 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva newNAPReport := newNap.GenerateNAPReport() // Check if there has been any change in the NAP report + nap.mu.Lock() if nap.napReportIsEqual(newNAPReport) { log.Debugf("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) + nap.mu.Unlock() break } @@ -140,6 +144,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva err = nap.syncSymLink(nap.Release.VersioningDetails.NAPBuild, newNAPReport.NAPVersion) if err != nil { log.Errorf("Got the following error syncing NAP symlink - %v", err) + nap.mu.Unlock() break } @@ -148,6 +153,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva nap.Release = newNap.Release nap.AttackSignaturesVersion = newNap.AttackSignaturesVersion nap.ThreatCampaignsVersion = newNap.ThreatCampaignsVersion + nap.mu.Unlock() // Send the update message through the channel msgChannel <- NAPReportBundle{ @@ -236,6 +242,8 @@ func (nap *NginxAppProtect) removeNAPSymlinks(symlinkPatternToIgnore string) err // function has NOT called the Monitor function that is responsible for updating its values // to be in sync with the current system NAP values. func (nap *NginxAppProtect) GenerateNAPReport() NAPReport { + nap.mu.Lock() + defer nap.mu.Unlock() return NAPReport{ NAPVersion: nap.Release.VersioningDetails.NAPBuild, NAPRelease: nap.Release.VersioningDetails.NAPRelease, diff --git a/src/extensions/nginx-app-protect/nap/types.go b/src/extensions/nginx-app-protect/nap/types.go index d7a648b1a2..9e1bfdbb2c 100644 --- a/src/extensions/nginx-app-protect/nap/types.go +++ b/src/extensions/nginx-app-protect/nap/types.go @@ -7,6 +7,8 @@ package nap +import "sync" + // Status is an Enum that represents the status of NAP. type Status int @@ -19,6 +21,7 @@ type NginxAppProtect struct { ThreatCampaignsVersion string optDirPath string symLinkDir string + mu sync.Mutex // Protects the fields above } // NAPReport is a collection of information on the current systems NAP details. diff --git a/src/extensions/nginx_app_protect.go b/src/extensions/nginx_app_protect.go index 62c7e0328d..ee7f9e95d3 100644 --- a/src/extensions/nginx_app_protect.go +++ b/src/extensions/nginx_app_protect.go @@ -131,7 +131,7 @@ func (n *NginxAppProtect) monitor() { ) napUpdateChannel := n.nap.Monitor(n.reportInterval) - + defer close(napUpdateChannel) for { select { case updateMsg := <-napUpdateChannel: diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index 770bf27331..6f7cdefd83 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -4,7 +4,6 @@ * This source code is licensed under the Apache License, Version 2.0 license found in the * LICENSE file in the root directory of this source tree. */ - package plugins import ( @@ -37,11 +36,12 @@ type MetricsThrottle struct { metricsAggregation bool metricsCollections map[proto.MetricsReport_Type]*metrics.Collections ctx context.Context + cancel context.CancelFunc wg sync.WaitGroup - mu sync.Mutex - env core.Environment - conf *config.Config - errors chan error + // mu sync.Mutex + env core.Environment + conf *config.Config + errors chan error } func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrottle { @@ -53,7 +53,6 @@ func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrot collectorsUpdate: atomic.NewBool(false), metricsAggregation: conf.AgentMetrics.Mode == "aggregated", metricsCollections: make(map[proto.MetricsReport_Type]*metrics.Collections, 0), - wg: sync.WaitGroup{}, env: env, conf: conf, errors: make(chan error), @@ -62,10 +61,10 @@ func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrot func (r *MetricsThrottle) Init(pipeline core.MessagePipeInterface) { r.messagePipeline = pipeline - r.ctx = pipeline.Context() + r.ctx, r.cancel = context.WithCancel(pipeline.Context()) if r.metricsAggregation { r.wg.Add(1) - go r.metricsReportGoroutine(r.ctx, &r.wg) + go r.metricsReportGoroutine() } log.Info("MetricsThrottle initializing") } @@ -73,6 +72,8 @@ func (r *MetricsThrottle) Init(pipeline core.MessagePipeInterface) { func (r *MetricsThrottle) Close() { log.Info("MetricsThrottle is wrapping up") r.reportsReady.Store(false) // allow metricsReportGoroutine to shutdown gracefully + r.cancel() + r.wg.Wait() r.ticker.Stop() } @@ -93,7 +94,7 @@ func (r *MetricsThrottle) Process(msg *core.Message) { switch bundle := msg.Data().(type) { case *metrics.MetricsReportBundle: if len(bundle.Data) > 0 { - r.mu.Lock() + // r.mu.Lock() for _, report := range bundle.Data { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { @@ -107,7 +108,7 @@ func (r *MetricsThrottle) Process(msg *core.Message) { log.Debugf("MetricsThrottle: Metrics collection saved [Type: %d]", report.Type) } } - r.mu.Unlock() + // r.mu.Unlock() r.reportsReady.Store(true) } } @@ -136,19 +137,29 @@ func (r *MetricsThrottle) Subscriptions() []string { return []string{core.MetricReport, core.AgentConfigChanged} } -func (r *MetricsThrottle) metricsReportGoroutine(ctx context.Context, wg *sync.WaitGroup) { - defer wg.Done() +func (r *MetricsThrottle) metricsReportGoroutine() { + defer r.wg.Done() defer r.ticker.Stop() + defer close(r.errors) log.Info("MetricsThrottle waiting for report ready") for { - if !r.reportsReady.Load() { - continue + select { + case <-r.ctx.Done(): + err := r.ctx.Err() + if err != nil && err != context.Canceled { + log.Errorf("error in done context metricsReportGoroutine %v", err) + } + return + default: + if !r.reportsReady.Load() { + continue + } } select { - case <-ctx.Done(): + case <-r.ctx.Done(): err := r.ctx.Err() - if err != nil { + if err != nil && err != context.Canceled { log.Errorf("error in done context metricsReportGoroutine %v", err) } return @@ -167,7 +178,9 @@ func (r *MetricsThrottle) metricsReportGoroutine(ctx context.Context, wg *sync.W r.collectorsUpdate.Store(false) } case err := <-r.errors: - log.Errorf("Error in metricsReportGoroutine %v", err) + if err != nil { + log.Errorf("Error in metricsReportGoroutine %v", err) + } } } } @@ -188,8 +201,10 @@ func (r *MetricsThrottle) syncAgentConfigChange() { } func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { - r.mu.Lock() - defer r.mu.Unlock() + // r.mu.Lock() + // localMetricsCollections := r.metricsCollections + // r.metricsCollections = make(map[proto.MetricsReport_Type]*metrics.Collections) + // r.mu.Unlock() for reportType, collection := range r.metricsCollections { reports = append(reports, &proto.MetricsReport{ @@ -199,11 +214,6 @@ func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { Type: reportType, Data: metrics.GenerateMetrics(*collection), }) - r.metricsCollections[reportType] = &metrics.Collections{ - Count: 0, - Data: make(map[string]metrics.PerDimension), - } } - return reports } diff --git a/src/plugins/nginx_counter.go b/src/plugins/nginx_counter.go index 68f9b4fe7a..d33fec57e0 100644 --- a/src/plugins/nginx_counter.go +++ b/src/plugins/nginx_counter.go @@ -115,6 +115,10 @@ func (nc *NginxCounter) Close() { if err := os.RemoveAll(nc.serverAddress[1]); err != nil { log.Warn("Error removing socket") } + + nc.processMutex.RLock() + nc.nginxes = nil + nc.processMutex.RUnlock() } func (nc *NginxCounter) Info() *core.Info { diff --git a/src/plugins/nginx_counter_test.go b/src/plugins/nginx_counter_test.go index 54910bc554..b28350c471 100644 --- a/src/plugins/nginx_counter_test.go +++ b/src/plugins/nginx_counter_test.go @@ -94,6 +94,8 @@ func TestNginxCounter(t *testing.T) { assert.NotEqual(t, result, tt.expectedPayload) wg.Wait() + + nginxCounter.Close() }) } } diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go index e1f95cf324..012436d862 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -9,9 +9,12 @@ package core import ( "os" + "sync" "time" ) +var chmodMutex sync.Mutex + // FileExists determines if the specified file given by the file path exists on the system. // If the file does NOT exist on the system the bool will be false and the error will be nil, // if the error is not nil then it's possible the file might exist but an error verifying it's @@ -50,11 +53,13 @@ func EnableWritePermissionForSocket(path string) error { case <-timeout: return lastError default: + chmodMutex.Lock() lastError = os.Chmod(path, 0o660) + chmodMutex.Unlock() if lastError == nil { return nil } } - <-time.After(time.Microsecond * 100) + time.Sleep(time.Microsecond * 100) } -} +} \ No newline at end of file diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go index e1f95cf324..012436d862 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -9,9 +9,12 @@ package core import ( "os" + "sync" "time" ) +var chmodMutex sync.Mutex + // FileExists determines if the specified file given by the file path exists on the system. // If the file does NOT exist on the system the bool will be false and the error will be nil, // if the error is not nil then it's possible the file might exist but an error verifying it's @@ -50,11 +53,13 @@ func EnableWritePermissionForSocket(path string) error { case <-timeout: return lastError default: + chmodMutex.Lock() lastError = os.Chmod(path, 0o660) + chmodMutex.Unlock() if lastError == nil { return nil } } - <-time.After(time.Microsecond * 100) + time.Sleep(time.Microsecond * 100) } -} +} \ No newline at end of file diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go index 2043859d77..545c2da5c0 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go @@ -106,12 +106,14 @@ func (nap *NginxAppProtect) Monitor(pollInterval time.Duration) chan NAPReportBu // a report message sent via the channel provided to it. func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterval time.Duration) { // Initial symlink sync + nap.mu.Lock() if nap.Release.VersioningDetails.NAPRelease != "" { err := nap.syncSymLink("", nap.Release.VersioningDetails.NAPBuild) if err != nil { log.Errorf("Error occurred while performing initial sync for NAP symlink - %v", err) } } + nap.mu.Unlock() ticker := time.NewTicker(pollInterval) @@ -127,8 +129,10 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva newNAPReport := newNap.GenerateNAPReport() // Check if there has been any change in the NAP report + nap.mu.Lock() if nap.napReportIsEqual(newNAPReport) { log.Debugf("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) + nap.mu.Unlock() break } @@ -140,6 +144,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva err = nap.syncSymLink(nap.Release.VersioningDetails.NAPBuild, newNAPReport.NAPVersion) if err != nil { log.Errorf("Got the following error syncing NAP symlink - %v", err) + nap.mu.Unlock() break } @@ -148,6 +153,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva nap.Release = newNap.Release nap.AttackSignaturesVersion = newNap.AttackSignaturesVersion nap.ThreatCampaignsVersion = newNap.ThreatCampaignsVersion + nap.mu.Unlock() // Send the update message through the channel msgChannel <- NAPReportBundle{ @@ -236,6 +242,8 @@ func (nap *NginxAppProtect) removeNAPSymlinks(symlinkPatternToIgnore string) err // function has NOT called the Monitor function that is responsible for updating its values // to be in sync with the current system NAP values. func (nap *NginxAppProtect) GenerateNAPReport() NAPReport { + nap.mu.Lock() + defer nap.mu.Unlock() return NAPReport{ NAPVersion: nap.Release.VersioningDetails.NAPBuild, NAPRelease: nap.Release.VersioningDetails.NAPRelease, diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/types.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/types.go index d7a648b1a2..9e1bfdbb2c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/types.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/types.go @@ -7,6 +7,8 @@ package nap +import "sync" + // Status is an Enum that represents the status of NAP. type Status int @@ -19,6 +21,7 @@ type NginxAppProtect struct { ThreatCampaignsVersion string optDirPath string symLinkDir string + mu sync.Mutex // Protects the fields above } // NAPReport is a collection of information on the current systems NAP details. diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go index 62c7e0328d..ee7f9e95d3 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go @@ -131,7 +131,7 @@ func (n *NginxAppProtect) monitor() { ) napUpdateChannel := n.nap.Monitor(n.reportInterval) - + defer close(napUpdateChannel) for { select { case updateMsg := <-napUpdateChannel: diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index 770bf27331..6f7cdefd83 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -4,7 +4,6 @@ * This source code is licensed under the Apache License, Version 2.0 license found in the * LICENSE file in the root directory of this source tree. */ - package plugins import ( @@ -37,11 +36,12 @@ type MetricsThrottle struct { metricsAggregation bool metricsCollections map[proto.MetricsReport_Type]*metrics.Collections ctx context.Context + cancel context.CancelFunc wg sync.WaitGroup - mu sync.Mutex - env core.Environment - conf *config.Config - errors chan error + // mu sync.Mutex + env core.Environment + conf *config.Config + errors chan error } func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrottle { @@ -53,7 +53,6 @@ func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrot collectorsUpdate: atomic.NewBool(false), metricsAggregation: conf.AgentMetrics.Mode == "aggregated", metricsCollections: make(map[proto.MetricsReport_Type]*metrics.Collections, 0), - wg: sync.WaitGroup{}, env: env, conf: conf, errors: make(chan error), @@ -62,10 +61,10 @@ func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrot func (r *MetricsThrottle) Init(pipeline core.MessagePipeInterface) { r.messagePipeline = pipeline - r.ctx = pipeline.Context() + r.ctx, r.cancel = context.WithCancel(pipeline.Context()) if r.metricsAggregation { r.wg.Add(1) - go r.metricsReportGoroutine(r.ctx, &r.wg) + go r.metricsReportGoroutine() } log.Info("MetricsThrottle initializing") } @@ -73,6 +72,8 @@ func (r *MetricsThrottle) Init(pipeline core.MessagePipeInterface) { func (r *MetricsThrottle) Close() { log.Info("MetricsThrottle is wrapping up") r.reportsReady.Store(false) // allow metricsReportGoroutine to shutdown gracefully + r.cancel() + r.wg.Wait() r.ticker.Stop() } @@ -93,7 +94,7 @@ func (r *MetricsThrottle) Process(msg *core.Message) { switch bundle := msg.Data().(type) { case *metrics.MetricsReportBundle: if len(bundle.Data) > 0 { - r.mu.Lock() + // r.mu.Lock() for _, report := range bundle.Data { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { @@ -107,7 +108,7 @@ func (r *MetricsThrottle) Process(msg *core.Message) { log.Debugf("MetricsThrottle: Metrics collection saved [Type: %d]", report.Type) } } - r.mu.Unlock() + // r.mu.Unlock() r.reportsReady.Store(true) } } @@ -136,19 +137,29 @@ func (r *MetricsThrottle) Subscriptions() []string { return []string{core.MetricReport, core.AgentConfigChanged} } -func (r *MetricsThrottle) metricsReportGoroutine(ctx context.Context, wg *sync.WaitGroup) { - defer wg.Done() +func (r *MetricsThrottle) metricsReportGoroutine() { + defer r.wg.Done() defer r.ticker.Stop() + defer close(r.errors) log.Info("MetricsThrottle waiting for report ready") for { - if !r.reportsReady.Load() { - continue + select { + case <-r.ctx.Done(): + err := r.ctx.Err() + if err != nil && err != context.Canceled { + log.Errorf("error in done context metricsReportGoroutine %v", err) + } + return + default: + if !r.reportsReady.Load() { + continue + } } select { - case <-ctx.Done(): + case <-r.ctx.Done(): err := r.ctx.Err() - if err != nil { + if err != nil && err != context.Canceled { log.Errorf("error in done context metricsReportGoroutine %v", err) } return @@ -167,7 +178,9 @@ func (r *MetricsThrottle) metricsReportGoroutine(ctx context.Context, wg *sync.W r.collectorsUpdate.Store(false) } case err := <-r.errors: - log.Errorf("Error in metricsReportGoroutine %v", err) + if err != nil { + log.Errorf("Error in metricsReportGoroutine %v", err) + } } } } @@ -188,8 +201,10 @@ func (r *MetricsThrottle) syncAgentConfigChange() { } func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { - r.mu.Lock() - defer r.mu.Unlock() + // r.mu.Lock() + // localMetricsCollections := r.metricsCollections + // r.metricsCollections = make(map[proto.MetricsReport_Type]*metrics.Collections) + // r.mu.Unlock() for reportType, collection := range r.metricsCollections { reports = append(reports, &proto.MetricsReport{ @@ -199,11 +214,6 @@ func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { Type: reportType, Data: metrics.GenerateMetrics(*collection), }) - r.metricsCollections[reportType] = &metrics.Collections{ - Count: 0, - Data: make(map[string]metrics.PerDimension), - } } - return reports } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go index 68f9b4fe7a..d33fec57e0 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go @@ -115,6 +115,10 @@ func (nc *NginxCounter) Close() { if err := os.RemoveAll(nc.serverAddress[1]); err != nil { log.Warn("Error removing socket") } + + nc.processMutex.RLock() + nc.nginxes = nil + nc.processMutex.RUnlock() } func (nc *NginxCounter) Info() *core.Info { From bdaf0c947116ec97e447f78d0d513a1f3c2d61cb Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 7 Aug 2024 17:02:14 +0100 Subject: [PATCH 09/49] wip: fixing race conditions --- src/extensions/nginx-app-protect/nap/nap.go | 19 ++++++++++--------- src/extensions/nginx-app-protect/nap/types.go | 3 --- .../extensions/nginx-app-protect/nap/nap.go | 19 ++++++++++--------- .../extensions/nginx-app-protect/nap/types.go | 3 --- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/extensions/nginx-app-protect/nap/nap.go b/src/extensions/nginx-app-protect/nap/nap.go index 545c2da5c0..efbac39dea 100644 --- a/src/extensions/nginx-app-protect/nap/nap.go +++ b/src/extensions/nginx-app-protect/nap/nap.go @@ -13,6 +13,7 @@ import ( "os" "path/filepath" "strings" + "sync" "time" "github.com/nginx/agent/v2/src/core" @@ -31,7 +32,7 @@ var ( requiredNAPFiles = []string{NAP_VERSION_FILE, NAP_RELEASE_FILE} requireNAPProcesses = []string{BD_SOCKET_PLUGIN_PROCESS} processCheckFunc = core.CheckForProcesses -) + mu = sync.Mutex{} // NewNginxAppProtect returns the object NginxAppProtect, which contains information related // to the Nginx App Protect installed on the system. If Nginx App Protect is NOT installed on @@ -106,14 +107,14 @@ func (nap *NginxAppProtect) Monitor(pollInterval time.Duration) chan NAPReportBu // a report message sent via the channel provided to it. func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterval time.Duration) { // Initial symlink sync - nap.mu.Lock() + mu.Lock() if nap.Release.VersioningDetails.NAPRelease != "" { err := nap.syncSymLink("", nap.Release.VersioningDetails.NAPBuild) if err != nil { log.Errorf("Error occurred while performing initial sync for NAP symlink - %v", err) } } - nap.mu.Unlock() + mu.Unlock() ticker := time.NewTicker(pollInterval) @@ -129,10 +130,10 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva newNAPReport := newNap.GenerateNAPReport() // Check if there has been any change in the NAP report - nap.mu.Lock() + mu.Lock() if nap.napReportIsEqual(newNAPReport) { log.Debugf("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) - nap.mu.Unlock() + mu.Unlock() break } @@ -144,7 +145,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva err = nap.syncSymLink(nap.Release.VersioningDetails.NAPBuild, newNAPReport.NAPVersion) if err != nil { log.Errorf("Got the following error syncing NAP symlink - %v", err) - nap.mu.Unlock() + mu.Unlock() break } @@ -153,7 +154,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva nap.Release = newNap.Release nap.AttackSignaturesVersion = newNap.AttackSignaturesVersion nap.ThreatCampaignsVersion = newNap.ThreatCampaignsVersion - nap.mu.Unlock() + mu.Unlock() // Send the update message through the channel msgChannel <- NAPReportBundle{ @@ -242,8 +243,8 @@ func (nap *NginxAppProtect) removeNAPSymlinks(symlinkPatternToIgnore string) err // function has NOT called the Monitor function that is responsible for updating its values // to be in sync with the current system NAP values. func (nap *NginxAppProtect) GenerateNAPReport() NAPReport { - nap.mu.Lock() - defer nap.mu.Unlock() + mu.Lock() + defer mu.Unlock() return NAPReport{ NAPVersion: nap.Release.VersioningDetails.NAPBuild, NAPRelease: nap.Release.VersioningDetails.NAPRelease, diff --git a/src/extensions/nginx-app-protect/nap/types.go b/src/extensions/nginx-app-protect/nap/types.go index 9e1bfdbb2c..d7a648b1a2 100644 --- a/src/extensions/nginx-app-protect/nap/types.go +++ b/src/extensions/nginx-app-protect/nap/types.go @@ -7,8 +7,6 @@ package nap -import "sync" - // Status is an Enum that represents the status of NAP. type Status int @@ -21,7 +19,6 @@ type NginxAppProtect struct { ThreatCampaignsVersion string optDirPath string symLinkDir string - mu sync.Mutex // Protects the fields above } // NAPReport is a collection of information on the current systems NAP details. diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go index 545c2da5c0..efbac39dea 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go @@ -13,6 +13,7 @@ import ( "os" "path/filepath" "strings" + "sync" "time" "github.com/nginx/agent/v2/src/core" @@ -31,7 +32,7 @@ var ( requiredNAPFiles = []string{NAP_VERSION_FILE, NAP_RELEASE_FILE} requireNAPProcesses = []string{BD_SOCKET_PLUGIN_PROCESS} processCheckFunc = core.CheckForProcesses -) + mu = sync.Mutex{} // NewNginxAppProtect returns the object NginxAppProtect, which contains information related // to the Nginx App Protect installed on the system. If Nginx App Protect is NOT installed on @@ -106,14 +107,14 @@ func (nap *NginxAppProtect) Monitor(pollInterval time.Duration) chan NAPReportBu // a report message sent via the channel provided to it. func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterval time.Duration) { // Initial symlink sync - nap.mu.Lock() + mu.Lock() if nap.Release.VersioningDetails.NAPRelease != "" { err := nap.syncSymLink("", nap.Release.VersioningDetails.NAPBuild) if err != nil { log.Errorf("Error occurred while performing initial sync for NAP symlink - %v", err) } } - nap.mu.Unlock() + mu.Unlock() ticker := time.NewTicker(pollInterval) @@ -129,10 +130,10 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva newNAPReport := newNap.GenerateNAPReport() // Check if there has been any change in the NAP report - nap.mu.Lock() + mu.Lock() if nap.napReportIsEqual(newNAPReport) { log.Debugf("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) - nap.mu.Unlock() + mu.Unlock() break } @@ -144,7 +145,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva err = nap.syncSymLink(nap.Release.VersioningDetails.NAPBuild, newNAPReport.NAPVersion) if err != nil { log.Errorf("Got the following error syncing NAP symlink - %v", err) - nap.mu.Unlock() + mu.Unlock() break } @@ -153,7 +154,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva nap.Release = newNap.Release nap.AttackSignaturesVersion = newNap.AttackSignaturesVersion nap.ThreatCampaignsVersion = newNap.ThreatCampaignsVersion - nap.mu.Unlock() + mu.Unlock() // Send the update message through the channel msgChannel <- NAPReportBundle{ @@ -242,8 +243,8 @@ func (nap *NginxAppProtect) removeNAPSymlinks(symlinkPatternToIgnore string) err // function has NOT called the Monitor function that is responsible for updating its values // to be in sync with the current system NAP values. func (nap *NginxAppProtect) GenerateNAPReport() NAPReport { - nap.mu.Lock() - defer nap.mu.Unlock() + mu.Lock() + defer mu.Unlock() return NAPReport{ NAPVersion: nap.Release.VersioningDetails.NAPBuild, NAPRelease: nap.Release.VersioningDetails.NAPRelease, diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/types.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/types.go index 9e1bfdbb2c..d7a648b1a2 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/types.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/types.go @@ -7,8 +7,6 @@ package nap -import "sync" - // Status is an Enum that represents the status of NAP. type Status int @@ -21,7 +19,6 @@ type NginxAppProtect struct { ThreatCampaignsVersion string optDirPath string symLinkDir string - mu sync.Mutex // Protects the fields above } // NAPReport is a collection of information on the current systems NAP details. From 883ced4076e076f48a787355267a512b698376a0 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 7 Aug 2024 17:04:24 +0100 Subject: [PATCH 10/49] wip: race conditions --- src/extensions/nginx-app-protect/nap/nap.go | 2 +- .../nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extensions/nginx-app-protect/nap/nap.go b/src/extensions/nginx-app-protect/nap/nap.go index efbac39dea..38010298aa 100644 --- a/src/extensions/nginx-app-protect/nap/nap.go +++ b/src/extensions/nginx-app-protect/nap/nap.go @@ -33,7 +33,7 @@ var ( requireNAPProcesses = []string{BD_SOCKET_PLUGIN_PROCESS} processCheckFunc = core.CheckForProcesses mu = sync.Mutex{} - +) // NewNginxAppProtect returns the object NginxAppProtect, which contains information related // to the Nginx App Protect installed on the system. If Nginx App Protect is NOT installed on // the system then a NginxAppProtect object is still returned, the status field will be set diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go index efbac39dea..38010298aa 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go @@ -33,7 +33,7 @@ var ( requireNAPProcesses = []string{BD_SOCKET_PLUGIN_PROCESS} processCheckFunc = core.CheckForProcesses mu = sync.Mutex{} - +) // NewNginxAppProtect returns the object NginxAppProtect, which contains information related // to the Nginx App Protect installed on the system. If Nginx App Protect is NOT installed on // the system then a NginxAppProtect object is still returned, the status field will be set From 18a414b974d5c5e959804ee1b06e6bb5bf57b05b Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 7 Aug 2024 17:05:12 +0100 Subject: [PATCH 11/49] wip: local changes --- src/core/os.go | 2 +- src/extensions/nginx-app-protect/nap/nap.go | 1 + .../integration/vendor/github.com/nginx/agent/v2/src/core/os.go | 2 +- .../performance/vendor/github.com/nginx/agent/v2/src/core/os.go | 2 +- .../nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/os.go b/src/core/os.go index 012436d862..e71413aebb 100644 --- a/src/core/os.go +++ b/src/core/os.go @@ -62,4 +62,4 @@ func EnableWritePermissionForSocket(path string) error { } time.Sleep(time.Microsecond * 100) } -} \ No newline at end of file +} diff --git a/src/extensions/nginx-app-protect/nap/nap.go b/src/extensions/nginx-app-protect/nap/nap.go index 38010298aa..d1d37f80e1 100644 --- a/src/extensions/nginx-app-protect/nap/nap.go +++ b/src/extensions/nginx-app-protect/nap/nap.go @@ -34,6 +34,7 @@ var ( processCheckFunc = core.CheckForProcesses mu = sync.Mutex{} ) + // NewNginxAppProtect returns the object NginxAppProtect, which contains information related // to the Nginx App Protect installed on the system. If Nginx App Protect is NOT installed on // the system then a NginxAppProtect object is still returned, the status field will be set diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go index 012436d862..e71413aebb 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -62,4 +62,4 @@ func EnableWritePermissionForSocket(path string) error { } time.Sleep(time.Microsecond * 100) } -} \ No newline at end of file +} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go index 012436d862..e71413aebb 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -62,4 +62,4 @@ func EnableWritePermissionForSocket(path string) error { } time.Sleep(time.Microsecond * 100) } -} \ No newline at end of file +} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go index 38010298aa..d1d37f80e1 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go @@ -34,6 +34,7 @@ var ( processCheckFunc = core.CheckForProcesses mu = sync.Mutex{} ) + // NewNginxAppProtect returns the object NginxAppProtect, which contains information related // to the Nginx App Protect installed on the system. If Nginx App Protect is NOT installed on // the system then a NginxAppProtect object is still returned, the status field will be set From 7d7ea6e939d2c1be6f5c8a4714a1edab992f38ae Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 8 Aug 2024 16:28:54 +0100 Subject: [PATCH 12/49] updated test --- src/core/os.go | 2 + src/core/pipe.go | 75 +++++++------ src/core/pipe_test.go | 100 +++++++++++++----- .../github.com/nginx/agent/v2/src/core/os.go | 2 + .../nginx/agent/v2/src/core/pipe.go | 75 +++++++------ .../github.com/nginx/agent/v2/src/core/os.go | 2 + .../nginx/agent/v2/src/core/pipe.go | 75 +++++++------ 7 files changed, 214 insertions(+), 117 deletions(-) diff --git a/src/core/os.go b/src/core/os.go index e71413aebb..fcc9901d7f 100644 --- a/src/core/os.go +++ b/src/core/os.go @@ -45,6 +45,8 @@ func FilesExists(filePaths []string) (bool, error) { return true, nil } +// EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. +// The function continuously attempts the operation until either it succeeds or the timeout period elapses. func EnableWritePermissionForSocket(path string) error { timeout := time.After(time.Second * 1) var lastError error diff --git a/src/core/pipe.go b/src/core/pipe.go index be4dff74ce..95150f781c 100644 --- a/src/core/pipe.go +++ b/src/core/pipe.go @@ -36,20 +36,18 @@ type MessagePipe struct { plugins []Plugin extensionPlugins []ExtensionPlugin ctx context.Context - cancel context.CancelFunc mu sync.RWMutex bus message_bus.MessageBus } func NewMessagePipe(ctx context.Context, size int) *MessagePipe { - pipeContext, pipeCancel := context.WithCancel(ctx) return &MessagePipe{ messageChannel: make(chan *Message, size), plugins: make([]Plugin, 0, MaxPlugins), extensionPlugins: make([]ExtensionPlugin, 0, MaxExtensionPlugins), - ctx: pipeContext, - cancel: pipeCancel, + ctx: ctx, mu: sync.RWMutex{}, + bus: message_bus.New(size), } } @@ -64,6 +62,7 @@ func InitializePipe(ctx context.Context, corePlugins []Plugin, extensionPlugins func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []ExtensionPlugin) error { p.mu.Lock() + defer p.mu.Unlock() p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) @@ -91,25 +90,26 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex } extensionPluginsRegistered = append(extensionPluginsRegistered, *plugin.Info().name) } - log.Infof("The following core plugins have being registered: %q", pluginsRegistered) - log.Infof("The following extension plugins have being registered: %q", extensionPluginsRegistered) - p.mu.Unlock() + log.Infof("The following core plugins have been registered: %q", pluginsRegistered) + log.Infof("The following extension plugins have been registered: %q", extensionPluginsRegistered) + return nil } func (p *MessagePipe) DeRegister(pluginNames []string) error { p.mu.Lock() + defer p.mu.Unlock() - var plugins []Plugin + var pluginsToRemove []Plugin for _, name := range pluginNames { for _, plugin := range p.plugins { if plugin.Info().Name() == name { - plugins = append(plugins, plugin) + pluginsToRemove = append(pluginsToRemove, plugin) } } } - for _, plugin := range plugins { + for _, plugin := range pluginsToRemove { index := getIndex(plugin.Info().Name(), p.plugins) if index != -1 { @@ -124,10 +124,8 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { } } } - } - p.mu.Unlock() return nil } @@ -140,11 +138,15 @@ func getIndex(pluginName string, plugins []Plugin) int { return -1 } + func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { - case p.messageChannel <- m: case <-p.ctx.Done(): + p.cleanup() + return + case p.messageChannel <- m: + default: return } } @@ -156,21 +158,14 @@ func (p *MessagePipe) Run() { for { select { case <-p.ctx.Done(): - for _, r := range p.plugins { - r.Close() - } - - for _, r := range p.extensionPlugins { - r.Close() - } - - close(p.messageChannel) - + p.cleanup() return case m := <-p.messageChannel: p.mu.Lock() p.bus.Publish(m.Topic(), m) p.mu.Unlock() + default: + return } } } @@ -179,18 +174,36 @@ func (p *MessagePipe) Context() context.Context { return p.ctx } -func (p *MessagePipe) Cancel() context.CancelFunc { - return p.cancel -} - func (p *MessagePipe) GetPlugins() []Plugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.plugins } func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.extensionPlugins } +func (p *MessagePipe) cleanup() { + for _, r := range p.plugins { + for _, subscription := range r.Subscriptions() { + p.bus.Close(subscription) + } + r.Close() + } + + for _, r := range p.extensionPlugins { + for _, subscription := range r.Subscriptions() { + p.bus.Close(subscription) + } + r.Close() + } + + close(p.messageChannel) +} + func (p *MessagePipe) initPlugins() { for _, r := range p.plugins { r.Init(p) @@ -202,11 +215,13 @@ func (p *MessagePipe) initPlugins() { } func (p *MessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { - pluginAlreadyRegistered := false + p.mu.RLock() + defer p.mu.RUnlock() + for _, plugin := range p.GetPlugins() { if plugin.Info().Name() == pluginName { - pluginAlreadyRegistered = true + return true } } - return pluginAlreadyRegistered + return false } diff --git a/src/core/pipe_test.go b/src/core/pipe_test.go index 73ce9aeff4..c896d8d45d 100644 --- a/src/core/pipe_test.go +++ b/src/core/pipe_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" ) type testPlugin struct { @@ -41,6 +42,38 @@ func (p *testPlugin) Subscriptions() []string { } func TestMessagePipe(t *testing.T) { + messages := []*Message{ + NewMessage("test.message", 1), + } + + plugin := new(testPlugin) + plugin.On("Close").Times(1) + + ctx, cancel := context.WithCancel(context.Background()) + + messagePipe := NewMessagePipe(ctx, 100) + err := messagePipe.Register(10, []Plugin{plugin}, nil) + + require.NoError(t, err) + + messagePipe.Process(messages...) + + select { + case msg := <-messagePipe.messageChannel: + assert.Equal(t, "test.message", *msg.topic) + case <-time.After(time.Second): + t.Fatal("Expected message not received") + } + + err = messagePipe.DeRegister([]string{*plugin.Info().name}) + require.NoError(t, err) + + plugin.AssertExpectations(t) + cancel() + time.Sleep(1 * time.Second) // Allow some time for the message to be processed +} + +func TestMessagePipe_Run(t *testing.T) { messages := []*Message{ NewMessage("test.message", 1), NewMessage("test.message", 2), @@ -49,31 +82,46 @@ func TestMessagePipe(t *testing.T) { NewMessage("test.message", 5), } + ctx, cancel := context.WithCancel(context.Background()) + + pipe := NewMessagePipe(ctx, 10) + plugin := new(testPlugin) plugin.On("Init").Times(1) - plugin.On("Process").Times(len(messages)) + plugin.On("Process").Times(len(messages)) plugin.On("Close").Times(1) - ctx, cancel := context.WithCancel(context.Background()) - pipelineDone := make(chan bool) + pipe.Register(10, []Plugin{plugin}, nil) - messagePipe := NewMessagePipe(ctx, 100) - err := messagePipe.Register(10, []Plugin{plugin}, nil) + go pipe.Run() - assert.NoError(t, err) + pipe.Process(messages...) - go func() { - messagePipe.Run() - pipelineDone <- true - }() + time.Sleep(100 * time.Millisecond) // Allow some time for the message to be processed + cancel() - messagePipe.Process(messages...) - time.Sleep(10 * time.Millisecond) // for the above call being asynchronous + time.Sleep(1 * time.Second) // Allow some time for the message to be processed - cancel() - <-pipelineDone +} - plugin.AssertExpectations(t) +func TestMessagePipe_Process(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + pipe := NewMessagePipe(ctx, 10) + + messages := []*Message{ + NewMessage("test.message", 1), + } + + pipe.Process(messages...) + + select { + case msg := <-pipe.messageChannel: + assert.Equal(t, "test.message", *msg.topic) + case <-time.After(time.Second): + t.Fatal("Expected message not received") + } } func TestPipe_DeRegister(t *testing.T) { @@ -84,11 +132,11 @@ func TestPipe_DeRegister(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - messagePipe := SetupMockMessagePipe(t, ctx, []Plugin{plugin}, []ExtensionPlugin{}) + messagePipe := NewMessagePipe(ctx, 10) + messagePipe.Register(10, []Plugin{plugin}, nil) err := messagePipe.DeRegister([]string{*plugin.Info().name}) - - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, 0, len(messagePipe.GetPlugins())) } @@ -99,21 +147,19 @@ func TestPipe_IsPluginAlreadyRegistered(t *testing.T) { plugin.On("Close").Times(1) ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + pipelineDone := make(chan bool) + defer close(pipelineDone) messagePipe := NewMessagePipe(ctx, 100) err := messagePipe.Register(10, []Plugin{plugin}, nil) - assert.NoError(t, err) - - go func() { - messagePipe.Run() - pipelineDone <- true - }() // for the above call being asynchronous - - cancel() - <-pipelineDone + require.NoError(t, err) assert.True(t, messagePipe.IsPluginAlreadyRegistered(*plugin.Info().name)) assert.False(t, messagePipe.IsPluginAlreadyRegistered("metrics")) + + err = messagePipe.DeRegister([]string{*plugin.Info().name}) + require.NoError(t, err) } diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go index e71413aebb..fcc9901d7f 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -45,6 +45,8 @@ func FilesExists(filePaths []string) (bool, error) { return true, nil } +// EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. +// The function continuously attempts the operation until either it succeeds or the timeout period elapses. func EnableWritePermissionForSocket(path string) error { timeout := time.After(time.Second * 1) var lastError error diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go index be4dff74ce..95150f781c 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -36,20 +36,18 @@ type MessagePipe struct { plugins []Plugin extensionPlugins []ExtensionPlugin ctx context.Context - cancel context.CancelFunc mu sync.RWMutex bus message_bus.MessageBus } func NewMessagePipe(ctx context.Context, size int) *MessagePipe { - pipeContext, pipeCancel := context.WithCancel(ctx) return &MessagePipe{ messageChannel: make(chan *Message, size), plugins: make([]Plugin, 0, MaxPlugins), extensionPlugins: make([]ExtensionPlugin, 0, MaxExtensionPlugins), - ctx: pipeContext, - cancel: pipeCancel, + ctx: ctx, mu: sync.RWMutex{}, + bus: message_bus.New(size), } } @@ -64,6 +62,7 @@ func InitializePipe(ctx context.Context, corePlugins []Plugin, extensionPlugins func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []ExtensionPlugin) error { p.mu.Lock() + defer p.mu.Unlock() p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) @@ -91,25 +90,26 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex } extensionPluginsRegistered = append(extensionPluginsRegistered, *plugin.Info().name) } - log.Infof("The following core plugins have being registered: %q", pluginsRegistered) - log.Infof("The following extension plugins have being registered: %q", extensionPluginsRegistered) - p.mu.Unlock() + log.Infof("The following core plugins have been registered: %q", pluginsRegistered) + log.Infof("The following extension plugins have been registered: %q", extensionPluginsRegistered) + return nil } func (p *MessagePipe) DeRegister(pluginNames []string) error { p.mu.Lock() + defer p.mu.Unlock() - var plugins []Plugin + var pluginsToRemove []Plugin for _, name := range pluginNames { for _, plugin := range p.plugins { if plugin.Info().Name() == name { - plugins = append(plugins, plugin) + pluginsToRemove = append(pluginsToRemove, plugin) } } } - for _, plugin := range plugins { + for _, plugin := range pluginsToRemove { index := getIndex(plugin.Info().Name(), p.plugins) if index != -1 { @@ -124,10 +124,8 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { } } } - } - p.mu.Unlock() return nil } @@ -140,11 +138,15 @@ func getIndex(pluginName string, plugins []Plugin) int { return -1 } + func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { - case p.messageChannel <- m: case <-p.ctx.Done(): + p.cleanup() + return + case p.messageChannel <- m: + default: return } } @@ -156,21 +158,14 @@ func (p *MessagePipe) Run() { for { select { case <-p.ctx.Done(): - for _, r := range p.plugins { - r.Close() - } - - for _, r := range p.extensionPlugins { - r.Close() - } - - close(p.messageChannel) - + p.cleanup() return case m := <-p.messageChannel: p.mu.Lock() p.bus.Publish(m.Topic(), m) p.mu.Unlock() + default: + return } } } @@ -179,18 +174,36 @@ func (p *MessagePipe) Context() context.Context { return p.ctx } -func (p *MessagePipe) Cancel() context.CancelFunc { - return p.cancel -} - func (p *MessagePipe) GetPlugins() []Plugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.plugins } func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.extensionPlugins } +func (p *MessagePipe) cleanup() { + for _, r := range p.plugins { + for _, subscription := range r.Subscriptions() { + p.bus.Close(subscription) + } + r.Close() + } + + for _, r := range p.extensionPlugins { + for _, subscription := range r.Subscriptions() { + p.bus.Close(subscription) + } + r.Close() + } + + close(p.messageChannel) +} + func (p *MessagePipe) initPlugins() { for _, r := range p.plugins { r.Init(p) @@ -202,11 +215,13 @@ func (p *MessagePipe) initPlugins() { } func (p *MessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { - pluginAlreadyRegistered := false + p.mu.RLock() + defer p.mu.RUnlock() + for _, plugin := range p.GetPlugins() { if plugin.Info().Name() == pluginName { - pluginAlreadyRegistered = true + return true } } - return pluginAlreadyRegistered + return false } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go index e71413aebb..fcc9901d7f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -45,6 +45,8 @@ func FilesExists(filePaths []string) (bool, error) { return true, nil } +// EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. +// The function continuously attempts the operation until either it succeeds or the timeout period elapses. func EnableWritePermissionForSocket(path string) error { timeout := time.After(time.Second * 1) var lastError error diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go index be4dff74ce..95150f781c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -36,20 +36,18 @@ type MessagePipe struct { plugins []Plugin extensionPlugins []ExtensionPlugin ctx context.Context - cancel context.CancelFunc mu sync.RWMutex bus message_bus.MessageBus } func NewMessagePipe(ctx context.Context, size int) *MessagePipe { - pipeContext, pipeCancel := context.WithCancel(ctx) return &MessagePipe{ messageChannel: make(chan *Message, size), plugins: make([]Plugin, 0, MaxPlugins), extensionPlugins: make([]ExtensionPlugin, 0, MaxExtensionPlugins), - ctx: pipeContext, - cancel: pipeCancel, + ctx: ctx, mu: sync.RWMutex{}, + bus: message_bus.New(size), } } @@ -64,6 +62,7 @@ func InitializePipe(ctx context.Context, corePlugins []Plugin, extensionPlugins func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []ExtensionPlugin) error { p.mu.Lock() + defer p.mu.Unlock() p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) @@ -91,25 +90,26 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex } extensionPluginsRegistered = append(extensionPluginsRegistered, *plugin.Info().name) } - log.Infof("The following core plugins have being registered: %q", pluginsRegistered) - log.Infof("The following extension plugins have being registered: %q", extensionPluginsRegistered) - p.mu.Unlock() + log.Infof("The following core plugins have been registered: %q", pluginsRegistered) + log.Infof("The following extension plugins have been registered: %q", extensionPluginsRegistered) + return nil } func (p *MessagePipe) DeRegister(pluginNames []string) error { p.mu.Lock() + defer p.mu.Unlock() - var plugins []Plugin + var pluginsToRemove []Plugin for _, name := range pluginNames { for _, plugin := range p.plugins { if plugin.Info().Name() == name { - plugins = append(plugins, plugin) + pluginsToRemove = append(pluginsToRemove, plugin) } } } - for _, plugin := range plugins { + for _, plugin := range pluginsToRemove { index := getIndex(plugin.Info().Name(), p.plugins) if index != -1 { @@ -124,10 +124,8 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { } } } - } - p.mu.Unlock() return nil } @@ -140,11 +138,15 @@ func getIndex(pluginName string, plugins []Plugin) int { return -1 } + func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { - case p.messageChannel <- m: case <-p.ctx.Done(): + p.cleanup() + return + case p.messageChannel <- m: + default: return } } @@ -156,21 +158,14 @@ func (p *MessagePipe) Run() { for { select { case <-p.ctx.Done(): - for _, r := range p.plugins { - r.Close() - } - - for _, r := range p.extensionPlugins { - r.Close() - } - - close(p.messageChannel) - + p.cleanup() return case m := <-p.messageChannel: p.mu.Lock() p.bus.Publish(m.Topic(), m) p.mu.Unlock() + default: + return } } } @@ -179,18 +174,36 @@ func (p *MessagePipe) Context() context.Context { return p.ctx } -func (p *MessagePipe) Cancel() context.CancelFunc { - return p.cancel -} - func (p *MessagePipe) GetPlugins() []Plugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.plugins } func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.extensionPlugins } +func (p *MessagePipe) cleanup() { + for _, r := range p.plugins { + for _, subscription := range r.Subscriptions() { + p.bus.Close(subscription) + } + r.Close() + } + + for _, r := range p.extensionPlugins { + for _, subscription := range r.Subscriptions() { + p.bus.Close(subscription) + } + r.Close() + } + + close(p.messageChannel) +} + func (p *MessagePipe) initPlugins() { for _, r := range p.plugins { r.Init(p) @@ -202,11 +215,13 @@ func (p *MessagePipe) initPlugins() { } func (p *MessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { - pluginAlreadyRegistered := false + p.mu.RLock() + defer p.mu.RUnlock() + for _, plugin := range p.GetPlugins() { if plugin.Info().Name() == pluginName { - pluginAlreadyRegistered = true + return true } } - return pluginAlreadyRegistered + return false } From 4c26c19d8bb8f8210adaabf87de3411a9a1b7098 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Fri, 9 Aug 2024 12:22:37 +0100 Subject: [PATCH 13/49] removed some memory leaks --- src/core/mock_pipe.go | 4 +++ src/core/pipe.go | 17 ++++++++-- src/core/pipe_test.go | 73 +++++++++++++++++----------------------- src/core/signals.go | 1 + src/plugins/leak_test.go | 18 ---------- 5 files changed, 49 insertions(+), 64 deletions(-) delete mode 100644 src/plugins/leak_test.go diff --git a/src/core/mock_pipe.go b/src/core/mock_pipe.go index a11ccbb18e..11bc5bf311 100644 --- a/src/core/mock_pipe.go +++ b/src/core/mock_pipe.go @@ -146,3 +146,7 @@ func (p *MockMessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { } return pluginAlreadyRegistered } + +func (p *MockMessagePipe) Close() { + +} \ No newline at end of file diff --git a/src/core/pipe.go b/src/core/pipe.go index 95150f781c..379f9ed8ef 100644 --- a/src/core/pipe.go +++ b/src/core/pipe.go @@ -29,6 +29,7 @@ type MessagePipeInterface interface { GetPlugins() []Plugin GetExtensionPlugins() []ExtensionPlugin IsPluginAlreadyRegistered(string) bool + Close() } type MessagePipe struct { @@ -66,7 +67,6 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) - p.bus = message_bus.New(size) pluginsRegistered := []string{} extensionPluginsRegistered := []string{} @@ -129,6 +129,10 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { return nil } +func (p *MessagePipe) Close() { + p.cleanup() +} + func getIndex(pluginName string, plugins []Plugin) int { for index, plugin := range plugins { if pluginName == plugin.Info().Name() { @@ -162,7 +166,9 @@ func (p *MessagePipe) Run() { return case m := <-p.messageChannel: p.mu.Lock() - p.bus.Publish(m.Topic(), m) + if p.bus != nil { + p.bus.Publish(m.Topic(), m) + } p.mu.Unlock() default: return @@ -201,7 +207,12 @@ func (p *MessagePipe) cleanup() { r.Close() } - close(p.messageChannel) + p.bus = nil + p.plugins = nil + if p.messageChannel != nil { + close(p.messageChannel) + } + p.messageChannel = nil } func (p *MessagePipe) initPlugins() { diff --git a/src/core/pipe_test.go b/src/core/pipe_test.go index c896d8d45d..0a7cf2a80b 100644 --- a/src/core/pipe_test.go +++ b/src/core/pipe_test.go @@ -41,11 +41,7 @@ func (p *testPlugin) Subscriptions() []string { return []string{"test.message"} } -func TestMessagePipe(t *testing.T) { - messages := []*Message{ - NewMessage("test.message", 1), - } - +func TestMessagePipe_Register(t *testing.T) { plugin := new(testPlugin) plugin.On("Close").Times(1) @@ -56,21 +52,9 @@ func TestMessagePipe(t *testing.T) { require.NoError(t, err) - messagePipe.Process(messages...) - - select { - case msg := <-messagePipe.messageChannel: - assert.Equal(t, "test.message", *msg.topic) - case <-time.After(time.Second): - t.Fatal("Expected message not received") - } - - err = messagePipe.DeRegister([]string{*plugin.Info().name}) - require.NoError(t, err) - - plugin.AssertExpectations(t) cancel() - time.Sleep(1 * time.Second) // Allow some time for the message to be processed + messagePipe.Close() + plugin.AssertExpectations(t) } func TestMessagePipe_Run(t *testing.T) { @@ -91,22 +75,23 @@ func TestMessagePipe_Run(t *testing.T) { plugin.On("Process").Times(len(messages)) plugin.On("Close").Times(1) - pipe.Register(10, []Plugin{plugin}, nil) + err := pipe.Register(10, []Plugin{plugin}, nil) + require.NoError(t, err) go pipe.Run() pipe.Process(messages...) - time.Sleep(100 * time.Millisecond) // Allow some time for the message to be processed + time.Sleep(100 * time.Millisecond) + cancel() - time.Sleep(1 * time.Second) // Allow some time for the message to be processed - + pipe.Close() + plugin.AssertExpectations(t) } func TestMessagePipe_Process(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) - defer cancel() pipe := NewMessagePipe(ctx, 10) @@ -122,36 +107,38 @@ func TestMessagePipe_Process(t *testing.T) { case <-time.After(time.Second): t.Fatal("Expected message not received") } + + cancel() + pipe.Close() } -func TestPipe_DeRegister(t *testing.T) { - plugin := new(testPlugin) - plugin.On("Init").Times(1) - plugin.On("Close").Times(1) +// func TestPipe_DeRegister(t *testing.T) { +// plugin := new(testPlugin) +// plugin.On("Close").Times(1) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() +// ctx, cancel := context.WithCancel(context.Background()) +// defer cancel() - messagePipe := NewMessagePipe(ctx, 10) - messagePipe.Register(10, []Plugin{plugin}, nil) +// messagePipe := NewMessagePipe(ctx, 10) +// messagePipe.Register(10, []Plugin{plugin}, nil) - err := messagePipe.DeRegister([]string{*plugin.Info().name}) - require.NoError(t, err) +// err := messagePipe.DeRegister([]string{*plugin.Info().name}) +// require.NoError(t, err) - assert.Equal(t, 0, len(messagePipe.GetPlugins())) -} +// assert.Equal(t, 0, len(messagePipe.GetPlugins())) + +// cancel() +// messagePipe.Close() +// plugin.AssertExpectations(t) +// } func TestPipe_IsPluginAlreadyRegistered(t *testing.T) { plugin := new(testPlugin) - plugin.On("Init").Times(1) plugin.On("Close").Times(1) ctx, cancel := context.WithCancel(context.Background()) defer cancel() - pipelineDone := make(chan bool) - defer close(pipelineDone) - messagePipe := NewMessagePipe(ctx, 100) err := messagePipe.Register(10, []Plugin{plugin}, nil) @@ -159,7 +146,7 @@ func TestPipe_IsPluginAlreadyRegistered(t *testing.T) { assert.True(t, messagePipe.IsPluginAlreadyRegistered(*plugin.Info().name)) assert.False(t, messagePipe.IsPluginAlreadyRegistered("metrics")) - - err = messagePipe.DeRegister([]string{*plugin.Info().name}) - require.NoError(t, err) + + messagePipe.Close() + plugin.AssertExpectations(t) } diff --git a/src/core/signals.go b/src/core/signals.go index c8a1ed8d89..70496f0471 100644 --- a/src/core/signals.go +++ b/src/core/signals.go @@ -63,6 +63,7 @@ func HandleSignals( } log.Warn("NGINX Agent exiting") + pipe.Close() cancel() timeout := time.Second * 5 diff --git a/src/plugins/leak_test.go b/src/plugins/leak_test.go deleted file mode 100644 index 374e99f47c..0000000000 --- a/src/plugins/leak_test.go +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) F5, Inc. - * - * This source code is licensed under the Apache License, Version 2.0 license found in the - * LICENSE file in the root directory of this source tree. - */ - -package plugins - -import ( - "testing" - - "go.uber.org/goleak" -) - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -} From ac5c7e0b14b7d1268f425cd2f05f5c00b77d7a3b Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Fri, 9 Aug 2024 12:23:38 +0100 Subject: [PATCH 14/49] local changes --- src/core/mock_pipe.go | 3 +-- src/core/pipe.go | 1 - src/core/pipe_test.go | 4 ++-- .../nginx/agent/v2/src/core/mock_pipe.go | 3 +++ .../github.com/nginx/agent/v2/src/core/pipe.go | 18 ++++++++++++++---- .../nginx/agent/v2/src/core/signals.go | 1 + .../nginx/agent/v2/src/core/mock_pipe.go | 3 +++ .../github.com/nginx/agent/v2/src/core/pipe.go | 18 ++++++++++++++---- .../nginx/agent/v2/src/core/signals.go | 1 + 9 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/core/mock_pipe.go b/src/core/mock_pipe.go index 11bc5bf311..91e087e5f7 100644 --- a/src/core/mock_pipe.go +++ b/src/core/mock_pipe.go @@ -148,5 +148,4 @@ func (p *MockMessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { } func (p *MockMessagePipe) Close() { - -} \ No newline at end of file +} diff --git a/src/core/pipe.go b/src/core/pipe.go index 379f9ed8ef..10bb0f6f0b 100644 --- a/src/core/pipe.go +++ b/src/core/pipe.go @@ -142,7 +142,6 @@ func getIndex(pluginName string, plugins []Plugin) int { return -1 } - func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { diff --git a/src/core/pipe_test.go b/src/core/pipe_test.go index 0a7cf2a80b..302a8b729c 100644 --- a/src/core/pipe_test.go +++ b/src/core/pipe_test.go @@ -72,7 +72,7 @@ func TestMessagePipe_Run(t *testing.T) { plugin := new(testPlugin) plugin.On("Init").Times(1) - plugin.On("Process").Times(len(messages)) + plugin.On("Process").Times(len(messages)) plugin.On("Close").Times(1) err := pipe.Register(10, []Plugin{plugin}, nil) @@ -83,7 +83,7 @@ func TestMessagePipe_Run(t *testing.T) { pipe.Process(messages...) time.Sleep(100 * time.Millisecond) - + cancel() pipe.Close() diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go index a11ccbb18e..91e087e5f7 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go @@ -146,3 +146,6 @@ func (p *MockMessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { } return pluginAlreadyRegistered } + +func (p *MockMessagePipe) Close() { +} diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go index 95150f781c..10bb0f6f0b 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -29,6 +29,7 @@ type MessagePipeInterface interface { GetPlugins() []Plugin GetExtensionPlugins() []ExtensionPlugin IsPluginAlreadyRegistered(string) bool + Close() } type MessagePipe struct { @@ -66,7 +67,6 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) - p.bus = message_bus.New(size) pluginsRegistered := []string{} extensionPluginsRegistered := []string{} @@ -129,6 +129,10 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { return nil } +func (p *MessagePipe) Close() { + p.cleanup() +} + func getIndex(pluginName string, plugins []Plugin) int { for index, plugin := range plugins { if pluginName == plugin.Info().Name() { @@ -138,7 +142,6 @@ func getIndex(pluginName string, plugins []Plugin) int { return -1 } - func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { @@ -162,7 +165,9 @@ func (p *MessagePipe) Run() { return case m := <-p.messageChannel: p.mu.Lock() - p.bus.Publish(m.Topic(), m) + if p.bus != nil { + p.bus.Publish(m.Topic(), m) + } p.mu.Unlock() default: return @@ -201,7 +206,12 @@ func (p *MessagePipe) cleanup() { r.Close() } - close(p.messageChannel) + p.bus = nil + p.plugins = nil + if p.messageChannel != nil { + close(p.messageChannel) + } + p.messageChannel = nil } func (p *MessagePipe) initPlugins() { diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/signals.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/signals.go index c8a1ed8d89..70496f0471 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/signals.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/signals.go @@ -63,6 +63,7 @@ func HandleSignals( } log.Warn("NGINX Agent exiting") + pipe.Close() cancel() timeout := time.Second * 5 diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go index a11ccbb18e..91e087e5f7 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go @@ -146,3 +146,6 @@ func (p *MockMessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { } return pluginAlreadyRegistered } + +func (p *MockMessagePipe) Close() { +} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go index 95150f781c..10bb0f6f0b 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -29,6 +29,7 @@ type MessagePipeInterface interface { GetPlugins() []Plugin GetExtensionPlugins() []ExtensionPlugin IsPluginAlreadyRegistered(string) bool + Close() } type MessagePipe struct { @@ -66,7 +67,6 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) - p.bus = message_bus.New(size) pluginsRegistered := []string{} extensionPluginsRegistered := []string{} @@ -129,6 +129,10 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { return nil } +func (p *MessagePipe) Close() { + p.cleanup() +} + func getIndex(pluginName string, plugins []Plugin) int { for index, plugin := range plugins { if pluginName == plugin.Info().Name() { @@ -138,7 +142,6 @@ func getIndex(pluginName string, plugins []Plugin) int { return -1 } - func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { @@ -162,7 +165,9 @@ func (p *MessagePipe) Run() { return case m := <-p.messageChannel: p.mu.Lock() - p.bus.Publish(m.Topic(), m) + if p.bus != nil { + p.bus.Publish(m.Topic(), m) + } p.mu.Unlock() default: return @@ -201,7 +206,12 @@ func (p *MessagePipe) cleanup() { r.Close() } - close(p.messageChannel) + p.bus = nil + p.plugins = nil + if p.messageChannel != nil { + close(p.messageChannel) + } + p.messageChannel = nil } func (p *MessagePipe) initPlugins() { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/signals.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/signals.go index c8a1ed8d89..70496f0471 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/signals.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/signals.go @@ -63,6 +63,7 @@ func HandleSignals( } log.Warn("NGINX Agent exiting") + pipe.Close() cancel() timeout := time.Second * 5 From c3edeea25f87f3211637215c2ca0e9b01425500d Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Fri, 9 Aug 2024 12:26:02 +0100 Subject: [PATCH 15/49] remove wg --- src/core/metrics/collectors/nginx.go | 8 ++------ .../nginx/agent/v2/src/core/metrics/collectors/nginx.go | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/core/metrics/collectors/nginx.go b/src/core/metrics/collectors/nginx.go index f2e58ae505..eaf900a971 100644 --- a/src/core/metrics/collectors/nginx.go +++ b/src/core/metrics/collectors/nginx.go @@ -75,16 +75,12 @@ func buildSources(dimensions *metrics.CommonDim, binary core.NginxBinary, collec func (c *NginxCollector) collectMetrics(ctx context.Context) { // using a separate WaitGroup, since we need to wait for our own buffer to be filled // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, nginxSource := range c.sources { - wg.Add(1) - go nginxSource.Collect(ctx, wg, c.buf) + go nginxSource.Collect(ctx, nil, c.buf) } - wg.Wait() } -func (c *NginxCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) for { select { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go index f2e58ae505..eaf900a971 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go @@ -75,16 +75,12 @@ func buildSources(dimensions *metrics.CommonDim, binary core.NginxBinary, collec func (c *NginxCollector) collectMetrics(ctx context.Context) { // using a separate WaitGroup, since we need to wait for our own buffer to be filled // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, nginxSource := range c.sources { - wg.Add(1) - go nginxSource.Collect(ctx, wg, c.buf) + go nginxSource.Collect(ctx, nil, c.buf) } - wg.Wait() } -func (c *NginxCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) for { select { From 53bf44e20f537813547d8bee34ce9d109fc59182 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Mon, 12 Aug 2024 10:39:56 +0100 Subject: [PATCH 16/49] wip: remove wg --- src/core/metrics/collectors/container.go | 12 ++++----- src/core/metrics/collectors/container_test.go | 7 +++-- src/core/metrics/collectors/nginx_test.go | 9 +++---- .../metrics/collectors/source_mocks_test.go | 8 +++--- src/core/metrics/collectors/system.go | 9 +++---- src/core/metrics/collectors/system_test.go | 7 +++-- src/core/metrics/sources/container_cpu.go | 4 +-- .../metrics/sources/container_cpu_test.go | 6 +---- src/core/metrics/sources/container_mem.go | 4 +-- .../metrics/sources/container_mem_test.go | 9 +++---- src/core/metrics/sources/cpu.go | 4 +-- src/core/metrics/sources/cpu_test.go | 26 +++++++++---------- src/core/metrics/sources/disk.go | 4 +-- src/core/metrics/sources/disk_io.go | 4 +-- src/core/metrics/sources/disk_io_test.go | 10 +++---- src/core/metrics/sources/disk_test.go | 10 +++---- src/core/metrics/sources/load.go | 4 +-- src/core/metrics/sources/load_test.go | 10 +++---- src/core/metrics/sources/mem.go | 4 +-- src/core/metrics/sources/mem_test.go | 9 +++---- src/core/metrics/sources/net_io.go | 4 +-- src/core/metrics/sources/net_io_test.go | 10 +++---- src/core/metrics/sources/nginx_access_log.go | 4 +-- src/core/metrics/sources/nginx_error_log.go | 4 +-- src/core/metrics/sources/nginx_oss.go | 4 +-- src/core/metrics/sources/nginx_oss_test.go | 10 +++---- src/core/metrics/sources/nginx_plus.go | 4 +-- src/core/metrics/sources/nginx_plus_test.go | 12 ++++----- src/core/metrics/sources/nginx_process.go | 4 +-- .../metrics/sources/nginx_process_test.go | 20 +++++++------- src/core/metrics/sources/nginx_static.go | 4 +-- src/core/metrics/sources/nginx_static_test.go | 10 +++---- src/core/metrics/sources/nginx_worker.go | 4 +-- src/core/metrics/sources/nginx_worker_test.go | 12 ++++----- src/core/metrics/sources/swap.go | 4 +-- src/core/metrics/sources/swap_test.go | 9 +++---- .../monitoring/collector/collector.go | 2 +- .../monitoring/collector/nap.go | 4 +-- .../monitoring/collector/nap_test.go | 7 +++-- .../monitoring/manager/manager.go | 10 +++---- .../monitoring/processor/processor.go | 10 +++---- .../monitoring/processor/processor_test.go | 6 ++--- src/plugins/metrics.go | 8 +++--- test/performance/metrics_test.go | 24 ++++++++--------- .../src/core/metrics/collectors/container.go | 12 ++++----- .../v2/src/core/metrics/collectors/system.go | 9 +++---- .../src/core/metrics/sources/container_cpu.go | 4 +-- .../src/core/metrics/sources/container_mem.go | 4 +-- .../agent/v2/src/core/metrics/sources/cpu.go | 4 +-- .../agent/v2/src/core/metrics/sources/disk.go | 4 +-- .../v2/src/core/metrics/sources/disk_io.go | 4 +-- .../agent/v2/src/core/metrics/sources/load.go | 4 +-- .../agent/v2/src/core/metrics/sources/mem.go | 4 +-- .../v2/src/core/metrics/sources/net_io.go | 4 +-- .../core/metrics/sources/nginx_access_log.go | 4 +-- .../core/metrics/sources/nginx_error_log.go | 4 +-- .../v2/src/core/metrics/sources/nginx_oss.go | 4 +-- .../v2/src/core/metrics/sources/nginx_plus.go | 4 +-- .../src/core/metrics/sources/nginx_process.go | 4 +-- .../src/core/metrics/sources/nginx_static.go | 4 +-- .../src/core/metrics/sources/nginx_worker.go | 4 +-- .../agent/v2/src/core/metrics/sources/swap.go | 4 +-- .../monitoring/collector/collector.go | 2 +- .../monitoring/collector/nap.go | 4 +-- .../monitoring/manager/manager.go | 10 +++---- .../monitoring/processor/processor.go | 10 +++---- .../nginx/agent/v2/src/plugins/metrics.go | 8 +++--- 67 files changed, 226 insertions(+), 243 deletions(-) diff --git a/src/core/metrics/collectors/container.go b/src/core/metrics/collectors/container.go index e0e60d4b75..bcb2b4dbdb 100644 --- a/src/core/metrics/collectors/container.go +++ b/src/core/metrics/collectors/container.go @@ -48,16 +48,16 @@ func NewContainerCollector(env core.Environment, conf *config.Config) *Container func (c *ContainerCollector) collectMetrics(ctx context.Context) { // using a separate WaitGroup, since we need to wait for our own buffer to be filled // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} + // wg := &sync.WaitGroup{} for _, containerSource := range c.sources { - wg.Add(1) - go containerSource.Collect(ctx, wg, c.buf) + // wg.Add(1) + go containerSource.Collect(ctx, nil, c.buf) } - wg.Wait() + // wg.Wait() } -func (c *ContainerCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *ContainerCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/src/core/metrics/collectors/container_test.go b/src/core/metrics/collectors/container_test.go index bb8cc95974..c013e012d9 100644 --- a/src/core/metrics/collectors/container_test.go +++ b/src/core/metrics/collectors/container_test.go @@ -10,7 +10,6 @@ package collectors import ( "context" "reflect" - "sync" "testing" "github.com/stretchr/testify/assert" @@ -62,11 +61,11 @@ func TestContainerCollector_Collect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper) - go containerCollector.Collect(ctx, wg, channel) + go containerCollector.Collect(ctx, nil, channel) containerCollector.buf <- &metrics.StatsEntityWrapper{Type: proto.MetricsReport_SYSTEM, Data: &proto.StatsEntity{Dimensions: []*proto.Dimension{{Name: "new_dim", Value: "123"}}}} actual := <-channel diff --git a/src/core/metrics/collectors/nginx_test.go b/src/core/metrics/collectors/nginx_test.go index 1dea9cb536..5eb64d797b 100644 --- a/src/core/metrics/collectors/nginx_test.go +++ b/src/core/metrics/collectors/nginx_test.go @@ -10,7 +10,6 @@ package collectors import ( "context" "reflect" - "sync" "testing" "github.com/nginx/agent/sdk/v2/proto" @@ -173,10 +172,10 @@ func TestNginxCollector_Collect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) - go nginxCollector.Collect(ctx, wg, make(chan<- *metrics.StatsEntityWrapper)) - wg.Wait() + // wg := &sync.WaitGroup{} + // wg.Add(1) + go nginxCollector.Collect(ctx, nil, make(chan<- *metrics.StatsEntityWrapper)) + // wg.Wait() mockNginxSource1.AssertExpectations(t) mockNginxSource2.AssertExpectations(t) diff --git a/src/core/metrics/collectors/source_mocks_test.go b/src/core/metrics/collectors/source_mocks_test.go index b6fa5a5ad2..4b656e847e 100644 --- a/src/core/metrics/collectors/source_mocks_test.go +++ b/src/core/metrics/collectors/source_mocks_test.go @@ -26,8 +26,8 @@ type NginxSourceMock struct { } func (m *NginxSourceMock) Collect(ctx context.Context, wg *sync.WaitGroup, statsChannel chan<- *metrics.StatsEntityWrapper) { - m.Called(ctx, wg, statsChannel) - wg.Done() + m.Called(ctx) + // wg.Done() } func (m *NginxSourceMock) Update(dimensions *metrics.CommonDim, collectorConf *metrics.NginxCollectorConfig) { @@ -43,6 +43,6 @@ type SourceMock struct { } func (m *SourceMock) Collect(ctx context.Context, wg *sync.WaitGroup, statsChannel chan<- *metrics.StatsEntityWrapper) { - m.Called(ctx, wg, statsChannel) - wg.Done() + m.Called(ctx) + // wg.Done() } diff --git a/src/core/metrics/collectors/system.go b/src/core/metrics/collectors/system.go index a92c4a7b8e..6e5a1573e5 100644 --- a/src/core/metrics/collectors/system.go +++ b/src/core/metrics/collectors/system.go @@ -59,16 +59,13 @@ func NewSystemCollector(env core.Environment, conf *config.Config) *SystemCollec func (c *SystemCollector) collectMetrics(ctx context.Context) { // using a separate WaitGroup, since we need to wait for our own buffer to be filled // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, systemSource := range c.sources { - wg.Add(1) - go systemSource.Collect(ctx, wg, c.buf) + go systemSource.Collect(ctx, nil, c.buf) } - wg.Wait() } -func (c *SystemCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *SystemCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/src/core/metrics/collectors/system_test.go b/src/core/metrics/collectors/system_test.go index a7cd9bdebc..694d8577c5 100644 --- a/src/core/metrics/collectors/system_test.go +++ b/src/core/metrics/collectors/system_test.go @@ -10,7 +10,6 @@ package collectors import ( "context" "reflect" - "sync" "testing" "github.com/stretchr/testify/assert" @@ -94,11 +93,11 @@ func TestSystemCollector_Collect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper) - go systemCollector.Collect(ctx, wg, channel) + go systemCollector.Collect(ctx, nil, channel) systemCollector.buf <- &metrics.StatsEntityWrapper{Type: proto.MetricsReport_SYSTEM, Data: &proto.StatsEntity{Dimensions: []*proto.Dimension{{Name: "new_dim", Value: "123"}}}} actual := <-channel diff --git a/src/core/metrics/sources/container_cpu.go b/src/core/metrics/sources/container_cpu.go index 474f6871c0..4ef7eb6aa5 100644 --- a/src/core/metrics/sources/container_cpu.go +++ b/src/core/metrics/sources/container_cpu.go @@ -47,9 +47,9 @@ func NewContainerCPUSource(namespace string, basePath string) *ContainerCPU { return &ContainerCPU{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, CpuGroup}} } -func (c *ContainerCPU) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerCPU) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container CPU metrics") - defer wg.Done() + // defer wg.Done() containerStats := map[string]float64{} diff --git a/src/core/metrics/sources/container_cpu_test.go b/src/core/metrics/sources/container_cpu_test.go index 27212b7c7c..903a161684 100644 --- a/src/core/metrics/sources/container_cpu_test.go +++ b/src/core/metrics/sources/container_cpu_test.go @@ -12,7 +12,6 @@ import ( "path" "runtime" "sort" - "sync" "testing" "time" @@ -120,12 +119,9 @@ func TestContainerCPUSource(t *testing.T) { t.Run(test.name, func(tt *testing.T) { actual := make(chan *metrics.StatsEntityWrapper, 1) ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) containerCPUSource := NewContainerCPUSource("container", test.basePath) - go containerCPUSource.Collect(ctx, wg, actual) - wg.Wait() + go containerCPUSource.Collect(ctx, nil, actual) select { case result := <-actual: diff --git a/src/core/metrics/sources/container_mem.go b/src/core/metrics/sources/container_mem.go index 01d0bcd7ce..2db6b6d81a 100644 --- a/src/core/metrics/sources/container_mem.go +++ b/src/core/metrics/sources/container_mem.go @@ -40,9 +40,9 @@ func NewContainerMemorySource(namespace string, basePath string) *ContainerMemor return &ContainerMemory{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}} } -func (c *ContainerMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerMemory) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container memory metrics") - defer wg.Done() + // defer wg.Done() var containerStats map[string]float64 diff --git a/src/core/metrics/sources/container_mem_test.go b/src/core/metrics/sources/container_mem_test.go index 9c1fccf584..df892bcfd8 100644 --- a/src/core/metrics/sources/container_mem_test.go +++ b/src/core/metrics/sources/container_mem_test.go @@ -12,7 +12,6 @@ import ( "path" "runtime" "sort" - "sync" "testing" "time" @@ -64,12 +63,12 @@ func TestContainerMemorySource(t *testing.T) { t.Run(test.name, func(tt *testing.T) { actual := make(chan *metrics.StatsEntityWrapper, 1) ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) containerMemorySource := NewContainerMemorySource("container", test.basePath) - go containerMemorySource.Collect(ctx, wg, actual) - wg.Wait() + go containerMemorySource.Collect(ctx, nil, actual) + // wg.Wait() select { case result := <-actual: diff --git a/src/core/metrics/sources/cpu.go b/src/core/metrics/sources/cpu.go index 520c8f550e..080b192314 100644 --- a/src/core/metrics/sources/cpu.go +++ b/src/core/metrics/sources/cpu.go @@ -69,8 +69,8 @@ func diffTimeStat(t1, t2 cpu.TimesStat) cpu.TimesStat { } } -func (c *CPUTimes) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *CPUTimes) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() var simpleMetrics []*proto.SimpleMetric if c.isDocker { dockerCpuPercentages, err := c.cgroupCPUSource.Percentages() diff --git a/src/core/metrics/sources/cpu_test.go b/src/core/metrics/sources/cpu_test.go index af20233ce3..2b210c06f6 100644 --- a/src/core/metrics/sources/cpu_test.go +++ b/src/core/metrics/sources/cpu_test.go @@ -12,7 +12,7 @@ import ( "path" "runtime" "sort" - "sync" + "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -104,11 +104,11 @@ func TestCPUTimesCollect_VM(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, wg, channel) - wg.Wait() + cpuTimes.Collect(ctx, nil, channel) + // wg.Wait() actual := <-channel @@ -147,11 +147,11 @@ func TestCPUTimesCollect_VM(t *testing.T) { } ctx = context.TODO() - wg = &sync.WaitGroup{} - wg.Add(1) + // wg = &sync.WaitGroup{} + // wg.Add(1) channel = make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, wg, channel) - wg.Wait() + cpuTimes.Collect(ctx, nil, channel) + // wg.Wait() actual = <-channel @@ -190,11 +190,11 @@ func TestCPUTimesCollect_Container(t *testing.T) { cgroup.CpuStatsPath = localDirectory + "/testdata/proc/stat" ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, wg, channel) - wg.Wait() + cpuTimes.Collect(ctx, nil, channel) + // wg.Wait() actual := <-channel actualMetricNames := []string{} diff --git a/src/core/metrics/sources/disk.go b/src/core/metrics/sources/disk.go index be915e7a1f..7203fe1be2 100644 --- a/src/core/metrics/sources/disk.go +++ b/src/core/metrics/sources/disk.go @@ -32,8 +32,8 @@ func NewDiskSource(namespace string, env core.Environment) *Disk { return &Disk{NewMetricSourceLogger(), &namedMetric{namespace, "disk"}, disks, env} } -func (c *Disk) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Disk) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() for _, part := range c.disks { if part.Device == "" || part.FsType == "" { continue diff --git a/src/core/metrics/sources/disk_io.go b/src/core/metrics/sources/disk_io.go index e85fcb1ba8..98de097092 100644 --- a/src/core/metrics/sources/disk_io.go +++ b/src/core/metrics/sources/disk_io.go @@ -37,8 +37,8 @@ func NewDiskIOSource(namespace string, env core.Environment) *DiskIO { return &DiskIO{namedMetric: &namedMetric{namespace, "io"}, env: env, diskIOStatsFunc: disk.IOCountersWithContext} } -func (dio *DiskIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (dio *DiskIO) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() dio.init.Do(func() { dio.diskDevs, _ = dio.env.DiskDevices() dio.diskIOStats = dio.newDiskIOCounters(ctx, dio.diskDevs) diff --git a/src/core/metrics/sources/disk_io_test.go b/src/core/metrics/sources/disk_io_test.go index 1e7a1cc3a0..31b99117f3 100644 --- a/src/core/metrics/sources/disk_io_test.go +++ b/src/core/metrics/sources/disk_io_test.go @@ -10,7 +10,7 @@ package sources import ( "context" "sort" - "sync" + "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -39,11 +39,11 @@ func TestDiskIOCollect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - diskio.Collect(ctx, wg, channel) - wg.Wait() + diskio.Collect(ctx, nil, channel) + // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/disk_test.go b/src/core/metrics/sources/disk_test.go index 9e0047c031..fe11854034 100644 --- a/src/core/metrics/sources/disk_test.go +++ b/src/core/metrics/sources/disk_test.go @@ -10,7 +10,7 @@ package sources import ( "context" "sort" - "sync" + "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -35,11 +35,11 @@ func TestDiskCollect(t *testing.T) { disk := NewDiskSource(namespace, env) ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - disk.Collect(ctx, wg, channel) - wg.Wait() + disk.Collect(ctx, nil, channel) + // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/load.go b/src/core/metrics/sources/load.go index ec622716ec..8615636937 100644 --- a/src/core/metrics/sources/load.go +++ b/src/core/metrics/sources/load.go @@ -28,8 +28,8 @@ func NewLoadSource(namespace string) *Load { return &Load{logger: NewMetricSourceLogger(), namedMetric: &namedMetric{namespace, "load"}, avgStatsFunc: load.Avg} } -func (c *Load) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Load) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() loadStats, err := c.avgStatsFunc() if err != nil { c.logger.Log(fmt.Sprintf("Failed to collect Load metrics, %v", err)) diff --git a/src/core/metrics/sources/load_test.go b/src/core/metrics/sources/load_test.go index 6c3fa27f88..cfe4a6b347 100644 --- a/src/core/metrics/sources/load_test.go +++ b/src/core/metrics/sources/load_test.go @@ -10,7 +10,7 @@ package sources import ( "context" "sort" - "sync" + "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -36,11 +36,11 @@ func TestLoadCollect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - loadSource.Collect(ctx, wg, channel) - wg.Wait() + loadSource.Collect(ctx, nil, channel) + // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/mem.go b/src/core/metrics/sources/mem.go index 9a174869fd..f586252157 100644 --- a/src/core/metrics/sources/mem.go +++ b/src/core/metrics/sources/mem.go @@ -38,8 +38,8 @@ func NewVirtualMemorySource(namespace string, env core.Environment) *VirtualMemo return &VirtualMemory{NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}, statFunc} } -func (c *VirtualMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *VirtualMemory) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() memstats, err := c.statFunc(ctx) if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/src/core/metrics/sources/mem_test.go b/src/core/metrics/sources/mem_test.go index 1847f453f3..6bfe2a4254 100644 --- a/src/core/metrics/sources/mem_test.go +++ b/src/core/metrics/sources/mem_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -57,11 +56,11 @@ func TestVirtualMemoryCollect(t *testing.T) { virtualMemorySource := NewVirtualMemorySource("test", env) ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 1) - go virtualMemorySource.Collect(ctx, wg, channel) - wg.Wait() + go virtualMemorySource.Collect(ctx, nil, channel) + // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/net_io.go b/src/core/metrics/sources/net_io.go index 141ab8cfdf..41f6c0a6a9 100644 --- a/src/core/metrics/sources/net_io.go +++ b/src/core/metrics/sources/net_io.go @@ -46,8 +46,8 @@ func NewNetIOSource(namespace string, env core.Environment) *NetIO { } } -func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (nio *NetIO) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() nio.init.Do(func() { ifs, err := nio.newNetInterfaces(ctx) if err != nil || ifs == nil { diff --git a/src/core/metrics/sources/net_io_test.go b/src/core/metrics/sources/net_io_test.go index 20ff69e279..5047b7624c 100644 --- a/src/core/metrics/sources/net_io_test.go +++ b/src/core/metrics/sources/net_io_test.go @@ -10,7 +10,7 @@ package sources import ( "context" "sort" - "sync" + "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -49,11 +49,11 @@ func TestNetIOCollect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - nioSource.Collect(ctx, wg, channel) - wg.Wait() + nioSource.Collect(ctx, nil, channel) + // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/nginx_access_log.go b/src/core/metrics/sources/nginx_access_log.go index ae1f972a7c..a4d01e193b 100644 --- a/src/core/metrics/sources/nginx_access_log.go +++ b/src/core/metrics/sources/nginx_access_log.go @@ -108,8 +108,8 @@ func NewNginxAccessLog( return nginxAccessLog } -func (c *NginxAccessLog) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxAccessLog) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.collectLogStats(ctx, m) } diff --git a/src/core/metrics/sources/nginx_error_log.go b/src/core/metrics/sources/nginx_error_log.go index d985d78b5f..b05dcdef6e 100644 --- a/src/core/metrics/sources/nginx_error_log.go +++ b/src/core/metrics/sources/nginx_error_log.go @@ -101,8 +101,8 @@ func NewNginxErrorLog( return nginxErrorLog } -func (c *NginxErrorLog) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxErrorLog) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.collectLogStats(ctx, m) } diff --git a/src/core/metrics/sources/nginx_oss.go b/src/core/metrics/sources/nginx_oss.go index a0cb3d81c2..a4d9c5b3c9 100644 --- a/src/core/metrics/sources/nginx_oss.go +++ b/src/core/metrics/sources/nginx_oss.go @@ -34,8 +34,8 @@ func NewNginxOSS(baseDimensions *metrics.CommonDim, namespace, stubStatus string return &NginxOSS{baseDimensions: baseDimensions, stubStatus: stubStatus, namedMetric: &namedMetric{namespace: namespace}, logger: NewMetricSourceLogger()} } -func (c *NginxOSS) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxOSS) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() var err error c.init.Do(func() { cl := client.NewNginxClient(&http.Client{}, c.stubStatus) diff --git a/src/core/metrics/sources/nginx_oss_test.go b/src/core/metrics/sources/nginx_oss_test.go index 9195514438..b3ab2920c0 100644 --- a/src/core/metrics/sources/nginx_oss_test.go +++ b/src/core/metrics/sources/nginx_oss_test.go @@ -11,7 +11,7 @@ import ( "context" "net/http" "net/http/httptest" - "sync" + "testing" "github.com/nginx/agent/sdk/v2/proto" @@ -110,10 +110,10 @@ Reading: 0 Writing: 1 Waiting: 0 logger: NewMetricSourceLogger(), } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) - go c.Collect(ctx, wg, test.m) - wg.Wait() + // wg := &sync.WaitGroup{} + // wg.Add(1) + go c.Collect(ctx, nil, test.m) + // wg.Wait() statEntity := <-test.m assert.Len(tt, statEntity.Data.Simplemetrics, len(test.expectedMetrics)) for _, metric := range statEntity.Data.Simplemetrics { diff --git a/src/core/metrics/sources/nginx_plus.go b/src/core/metrics/sources/nginx_plus.go index 582a81c6bf..baefbc9f16 100644 --- a/src/core/metrics/sources/nginx_plus.go +++ b/src/core/metrics/sources/nginx_plus.go @@ -85,8 +85,8 @@ func NewNginxPlus(baseDimensions *metrics.CommonDim, nginxNamespace, plusNamespa return &NginxPlus{baseDimensions: baseDimensions, nginxNamespace: nginxNamespace, plusNamespace: plusNamespace, plusAPI: plusAPI, clientVersion: clientVersion, logger: NewMetricSourceLogger()} } -func (c *NginxPlus) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxPlus) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.init.Do(func() { latestAPIVersion, err := c.getLatestAPIVersion(ctx, c.plusAPI) if err != nil { diff --git a/src/core/metrics/sources/nginx_plus_test.go b/src/core/metrics/sources/nginx_plus_test.go index b067a987ad..86e8c28001 100644 --- a/src/core/metrics/sources/nginx_plus_test.go +++ b/src/core/metrics/sources/nginx_plus_test.go @@ -565,8 +565,8 @@ type FakeNginxPlus struct { } // Collect is fake collector that hard codes a stats struct response to avoid dependency on external NGINX Plus api -func (f *FakeNginxPlus) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (f *FakeNginxPlus) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() f.baseDimensions.NginxType = "plus" f.baseDimensions.PublishedAPI = f.plusAPI @@ -982,10 +982,10 @@ func TestNginxPlus_Collect(t *testing.T) { ctx := context.TODO() f := &FakeNginxPlus{NewNginxPlus(test.baseDimensions, "nginx", "plus", "", 6)} - wg := &sync.WaitGroup{} - wg.Add(1) - go f.Collect(ctx, wg, test.m) - wg.Wait() + // wg := &sync.WaitGroup{} + // wg.Add(1) + go f.Collect(ctx, nil, test.m) + // wg.Wait() instanceMetrics := <-test.m assert.Len(t, instanceMetrics.Data.Simplemetrics, len(expectedInstanceMetrics)) diff --git a/src/core/metrics/sources/nginx_process.go b/src/core/metrics/sources/nginx_process.go index eb3a580db4..d432de436c 100644 --- a/src/core/metrics/sources/nginx_process.go +++ b/src/core/metrics/sources/nginx_process.go @@ -44,8 +44,8 @@ func (c *NginxProcess) getNginxCount() float64 { return 0.0 } -func (c *NginxProcess) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxProcess) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() l := &namedMetric{namespace: PlusNamespace, group: ""} countSimpleMetric := l.convertSamplesToSimpleMetrics(map[string]float64{ diff --git a/src/core/metrics/sources/nginx_process_test.go b/src/core/metrics/sources/nginx_process_test.go index f8c8b45438..70b7001962 100644 --- a/src/core/metrics/sources/nginx_process_test.go +++ b/src/core/metrics/sources/nginx_process_test.go @@ -9,7 +9,7 @@ package sources import ( "context" - "sync" + "testing" "time" @@ -58,10 +58,10 @@ func TestNginxProcessCollector_Collect_Process(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - wg := sync.WaitGroup{} - wg.Add(1) + // wg := sync.WaitGroup{} + // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, nil, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) @@ -102,10 +102,10 @@ func TestNginxProcessCollector_Collect_NoProcess(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - wg := sync.WaitGroup{} - wg.Add(1) + // wg := sync.WaitGroup{} + // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, nil, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) @@ -149,10 +149,10 @@ func TestNginxProcessCollector_Collect_NotPlus(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - wg := sync.WaitGroup{} - wg.Add(1) + // wg := sync.WaitGroup{} + // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, nil, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) diff --git a/src/core/metrics/sources/nginx_static.go b/src/core/metrics/sources/nginx_static.go index 82cdde4f4d..12ec6aca76 100644 --- a/src/core/metrics/sources/nginx_static.go +++ b/src/core/metrics/sources/nginx_static.go @@ -26,8 +26,8 @@ func NewNginxStatic(baseDimensions *metrics.CommonDim, namespace string) *NginxS return &NginxStatic{baseDimensions: baseDimensions, namedMetric: &namedMetric{namespace: namespace}} } -func (c *NginxStatic) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxStatic) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() SendNginxDownStatus(ctx, c.baseDimensions.ToDimensions(), m) } diff --git a/src/core/metrics/sources/nginx_static_test.go b/src/core/metrics/sources/nginx_static_test.go index 02e3b7048f..37b67947ba 100644 --- a/src/core/metrics/sources/nginx_static_test.go +++ b/src/core/metrics/sources/nginx_static_test.go @@ -9,7 +9,7 @@ package sources import ( "context" - "sync" + "testing" "github.com/nginx/agent/sdk/v2/proto" @@ -65,10 +65,10 @@ func TestNginxStatic_Collect(t *testing.T) { namedMetric: test.namedMetric, } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) - go c.Collect(ctx, wg, test.m) - wg.Wait() + // wg := &sync.WaitGroup{} + // wg.Add(1) + go c.Collect(ctx, nil, test.m) + // wg.Wait() statEntity := <-test.m assert.Len(tt, statEntity.Data.Simplemetrics, len(expectedMetrics)) for _, metric := range statEntity.Data.Simplemetrics { diff --git a/src/core/metrics/sources/nginx_worker.go b/src/core/metrics/sources/nginx_worker.go index 1b19227ece..514be451a3 100644 --- a/src/core/metrics/sources/nginx_worker.go +++ b/src/core/metrics/sources/nginx_worker.go @@ -49,9 +49,9 @@ func NewNginxWorker(baseDimensions *metrics.CommonDim, } } -func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxWorker) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { var err error - defer wg.Done() + // defer wg.Done() childProcs := c.binary.GetChildProcesses() c.init.Do(func() { for pid, children := range childProcs { diff --git a/src/core/metrics/sources/nginx_worker_test.go b/src/core/metrics/sources/nginx_worker_test.go index fda857e0a5..3dc7224e5b 100644 --- a/src/core/metrics/sources/nginx_worker_test.go +++ b/src/core/metrics/sources/nginx_worker_test.go @@ -9,7 +9,7 @@ package sources import ( "context" - "sync" + "testing" "time" @@ -78,10 +78,10 @@ func TestNginxWorkerCollector(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - wg := sync.WaitGroup{} - wg.Add(1) + // wg := sync.WaitGroup{} + // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, nil, m) time.Sleep(100 * time.Millisecond) mockClient.AssertNumberOfCalls(t, "GetWorkerStats", 2) @@ -122,9 +122,9 @@ func TestNginxWorkerCollector(t *testing.T) { } } - wg.Add(1) + // wg.Add(1) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, nil, m) time.Sleep(100 * time.Millisecond) mockClient.AssertNumberOfCalls(t, "GetWorkerStats", 3) diff --git a/src/core/metrics/sources/swap.go b/src/core/metrics/sources/swap.go index 2197b0365a..a617f91738 100644 --- a/src/core/metrics/sources/swap.go +++ b/src/core/metrics/sources/swap.go @@ -49,8 +49,8 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { return &Swap{NewMetricSourceLogger(), &namedMetric{namespace, "swap"}, statFunc} } -func (c *Swap) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Swap) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() swapStats, err := c.statFunc() if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/src/core/metrics/sources/swap_test.go b/src/core/metrics/sources/swap_test.go index 9e8af9daf2..7ecce5d3af 100644 --- a/src/core/metrics/sources/swap_test.go +++ b/src/core/metrics/sources/swap_test.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -91,10 +90,10 @@ func TestSwapSource_Collect(t *testing.T) { UsedPercent: 30, }, nil } - wg := &sync.WaitGroup{} - wg.Add(1) - go c.Collect(ctx, wg, test.m) - wg.Wait() + // wg := &sync.WaitGroup{} + // wg.Add(1) + go c.Collect(ctx, nil, test.m) + // wg.Wait() statsEntity := <-test.m assert.Len(tt, statsEntity.Data.Simplemetrics, len(expectedMetrics)) diff --git a/src/extensions/nginx-app-protect/monitoring/collector/collector.go b/src/extensions/nginx-app-protect/monitoring/collector/collector.go index bc9f7e085e..59f78c2fe6 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/collector.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/collector.go @@ -18,5 +18,5 @@ import ( // collect Raw Log data from WAF Instances. type Collector interface { // Collect starts collecting on collect chan until ctx.Done() chan gets a signal - Collect(ctx context.Context, wg *sync.WaitGroup, collect chan<- *monitoring.RawLog) + Collect(ctx context.Context, _ *sync.WaitGroup, collect chan<- *monitoring.RawLog) } diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap.go b/src/extensions/nginx-app-protect/monitoring/collector/nap.go index f7b71b2302..816265d058 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap.go @@ -84,8 +84,8 @@ func newSyslogServer(logger *logrus.Entry, ip string, port int) (*syslogServer, } // Collect starts collecting on collect chan until done chan gets a signal. -func (nap *NAPCollector) Collect(ctx context.Context, wg *sync.WaitGroup, collect chan<- *monitoring.RawLog) { - defer wg.Done() +func (nap *NAPCollector) Collect(ctx context.Context, _ *sync.WaitGroup, collect chan<- *monitoring.RawLog) { + // defer wg.Done() nap.logger.Infof("Starting collection for %s", monitoring.NAP) diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go index a341ea5e08..6227a98c19 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go @@ -13,7 +13,6 @@ import ( "log/syslog" "strconv" "strings" - "sync" "testing" "github.com/sirupsen/logrus" @@ -88,10 +87,10 @@ func TestNAPCollect(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - wg := &sync.WaitGroup{} - wg.Add(1) + // wg := &sync.WaitGroup{} + // wg.Add(1) - go waf.Collect(ctx, wg, collect) + go waf.Collect(ctx, nil, collect) logwriter, err = syslog.Dial("tcp4", testIP+":"+strconv.Itoa(testPort), syslog.LOG_INFO|syslog.LOG_USER, "test") if err != nil { diff --git a/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/src/extensions/nginx-app-protect/monitoring/manager/manager.go index 1c4e30f560..0d71ed0df1 100644 --- a/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -152,16 +152,16 @@ func (s *Manager) Run(ctx context.Context) { chtx, cancel := context.WithCancel(ctx) defer cancel() - waitGroup := &sync.WaitGroup{} - waitGroup.Add(2) + // waitGroup := &sync.WaitGroup{} + // waitGroup.Add(2) - go s.collector.Collect(chtx, waitGroup, s.collectChan) - go s.processor.Process(chtx, waitGroup, s.collectChan, s.processorChan) + go s.collector.Collect(chtx, nil, s.collectChan) + go s.processor.Process(chtx, nil, s.collectChan, s.processorChan) <-ctx.Done() s.logger.Infof("Received Context cancellation, %s is wrapping up...", componentName) - waitGroup.Wait() + // waitGroup.Wait() s.logger.Infof("Context cancellation, %s wrapped up...", componentName) } diff --git a/src/extensions/nginx-app-protect/monitoring/processor/processor.go b/src/extensions/nginx-app-protect/monitoring/processor/processor.go index da2065c8df..fe86feaea3 100644 --- a/src/extensions/nginx-app-protect/monitoring/processor/processor.go +++ b/src/extensions/nginx-app-protect/monitoring/processor/processor.go @@ -76,7 +76,7 @@ func GetClient(cfg *Config) (*Client, error) { // processorWorker is a worker process to process events. func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - defer wg.Done() + // defer wg.Done() c.logger.Debugf("Setting up Processor Worker: %d", id) @@ -121,14 +121,14 @@ func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int } // Process processes the raw log entries from collected chan into Security Events on processed chan. -func (c *Client) Process(ctx context.Context, wg *sync.WaitGroup, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - defer wg.Done() +func (c *Client) Process(ctx context.Context, _ *sync.WaitGroup, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { + // defer wg.Done() c.logger.Info("Setting up Processor") for id := 1; id <= c.workers; id++ { - wg.Add(1) - go c.processorWorker(ctx, wg, id, collected, processed) + // wg.Add(1) + go c.processorWorker(ctx, nil, id, collected, processed) } c.logger.Infof("Done setting up %v Processor Workers", c.workers) diff --git a/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go b/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go index ef09de1701..0efadcfb77 100644 --- a/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go +++ b/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go @@ -1215,11 +1215,11 @@ func TestNAPProcess(t *testing.T) { t.Fatalf("Could not get a Processor Client: %s", err) } - wg := &sync.WaitGroup{} + // wg := &sync.WaitGroup{} - wg.Add(1) + // wg.Add(1) // Start Processor - go p.Process(ctx, wg, collect, processed) + go p.Process(ctx, nil, collect, processed) // Briefly sleep so map can be reconciled before event is collected // and processed diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index de869794bc..58cd2fdb3c 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -219,14 +219,14 @@ func (m *Metrics) collectStats() (stats []*metrics.StatsEntityWrapper) { // maybe we can fine tune the lock later, but the collection has been very quick so far. m.collectorsMutex.Lock() defer m.collectorsMutex.Unlock() - wg := &sync.WaitGroup{} + // wg := &sync.WaitGroup{} start := time.Now() for _, s := range m.collectors { - wg.Add(1) - go s.Collect(ctx, wg, m.buf) + // wg.Add(1) + go s.Collect(ctx, nil, m.buf) } // wait until all the collection go routines are done, which either context timeout or exit - wg.Wait() + // wg.Wait() for len(m.buf) > 0 { // drain the buf, since our sources/collectors are all done, we can rely on buffer length diff --git a/test/performance/metrics_test.go b/test/performance/metrics_test.go index 899a976626..932db1bfad 100644 --- a/test/performance/metrics_test.go +++ b/test/performance/metrics_test.go @@ -75,28 +75,28 @@ type ( ) func (m *MetricsServer) Stream(stream proto.MetricsService_StreamServer) error { - wg := &sync.WaitGroup{} + // wg := &sync.WaitGroup{} h := m.ensureHandler() - wg.Add(1) + // wg.Add(1) hf := h.metricHandlerFunc if hf == nil { hf = h.metricsHandle } - go hf(stream, wg) - wg.Wait() + go hf(stream, nil) + // wg.Wait() return nil } func (m *MetricsServer) StreamEvents(stream proto.MetricsService_StreamEventsServer) error { - wg := &sync.WaitGroup{} + // wg := &sync.WaitGroup{} h := m.ensureHandler() - wg.Add(1) + // wg.Add(1) hf := h.eventReportHandlerFunc if hf == nil { hf = h.eventReportHandle } - go hf(stream, wg) - wg.Wait() + go hf(stream, nil) + // wg.Wait() return nil } @@ -157,15 +157,15 @@ type cmdService struct { } func (c *cmdService) CommandChannel(server proto.Commander_CommandChannelServer) error { - wg := &sync.WaitGroup{} + // wg := &sync.WaitGroup{} h := c.ensureHandler() - wg.Add(1) + // wg.Add(1) hf := h.handleFunc if hf == nil { hf = h.handle } - go hf(server, wg) - wg.Wait() + go hf(server, nil) + // wg.Wait() return nil } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go index e0e60d4b75..bcb2b4dbdb 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go @@ -48,16 +48,16 @@ func NewContainerCollector(env core.Environment, conf *config.Config) *Container func (c *ContainerCollector) collectMetrics(ctx context.Context) { // using a separate WaitGroup, since we need to wait for our own buffer to be filled // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} + // wg := &sync.WaitGroup{} for _, containerSource := range c.sources { - wg.Add(1) - go containerSource.Collect(ctx, wg, c.buf) + // wg.Add(1) + go containerSource.Collect(ctx, nil, c.buf) } - wg.Wait() + // wg.Wait() } -func (c *ContainerCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *ContainerCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go index a92c4a7b8e..6e5a1573e5 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go @@ -59,16 +59,13 @@ func NewSystemCollector(env core.Environment, conf *config.Config) *SystemCollec func (c *SystemCollector) collectMetrics(ctx context.Context) { // using a separate WaitGroup, since we need to wait for our own buffer to be filled // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, systemSource := range c.sources { - wg.Add(1) - go systemSource.Collect(ctx, wg, c.buf) + go systemSource.Collect(ctx, nil, c.buf) } - wg.Wait() } -func (c *SystemCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *SystemCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go index 474f6871c0..4ef7eb6aa5 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go @@ -47,9 +47,9 @@ func NewContainerCPUSource(namespace string, basePath string) *ContainerCPU { return &ContainerCPU{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, CpuGroup}} } -func (c *ContainerCPU) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerCPU) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container CPU metrics") - defer wg.Done() + // defer wg.Done() containerStats := map[string]float64{} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go index 01d0bcd7ce..2db6b6d81a 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go @@ -40,9 +40,9 @@ func NewContainerMemorySource(namespace string, basePath string) *ContainerMemor return &ContainerMemory{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}} } -func (c *ContainerMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerMemory) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container memory metrics") - defer wg.Done() + // defer wg.Done() var containerStats map[string]float64 diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go index 520c8f550e..080b192314 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go @@ -69,8 +69,8 @@ func diffTimeStat(t1, t2 cpu.TimesStat) cpu.TimesStat { } } -func (c *CPUTimes) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *CPUTimes) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() var simpleMetrics []*proto.SimpleMetric if c.isDocker { dockerCpuPercentages, err := c.cgroupCPUSource.Percentages() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go index be915e7a1f..7203fe1be2 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go @@ -32,8 +32,8 @@ func NewDiskSource(namespace string, env core.Environment) *Disk { return &Disk{NewMetricSourceLogger(), &namedMetric{namespace, "disk"}, disks, env} } -func (c *Disk) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Disk) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() for _, part := range c.disks { if part.Device == "" || part.FsType == "" { continue diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go index e85fcb1ba8..98de097092 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go @@ -37,8 +37,8 @@ func NewDiskIOSource(namespace string, env core.Environment) *DiskIO { return &DiskIO{namedMetric: &namedMetric{namespace, "io"}, env: env, diskIOStatsFunc: disk.IOCountersWithContext} } -func (dio *DiskIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (dio *DiskIO) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() dio.init.Do(func() { dio.diskDevs, _ = dio.env.DiskDevices() dio.diskIOStats = dio.newDiskIOCounters(ctx, dio.diskDevs) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go index ec622716ec..8615636937 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go @@ -28,8 +28,8 @@ func NewLoadSource(namespace string) *Load { return &Load{logger: NewMetricSourceLogger(), namedMetric: &namedMetric{namespace, "load"}, avgStatsFunc: load.Avg} } -func (c *Load) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Load) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() loadStats, err := c.avgStatsFunc() if err != nil { c.logger.Log(fmt.Sprintf("Failed to collect Load metrics, %v", err)) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go index 9a174869fd..f586252157 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go @@ -38,8 +38,8 @@ func NewVirtualMemorySource(namespace string, env core.Environment) *VirtualMemo return &VirtualMemory{NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}, statFunc} } -func (c *VirtualMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *VirtualMemory) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() memstats, err := c.statFunc(ctx) if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go index 141ab8cfdf..41f6c0a6a9 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go @@ -46,8 +46,8 @@ func NewNetIOSource(namespace string, env core.Environment) *NetIO { } } -func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (nio *NetIO) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() nio.init.Do(func() { ifs, err := nio.newNetInterfaces(ctx) if err != nil || ifs == nil { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go index ae1f972a7c..a4d01e193b 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go @@ -108,8 +108,8 @@ func NewNginxAccessLog( return nginxAccessLog } -func (c *NginxAccessLog) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxAccessLog) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.collectLogStats(ctx, m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go index d985d78b5f..b05dcdef6e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go @@ -101,8 +101,8 @@ func NewNginxErrorLog( return nginxErrorLog } -func (c *NginxErrorLog) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxErrorLog) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.collectLogStats(ctx, m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go index a0cb3d81c2..a4d9c5b3c9 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go @@ -34,8 +34,8 @@ func NewNginxOSS(baseDimensions *metrics.CommonDim, namespace, stubStatus string return &NginxOSS{baseDimensions: baseDimensions, stubStatus: stubStatus, namedMetric: &namedMetric{namespace: namespace}, logger: NewMetricSourceLogger()} } -func (c *NginxOSS) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxOSS) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() var err error c.init.Do(func() { cl := client.NewNginxClient(&http.Client{}, c.stubStatus) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go index 582a81c6bf..baefbc9f16 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go @@ -85,8 +85,8 @@ func NewNginxPlus(baseDimensions *metrics.CommonDim, nginxNamespace, plusNamespa return &NginxPlus{baseDimensions: baseDimensions, nginxNamespace: nginxNamespace, plusNamespace: plusNamespace, plusAPI: plusAPI, clientVersion: clientVersion, logger: NewMetricSourceLogger()} } -func (c *NginxPlus) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxPlus) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() c.init.Do(func() { latestAPIVersion, err := c.getLatestAPIVersion(ctx, c.plusAPI) if err != nil { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go index eb3a580db4..d432de436c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go @@ -44,8 +44,8 @@ func (c *NginxProcess) getNginxCount() float64 { return 0.0 } -func (c *NginxProcess) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxProcess) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() l := &namedMetric{namespace: PlusNamespace, group: ""} countSimpleMetric := l.convertSamplesToSimpleMetrics(map[string]float64{ diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go index 82cdde4f4d..12ec6aca76 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go @@ -26,8 +26,8 @@ func NewNginxStatic(baseDimensions *metrics.CommonDim, namespace string) *NginxS return &NginxStatic{baseDimensions: baseDimensions, namedMetric: &namedMetric{namespace: namespace}} } -func (c *NginxStatic) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxStatic) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() SendNginxDownStatus(ctx, c.baseDimensions.ToDimensions(), m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go index 1b19227ece..514be451a3 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go @@ -49,9 +49,9 @@ func NewNginxWorker(baseDimensions *metrics.CommonDim, } } -func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxWorker) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { var err error - defer wg.Done() + // defer wg.Done() childProcs := c.binary.GetChildProcesses() c.init.Do(func() { for pid, children := range childProcs { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go index 2197b0365a..a617f91738 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go @@ -49,8 +49,8 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { return &Swap{NewMetricSourceLogger(), &namedMetric{namespace, "swap"}, statFunc} } -func (c *Swap) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Swap) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { + // defer wg.Done() swapStats, err := c.statFunc() if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go index bc9f7e085e..59f78c2fe6 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go @@ -18,5 +18,5 @@ import ( // collect Raw Log data from WAF Instances. type Collector interface { // Collect starts collecting on collect chan until ctx.Done() chan gets a signal - Collect(ctx context.Context, wg *sync.WaitGroup, collect chan<- *monitoring.RawLog) + Collect(ctx context.Context, _ *sync.WaitGroup, collect chan<- *monitoring.RawLog) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go index f7b71b2302..816265d058 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go @@ -84,8 +84,8 @@ func newSyslogServer(logger *logrus.Entry, ip string, port int) (*syslogServer, } // Collect starts collecting on collect chan until done chan gets a signal. -func (nap *NAPCollector) Collect(ctx context.Context, wg *sync.WaitGroup, collect chan<- *monitoring.RawLog) { - defer wg.Done() +func (nap *NAPCollector) Collect(ctx context.Context, _ *sync.WaitGroup, collect chan<- *monitoring.RawLog) { + // defer wg.Done() nap.logger.Infof("Starting collection for %s", monitoring.NAP) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go index 1c4e30f560..0d71ed0df1 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -152,16 +152,16 @@ func (s *Manager) Run(ctx context.Context) { chtx, cancel := context.WithCancel(ctx) defer cancel() - waitGroup := &sync.WaitGroup{} - waitGroup.Add(2) + // waitGroup := &sync.WaitGroup{} + // waitGroup.Add(2) - go s.collector.Collect(chtx, waitGroup, s.collectChan) - go s.processor.Process(chtx, waitGroup, s.collectChan, s.processorChan) + go s.collector.Collect(chtx, nil, s.collectChan) + go s.processor.Process(chtx, nil, s.collectChan, s.processorChan) <-ctx.Done() s.logger.Infof("Received Context cancellation, %s is wrapping up...", componentName) - waitGroup.Wait() + // waitGroup.Wait() s.logger.Infof("Context cancellation, %s wrapped up...", componentName) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go index da2065c8df..fe86feaea3 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go @@ -76,7 +76,7 @@ func GetClient(cfg *Config) (*Client, error) { // processorWorker is a worker process to process events. func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - defer wg.Done() + // defer wg.Done() c.logger.Debugf("Setting up Processor Worker: %d", id) @@ -121,14 +121,14 @@ func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int } // Process processes the raw log entries from collected chan into Security Events on processed chan. -func (c *Client) Process(ctx context.Context, wg *sync.WaitGroup, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - defer wg.Done() +func (c *Client) Process(ctx context.Context, _ *sync.WaitGroup, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { + // defer wg.Done() c.logger.Info("Setting up Processor") for id := 1; id <= c.workers; id++ { - wg.Add(1) - go c.processorWorker(ctx, wg, id, collected, processed) + // wg.Add(1) + go c.processorWorker(ctx, nil, id, collected, processed) } c.logger.Infof("Done setting up %v Processor Workers", c.workers) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index de869794bc..58cd2fdb3c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -219,14 +219,14 @@ func (m *Metrics) collectStats() (stats []*metrics.StatsEntityWrapper) { // maybe we can fine tune the lock later, but the collection has been very quick so far. m.collectorsMutex.Lock() defer m.collectorsMutex.Unlock() - wg := &sync.WaitGroup{} + // wg := &sync.WaitGroup{} start := time.Now() for _, s := range m.collectors { - wg.Add(1) - go s.Collect(ctx, wg, m.buf) + // wg.Add(1) + go s.Collect(ctx, nil, m.buf) } // wait until all the collection go routines are done, which either context timeout or exit - wg.Wait() + // wg.Wait() for len(m.buf) > 0 { // drain the buf, since our sources/collectors are all done, we can rely on buffer length From 1b8e4d57ec2f27fec5ff3f6fdf5112232ed4a03c Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Mon, 12 Aug 2024 11:41:27 +0100 Subject: [PATCH 17/49] wip: failing tests --- src/extensions/nginx-app-protect/monitoring/manager/manager.go | 1 - .../nginx-app-protect/monitoring/processor/processor_test.go | 1 - .../extensions/nginx-app-protect/monitoring/manager/manager.go | 1 - 3 files changed, 3 deletions(-) diff --git a/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/src/extensions/nginx-app-protect/monitoring/manager/manager.go index 0d71ed0df1..4fbd3f4923 100644 --- a/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -10,7 +10,6 @@ package manager import ( "context" "runtime" - "sync" "time" log "github.com/sirupsen/logrus" diff --git a/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go b/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go index 0efadcfb77..b10eab5fe8 100644 --- a/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go +++ b/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go @@ -12,7 +12,6 @@ import ( "context" "os" "strings" - "sync" "testing" "time" diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go index 0d71ed0df1..4fbd3f4923 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -10,7 +10,6 @@ package manager import ( "context" "runtime" - "sync" "time" log "github.com/sirupsen/logrus" From a5a227042641cac6015f0dbdf1ad2a7311b03a4d Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Mon, 12 Aug 2024 11:42:05 +0100 Subject: [PATCH 18/49] wip: failing tests --- src/core/metrics/sources/cpu_test.go | 1 - src/core/metrics/sources/disk_io_test.go | 1 - src/core/metrics/sources/disk_test.go | 1 - src/core/metrics/sources/load_test.go | 1 - src/core/metrics/sources/net_io_test.go | 1 - src/core/metrics/sources/nginx_oss_test.go | 1 - src/core/metrics/sources/nginx_process_test.go | 1 - src/core/metrics/sources/nginx_static_test.go | 1 - src/core/metrics/sources/nginx_worker_test.go | 1 - 9 files changed, 9 deletions(-) diff --git a/src/core/metrics/sources/cpu_test.go b/src/core/metrics/sources/cpu_test.go index 2b210c06f6..21c0dca0f3 100644 --- a/src/core/metrics/sources/cpu_test.go +++ b/src/core/metrics/sources/cpu_test.go @@ -12,7 +12,6 @@ import ( "path" "runtime" "sort" - "testing" "github.com/nginx/agent/v2/src/core/metrics" diff --git a/src/core/metrics/sources/disk_io_test.go b/src/core/metrics/sources/disk_io_test.go index 31b99117f3..e977fcfb0b 100644 --- a/src/core/metrics/sources/disk_io_test.go +++ b/src/core/metrics/sources/disk_io_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "testing" "github.com/nginx/agent/v2/src/core/metrics" diff --git a/src/core/metrics/sources/disk_test.go b/src/core/metrics/sources/disk_test.go index fe11854034..37233ee029 100644 --- a/src/core/metrics/sources/disk_test.go +++ b/src/core/metrics/sources/disk_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "testing" "github.com/nginx/agent/v2/src/core/metrics" diff --git a/src/core/metrics/sources/load_test.go b/src/core/metrics/sources/load_test.go index cfe4a6b347..4d8bf4589a 100644 --- a/src/core/metrics/sources/load_test.go +++ b/src/core/metrics/sources/load_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "testing" "github.com/nginx/agent/v2/src/core/metrics" diff --git a/src/core/metrics/sources/net_io_test.go b/src/core/metrics/sources/net_io_test.go index 5047b7624c..7bd15a0d45 100644 --- a/src/core/metrics/sources/net_io_test.go +++ b/src/core/metrics/sources/net_io_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "testing" "github.com/nginx/agent/v2/src/core/metrics" diff --git a/src/core/metrics/sources/nginx_oss_test.go b/src/core/metrics/sources/nginx_oss_test.go index b3ab2920c0..61dff74abd 100644 --- a/src/core/metrics/sources/nginx_oss_test.go +++ b/src/core/metrics/sources/nginx_oss_test.go @@ -11,7 +11,6 @@ import ( "context" "net/http" "net/http/httptest" - "testing" "github.com/nginx/agent/sdk/v2/proto" diff --git a/src/core/metrics/sources/nginx_process_test.go b/src/core/metrics/sources/nginx_process_test.go index 70b7001962..3d14e67959 100644 --- a/src/core/metrics/sources/nginx_process_test.go +++ b/src/core/metrics/sources/nginx_process_test.go @@ -9,7 +9,6 @@ package sources import ( "context" - "testing" "time" diff --git a/src/core/metrics/sources/nginx_static_test.go b/src/core/metrics/sources/nginx_static_test.go index 37b67947ba..c7a3d1432d 100644 --- a/src/core/metrics/sources/nginx_static_test.go +++ b/src/core/metrics/sources/nginx_static_test.go @@ -9,7 +9,6 @@ package sources import ( "context" - "testing" "github.com/nginx/agent/sdk/v2/proto" diff --git a/src/core/metrics/sources/nginx_worker_test.go b/src/core/metrics/sources/nginx_worker_test.go index 3dc7224e5b..795b27bd3e 100644 --- a/src/core/metrics/sources/nginx_worker_test.go +++ b/src/core/metrics/sources/nginx_worker_test.go @@ -9,7 +9,6 @@ package sources import ( "context" - "testing" "time" From 1f8cc5a2cb7ce90d8263ef16598f4efd37c4b3ce Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 14 Aug 2024 13:12:12 +0100 Subject: [PATCH 19/49] wip: buffer changes --- main.go | 6 +++++ src/plugins/metrics.go | 58 ++++++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/main.go b/main.go index 12debc3d34..2168c6a439 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,12 @@ var ( func main() { config.InitFlags(version, commit) + defer func() { + if err := recover(); err != nil { + log.Printf("Recovered: %v", err) + } + }() + config.RegisterRunner(func(cmd *cobra.Command, _ []string) { config.InitConfigurationFiles() diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index 58cd2fdb3c..f02065c8a9 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -67,6 +67,7 @@ func (m *Metrics) Init(pipeline core.MessagePipeInterface) { m.pipeline = pipeline m.ctx = pipeline.Context() go m.metricsGoroutine() + go m.drainBuffer(m.ctx) } func (m *Metrics) Close() { @@ -176,13 +177,38 @@ func (m *Metrics) metricsGoroutine() { } return case <-m.ticker.C: - stats := m.collectStats() - if bundlePayload := metrics.GenerateMetricsReportBundle(stats); bundlePayload != nil { + m.collectStats() + + if m.collectorsUpdate.Load() { + m.ticker = time.NewTicker(m.conf.AgentMetrics.CollectionInterval) + m.collectorsUpdate.Store(false) + } + + case err := <-m.errors: + log.Errorf("Error in metricsGoroutine %v", err) + } + } +} + +func (m *Metrics) drainBuffer(ctx context.Context) { + for { + // drain the buf, since our sources/collectors are all done, we can rely on buffer length + select { + case <-ctx.Done(): + log.Debug("context done in drainBuffer") + + err := ctx.Err() + if err != nil { + log.Errorf("error in done context collectStats %v", err) + } + return + case stats := <-m.buf: + if bundlePayload := metrics.GenerateMetricsReportBundle([]*metrics.StatsEntityWrapper{stats}); bundlePayload != nil { if m.conf.IsFeatureEnabled(agent_config.FeatureMetrics) || m.conf.IsFeatureEnabled(agent_config.FeatureMetricsThrottle) { m.pipeline.Process(core.NewMessage(core.MetricReport, bundlePayload)) } else { metricBuffer := make([]core.Payload, 0) - + switch bundle := bundlePayload.(type) { case *metrics.MetricsReportBundle: if len(bundle.Data) > 0 { @@ -198,19 +224,11 @@ func (m *Metrics) metricsGoroutine() { } } } - - if m.collectorsUpdate.Load() { - m.ticker = time.NewTicker(m.conf.AgentMetrics.CollectionInterval) - m.collectorsUpdate.Store(false) - } - - case err := <-m.errors: - log.Errorf("Error in metricsGoroutine %v", err) } } } -func (m *Metrics) collectStats() (stats []*metrics.StatsEntityWrapper) { +func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // set a timeout for a millisecond less than the collection interval ctx, cancel := context.WithTimeout(m.ctx, (m.interval - 1*time.Millisecond)) defer cancel() @@ -228,22 +246,6 @@ func (m *Metrics) collectStats() (stats []*metrics.StatsEntityWrapper) { // wait until all the collection go routines are done, which either context timeout or exit // wg.Wait() - for len(m.buf) > 0 { - // drain the buf, since our sources/collectors are all done, we can rely on buffer length - select { - case <-ctx.Done(): - log.Debugf("context done in %s collectStats", time.Since(start)) - - err := ctx.Err() - if err != nil { - log.Errorf("error in done context collectStats %v", err) - } - return - case stat := <-m.buf: - stats = append(stats, stat) - } - } - log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) return } From 336347fb2f7add555e09cc4ca53bdde57c227c95 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 14 Aug 2024 13:16:43 +0100 Subject: [PATCH 20/49] wip: buffer changes --- main.go | 8 +-- src/plugins/metrics.go | 2 +- .../nginx/agent/v2/src/plugins/metrics.go | 56 ++++++++++--------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/main.go b/main.go index 2168c6a439..50c9e2e590 100644 --- a/main.go +++ b/main.go @@ -34,10 +34,10 @@ func main() { config.InitFlags(version, commit) defer func() { - if err := recover(); err != nil { - log.Printf("Recovered: %v", err) - } - }() + if err := recover(); err != nil { + log.Printf("Recovered: %v", err) + } + }() config.RegisterRunner(func(cmd *cobra.Command, _ []string) { config.InitConfigurationFiles() diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index f02065c8a9..9f4389953a 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -208,7 +208,7 @@ func (m *Metrics) drainBuffer(ctx context.Context) { m.pipeline.Process(core.NewMessage(core.MetricReport, bundlePayload)) } else { metricBuffer := make([]core.Payload, 0) - + switch bundle := bundlePayload.(type) { case *metrics.MetricsReportBundle: if len(bundle.Data) > 0 { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index 58cd2fdb3c..9f4389953a 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -67,6 +67,7 @@ func (m *Metrics) Init(pipeline core.MessagePipeInterface) { m.pipeline = pipeline m.ctx = pipeline.Context() go m.metricsGoroutine() + go m.drainBuffer(m.ctx) } func (m *Metrics) Close() { @@ -176,8 +177,33 @@ func (m *Metrics) metricsGoroutine() { } return case <-m.ticker.C: - stats := m.collectStats() - if bundlePayload := metrics.GenerateMetricsReportBundle(stats); bundlePayload != nil { + m.collectStats() + + if m.collectorsUpdate.Load() { + m.ticker = time.NewTicker(m.conf.AgentMetrics.CollectionInterval) + m.collectorsUpdate.Store(false) + } + + case err := <-m.errors: + log.Errorf("Error in metricsGoroutine %v", err) + } + } +} + +func (m *Metrics) drainBuffer(ctx context.Context) { + for { + // drain the buf, since our sources/collectors are all done, we can rely on buffer length + select { + case <-ctx.Done(): + log.Debug("context done in drainBuffer") + + err := ctx.Err() + if err != nil { + log.Errorf("error in done context collectStats %v", err) + } + return + case stats := <-m.buf: + if bundlePayload := metrics.GenerateMetricsReportBundle([]*metrics.StatsEntityWrapper{stats}); bundlePayload != nil { if m.conf.IsFeatureEnabled(agent_config.FeatureMetrics) || m.conf.IsFeatureEnabled(agent_config.FeatureMetricsThrottle) { m.pipeline.Process(core.NewMessage(core.MetricReport, bundlePayload)) } else { @@ -198,19 +224,11 @@ func (m *Metrics) metricsGoroutine() { } } } - - if m.collectorsUpdate.Load() { - m.ticker = time.NewTicker(m.conf.AgentMetrics.CollectionInterval) - m.collectorsUpdate.Store(false) - } - - case err := <-m.errors: - log.Errorf("Error in metricsGoroutine %v", err) } } } -func (m *Metrics) collectStats() (stats []*metrics.StatsEntityWrapper) { +func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // set a timeout for a millisecond less than the collection interval ctx, cancel := context.WithTimeout(m.ctx, (m.interval - 1*time.Millisecond)) defer cancel() @@ -228,22 +246,6 @@ func (m *Metrics) collectStats() (stats []*metrics.StatsEntityWrapper) { // wait until all the collection go routines are done, which either context timeout or exit // wg.Wait() - for len(m.buf) > 0 { - // drain the buf, since our sources/collectors are all done, we can rely on buffer length - select { - case <-ctx.Done(): - log.Debugf("context done in %s collectStats", time.Since(start)) - - err := ctx.Err() - if err != nil { - log.Errorf("error in done context collectStats %v", err) - } - return - case stat := <-m.buf: - stats = append(stats, stat) - } - } - log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) return } From 83920de778e9d5c6d125a952446c0740d30468b8 Mon Sep 17 00:00:00 2001 From: dhurley Date: Wed, 14 Aug 2024 13:59:57 +0100 Subject: [PATCH 21/49] stuff --- src/core/pipe.go | 2 -- src/plugins/metrics.go | 4 ++-- .../vendor/github.com/nginx/agent/v2/src/core/pipe.go | 2 -- .../vendor/github.com/nginx/agent/v2/src/core/pipe.go | 2 -- .../vendor/github.com/nginx/agent/v2/src/plugins/metrics.go | 4 ++-- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/core/pipe.go b/src/core/pipe.go index 10bb0f6f0b..226876f27c 100644 --- a/src/core/pipe.go +++ b/src/core/pipe.go @@ -169,8 +169,6 @@ func (p *MessagePipe) Run() { p.bus.Publish(m.Topic(), m) } p.mu.Unlock() - default: - return } } } diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index 9f4389953a..1a7d86688c 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -230,8 +230,8 @@ func (m *Metrics) drainBuffer(ctx context.Context) { func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // set a timeout for a millisecond less than the collection interval - ctx, cancel := context.WithTimeout(m.ctx, (m.interval - 1*time.Millisecond)) - defer cancel() + ctx := context.Background() + // defer cancel() // locks the m.collectors to make sure it doesn't get deleted in the middle // of collection, as we will delete the old one if config changes. // maybe we can fine tune the lock later, but the collection has been very quick so far. diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go index 10bb0f6f0b..226876f27c 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -169,8 +169,6 @@ func (p *MessagePipe) Run() { p.bus.Publish(m.Topic(), m) } p.mu.Unlock() - default: - return } } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go index 10bb0f6f0b..226876f27c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -169,8 +169,6 @@ func (p *MessagePipe) Run() { p.bus.Publish(m.Topic(), m) } p.mu.Unlock() - default: - return } } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index 9f4389953a..1a7d86688c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -230,8 +230,8 @@ func (m *Metrics) drainBuffer(ctx context.Context) { func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // set a timeout for a millisecond less than the collection interval - ctx, cancel := context.WithTimeout(m.ctx, (m.interval - 1*time.Millisecond)) - defer cancel() + ctx := context.Background() + // defer cancel() // locks the m.collectors to make sure it doesn't get deleted in the middle // of collection, as we will delete the old one if config changes. // maybe we can fine tune the lock later, but the collection has been very quick so far. From 2cee3ccffc7a567f90b765c56a18d512d347fee0 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 11:10:42 +0100 Subject: [PATCH 22/49] removed wait group, fixed tests --- src/core/metrics/collectors/container.go | 10 ++-------- src/core/metrics/collectors/container_test.go | 8 ++++---- src/core/metrics/collectors/nginx.go | 7 ++----- src/core/metrics/collectors/nginx_test.go | 8 ++++---- .../metrics/collectors/source_mocks_test.go | 13 +++++-------- src/core/metrics/collectors/system.go | 8 ++------ src/core/metrics/collectors/system_test.go | 7 ++++--- src/core/metrics/metrics_util.go | 7 +++---- src/core/metrics/sources/container_cpu.go | 4 +--- src/core/metrics/sources/container_cpu_test.go | 2 +- src/core/metrics/sources/container_mem.go | 4 +--- src/core/metrics/sources/container_mem_test.go | 5 +---- src/core/metrics/sources/cpu.go | 3 +-- src/core/metrics/sources/cpu_test.go | 18 ++++++------------ src/core/metrics/sources/disk.go | 4 +--- src/core/metrics/sources/disk_io.go | 3 +-- src/core/metrics/sources/disk_io_test.go | 5 +---- src/core/metrics/sources/disk_test.go | 5 +---- src/core/metrics/sources/load.go | 3 +-- src/core/metrics/sources/load_test.go | 5 +---- src/core/metrics/sources/mem.go | 3 +-- src/core/metrics/sources/mem_test.go | 2 +- src/core/metrics/sources/net_io.go | 2 +- src/core/metrics/sources/net_io_test.go | 2 +- src/core/metrics/sources/nginx_access_log.go | 2 +- src/core/metrics/sources/nginx_error_log.go | 2 +- src/core/metrics/sources/nginx_oss.go | 2 +- src/core/metrics/sources/nginx_oss_test.go | 2 +- src/core/metrics/sources/nginx_plus.go | 2 +- src/core/metrics/sources/nginx_plus_test.go | 5 ++--- src/core/metrics/sources/nginx_process.go | 3 +-- src/core/metrics/sources/nginx_process_test.go | 6 +++--- src/core/metrics/sources/nginx_static.go | 3 +-- src/core/metrics/sources/nginx_static_test.go | 2 +- src/core/metrics/sources/nginx_worker.go | 2 +- src/core/metrics/sources/nginx_worker_test.go | 4 ++-- src/core/metrics/sources/swap.go | 3 +-- src/core/metrics/sources/swap_test.go | 2 +- src/extensions/leak_test.go | 18 ------------------ .../monitoring/collector/collector.go | 3 +-- .../monitoring/collector/nap.go | 3 +-- .../monitoring/collector/nap_test.go | 2 +- .../monitoring/manager/manager.go | 7 ++----- .../monitoring/processor/processor.go | 5 +---- .../monitoring/processor/processor_test.go | 5 +---- src/plugins/metrics.go | 6 +----- .../src/core/metrics/collectors/container.go | 10 ++-------- .../v2/src/core/metrics/collectors/nginx.go | 7 ++----- .../v2/src/core/metrics/collectors/system.go | 8 ++------ .../agent/v2/src/core/metrics/metrics_util.go | 7 +++---- .../src/core/metrics/sources/container_cpu.go | 4 +--- .../src/core/metrics/sources/container_mem.go | 4 +--- .../agent/v2/src/core/metrics/sources/cpu.go | 3 +-- .../agent/v2/src/core/metrics/sources/disk.go | 4 +--- .../v2/src/core/metrics/sources/disk_io.go | 3 +-- .../agent/v2/src/core/metrics/sources/load.go | 3 +-- .../agent/v2/src/core/metrics/sources/mem.go | 3 +-- .../v2/src/core/metrics/sources/net_io.go | 2 +- .../core/metrics/sources/nginx_access_log.go | 2 +- .../core/metrics/sources/nginx_error_log.go | 2 +- .../v2/src/core/metrics/sources/nginx_oss.go | 2 +- .../v2/src/core/metrics/sources/nginx_plus.go | 2 +- .../src/core/metrics/sources/nginx_process.go | 3 +-- .../src/core/metrics/sources/nginx_static.go | 3 +-- .../src/core/metrics/sources/nginx_worker.go | 2 +- .../agent/v2/src/core/metrics/sources/swap.go | 3 +-- .../monitoring/collector/collector.go | 3 +-- .../monitoring/collector/nap.go | 3 +-- .../monitoring/manager/manager.go | 7 ++----- .../monitoring/processor/processor.go | 5 +---- .../nginx/agent/v2/src/plugins/metrics.go | 6 +----- 71 files changed, 104 insertions(+), 224 deletions(-) delete mode 100644 src/extensions/leak_test.go diff --git a/src/core/metrics/collectors/container.go b/src/core/metrics/collectors/container.go index bcb2b4dbdb..4e5439a21b 100644 --- a/src/core/metrics/collectors/container.go +++ b/src/core/metrics/collectors/container.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" log "github.com/sirupsen/logrus" @@ -46,17 +45,12 @@ func NewContainerCollector(env core.Environment, conf *config.Config) *Container } func (c *ContainerCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf - // wg := &sync.WaitGroup{} for _, containerSource := range c.sources { - // wg.Add(1) - go containerSource.Collect(ctx, nil, c.buf) + go containerSource.Collect(ctx, c.buf) } - // wg.Wait() } -func (c *ContainerCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() c.collectMetrics(ctx) diff --git a/src/core/metrics/collectors/container_test.go b/src/core/metrics/collectors/container_test.go index c013e012d9..1ef4636377 100644 --- a/src/core/metrics/collectors/container_test.go +++ b/src/core/metrics/collectors/container_test.go @@ -11,6 +11,7 @@ import ( "context" "reflect" "testing" + "time" "github.com/stretchr/testify/assert" @@ -61,15 +62,14 @@ func TestContainerCollector_Collect(t *testing.T) { } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) - channel := make(chan *metrics.StatsEntityWrapper) - go containerCollector.Collect(ctx, nil, channel) + go containerCollector.Collect(ctx, channel) containerCollector.buf <- &metrics.StatsEntityWrapper{Type: proto.MetricsReport_SYSTEM, Data: &proto.StatsEntity{Dimensions: []*proto.Dimension{{Name: "new_dim", Value: "123"}}}} actual := <-channel + time.Sleep(100 * time.Millisecond) + mockSource1.AssertExpectations(t) mockSource2.AssertExpectations(t) diff --git a/src/core/metrics/collectors/nginx.go b/src/core/metrics/collectors/nginx.go index eaf900a971..b6355e6929 100644 --- a/src/core/metrics/collectors/nginx.go +++ b/src/core/metrics/collectors/nginx.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" agent_config "github.com/nginx/agent/sdk/v2/agent/config" "github.com/nginx/agent/v2/src/core" @@ -73,14 +72,12 @@ func buildSources(dimensions *metrics.CommonDim, binary core.NginxBinary, collec } func (c *NginxCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf for _, nginxSource := range c.sources { - go nginxSource.Collect(ctx, nil, c.buf) + go nginxSource.Collect(ctx, c.buf) } } -func (c *NginxCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) for { select { diff --git a/src/core/metrics/collectors/nginx_test.go b/src/core/metrics/collectors/nginx_test.go index 5eb64d797b..0b08fe9462 100644 --- a/src/core/metrics/collectors/nginx_test.go +++ b/src/core/metrics/collectors/nginx_test.go @@ -11,6 +11,7 @@ import ( "context" "reflect" "testing" + "time" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -172,10 +173,9 @@ func TestNginxCollector_Collect(t *testing.T) { } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) - go nginxCollector.Collect(ctx, nil, make(chan<- *metrics.StatsEntityWrapper)) - // wg.Wait() + go nginxCollector.Collect(ctx, make(chan<- *metrics.StatsEntityWrapper)) + + time.Sleep(100 * time.Millisecond) mockNginxSource1.AssertExpectations(t) mockNginxSource2.AssertExpectations(t) diff --git a/src/core/metrics/collectors/source_mocks_test.go b/src/core/metrics/collectors/source_mocks_test.go index 4b656e847e..bff1e1683f 100644 --- a/src/core/metrics/collectors/source_mocks_test.go +++ b/src/core/metrics/collectors/source_mocks_test.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" "github.com/nginx/agent/v2/src/core/metrics" "github.com/stretchr/testify/mock" @@ -17,7 +16,7 @@ import ( func GetNginxSourceMock() *NginxSourceMock { mockSource := new(NginxSourceMock) - mockSource.On("Collect", mock.Anything, mock.Anything, mock.Anything).Once() + mockSource.On("Collect", mock.Anything, mock.Anything).Once() return mockSource } @@ -25,9 +24,8 @@ type NginxSourceMock struct { mock.Mock } -func (m *NginxSourceMock) Collect(ctx context.Context, wg *sync.WaitGroup, statsChannel chan<- *metrics.StatsEntityWrapper) { - m.Called(ctx) - // wg.Done() +func (m *NginxSourceMock) Collect(ctx context.Context, statsChannel chan<- *metrics.StatsEntityWrapper) { + m.Called(ctx, statsChannel) } func (m *NginxSourceMock) Update(dimensions *metrics.CommonDim, collectorConf *metrics.NginxCollectorConfig) { @@ -42,7 +40,6 @@ type SourceMock struct { mock.Mock } -func (m *SourceMock) Collect(ctx context.Context, wg *sync.WaitGroup, statsChannel chan<- *metrics.StatsEntityWrapper) { - m.Called(ctx) - // wg.Done() +func (m *SourceMock) Collect(ctx context.Context, statsChannel chan<- *metrics.StatsEntityWrapper) { + m.Called(ctx, statsChannel) } diff --git a/src/core/metrics/collectors/system.go b/src/core/metrics/collectors/system.go index 6e5a1573e5..cd91e7b1c7 100644 --- a/src/core/metrics/collectors/system.go +++ b/src/core/metrics/collectors/system.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" @@ -57,15 +56,12 @@ func NewSystemCollector(env core.Environment, conf *config.Config) *SystemCollec } func (c *SystemCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf for _, systemSource := range c.sources { - go systemSource.Collect(ctx, nil, c.buf) + go systemSource.Collect(ctx, c.buf) } } -func (c *SystemCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() +func (c *SystemCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/src/core/metrics/collectors/system_test.go b/src/core/metrics/collectors/system_test.go index 694d8577c5..a965548cad 100644 --- a/src/core/metrics/collectors/system_test.go +++ b/src/core/metrics/collectors/system_test.go @@ -11,6 +11,7 @@ import ( "context" "reflect" "testing" + "time" "github.com/stretchr/testify/assert" @@ -93,15 +94,15 @@ func TestSystemCollector_Collect(t *testing.T) { } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper) - go systemCollector.Collect(ctx, nil, channel) + go systemCollector.Collect(ctx, channel) systemCollector.buf <- &metrics.StatsEntityWrapper{Type: proto.MetricsReport_SYSTEM, Data: &proto.StatsEntity{Dimensions: []*proto.Dimension{{Name: "new_dim", Value: "123"}}}} actual := <-channel + time.Sleep(100 * time.Millisecond) + mockSource1.AssertExpectations(t) mockSource2.AssertExpectations(t) diff --git a/src/core/metrics/metrics_util.go b/src/core/metrics/metrics_util.go index 43b2ea7381..4128c87e5e 100644 --- a/src/core/metrics/metrics_util.go +++ b/src/core/metrics/metrics_util.go @@ -11,7 +11,6 @@ import ( "context" "math" "sort" - "sync" "time" "github.com/nginx/agent/sdk/v2/proto" @@ -22,16 +21,16 @@ import ( ) type Collector interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) UpdateConfig(config *config.Config) } type Source interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) } type NginxSource interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) Update(dimensions *CommonDim, collectorConf *NginxCollectorConfig) Stop() } diff --git a/src/core/metrics/sources/container_cpu.go b/src/core/metrics/sources/container_cpu.go index 4ef7eb6aa5..998b1653fc 100644 --- a/src/core/metrics/sources/container_cpu.go +++ b/src/core/metrics/sources/container_cpu.go @@ -13,7 +13,6 @@ import ( "path" "strconv" "strings" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -47,9 +46,8 @@ func NewContainerCPUSource(namespace string, basePath string) *ContainerCPU { return &ContainerCPU{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, CpuGroup}} } -func (c *ContainerCPU) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerCPU) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container CPU metrics") - // defer wg.Done() containerStats := map[string]float64{} diff --git a/src/core/metrics/sources/container_cpu_test.go b/src/core/metrics/sources/container_cpu_test.go index 903a161684..ba054a577a 100644 --- a/src/core/metrics/sources/container_cpu_test.go +++ b/src/core/metrics/sources/container_cpu_test.go @@ -121,7 +121,7 @@ func TestContainerCPUSource(t *testing.T) { ctx := context.TODO() containerCPUSource := NewContainerCPUSource("container", test.basePath) - go containerCPUSource.Collect(ctx, nil, actual) + go containerCPUSource.Collect(ctx, actual) select { case result := <-actual: diff --git a/src/core/metrics/sources/container_mem.go b/src/core/metrics/sources/container_mem.go index 2db6b6d81a..086ac5b345 100644 --- a/src/core/metrics/sources/container_mem.go +++ b/src/core/metrics/sources/container_mem.go @@ -13,7 +13,6 @@ import ( "path" "strconv" "strings" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -40,9 +39,8 @@ func NewContainerMemorySource(namespace string, basePath string) *ContainerMemor return &ContainerMemory{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}} } -func (c *ContainerMemory) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container memory metrics") - // defer wg.Done() var containerStats map[string]float64 diff --git a/src/core/metrics/sources/container_mem_test.go b/src/core/metrics/sources/container_mem_test.go index df892bcfd8..096b8c65e2 100644 --- a/src/core/metrics/sources/container_mem_test.go +++ b/src/core/metrics/sources/container_mem_test.go @@ -63,12 +63,9 @@ func TestContainerMemorySource(t *testing.T) { t.Run(test.name, func(tt *testing.T) { actual := make(chan *metrics.StatsEntityWrapper, 1) ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) containerMemorySource := NewContainerMemorySource("container", test.basePath) - go containerMemorySource.Collect(ctx, nil, actual) - // wg.Wait() + go containerMemorySource.Collect(ctx, actual) select { case result := <-actual: diff --git a/src/core/metrics/sources/cpu.go b/src/core/metrics/sources/cpu.go index 080b192314..f7bb0046ca 100644 --- a/src/core/metrics/sources/cpu.go +++ b/src/core/metrics/sources/cpu.go @@ -69,8 +69,7 @@ func diffTimeStat(t1, t2 cpu.TimesStat) cpu.TimesStat { } } -func (c *CPUTimes) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() +func (c *CPUTimes) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var simpleMetrics []*proto.SimpleMetric if c.isDocker { dockerCpuPercentages, err := c.cgroupCPUSource.Percentages() diff --git a/src/core/metrics/sources/cpu_test.go b/src/core/metrics/sources/cpu_test.go index 21c0dca0f3..d4582cd04d 100644 --- a/src/core/metrics/sources/cpu_test.go +++ b/src/core/metrics/sources/cpu_test.go @@ -103,11 +103,8 @@ func TestCPUTimesCollect_VM(t *testing.T) { } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, nil, channel) - // wg.Wait() + cpuTimes.Collect(ctx, channel) actual := <-channel @@ -146,11 +143,9 @@ func TestCPUTimesCollect_VM(t *testing.T) { } ctx = context.TODO() - // wg = &sync.WaitGroup{} - // wg.Add(1) + channel = make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, nil, channel) - // wg.Wait() + cpuTimes.Collect(ctx, channel) actual = <-channel @@ -189,11 +184,10 @@ func TestCPUTimesCollect_Container(t *testing.T) { cgroup.CpuStatsPath = localDirectory + "/testdata/proc/stat" ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) + channel := make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, nil, channel) - // wg.Wait() + cpuTimes.Collect(ctx, channel) + actual := <-channel actualMetricNames := []string{} diff --git a/src/core/metrics/sources/disk.go b/src/core/metrics/sources/disk.go index 7203fe1be2..98a3847a2d 100644 --- a/src/core/metrics/sources/disk.go +++ b/src/core/metrics/sources/disk.go @@ -10,7 +10,6 @@ package sources import ( "context" "fmt" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -32,8 +31,7 @@ func NewDiskSource(namespace string, env core.Environment) *Disk { return &Disk{NewMetricSourceLogger(), &namedMetric{namespace, "disk"}, disks, env} } -func (c *Disk) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() +func (c *Disk) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { for _, part := range c.disks { if part.Device == "" || part.FsType == "" { continue diff --git a/src/core/metrics/sources/disk_io.go b/src/core/metrics/sources/disk_io.go index 98de097092..3a8f692275 100644 --- a/src/core/metrics/sources/disk_io.go +++ b/src/core/metrics/sources/disk_io.go @@ -37,8 +37,7 @@ func NewDiskIOSource(namespace string, env core.Environment) *DiskIO { return &DiskIO{namedMetric: &namedMetric{namespace, "io"}, env: env, diskIOStatsFunc: disk.IOCountersWithContext} } -func (dio *DiskIO) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() +func (dio *DiskIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { dio.init.Do(func() { dio.diskDevs, _ = dio.env.DiskDevices() dio.diskIOStats = dio.newDiskIOCounters(ctx, dio.diskDevs) diff --git a/src/core/metrics/sources/disk_io_test.go b/src/core/metrics/sources/disk_io_test.go index e977fcfb0b..3a4080e7d9 100644 --- a/src/core/metrics/sources/disk_io_test.go +++ b/src/core/metrics/sources/disk_io_test.go @@ -38,11 +38,8 @@ func TestDiskIOCollect(t *testing.T) { } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - diskio.Collect(ctx, nil, channel) - // wg.Wait() + diskio.Collect(ctx, channel) actual := <-channel diff --git a/src/core/metrics/sources/disk_test.go b/src/core/metrics/sources/disk_test.go index 37233ee029..b35d33d48c 100644 --- a/src/core/metrics/sources/disk_test.go +++ b/src/core/metrics/sources/disk_test.go @@ -34,11 +34,8 @@ func TestDiskCollect(t *testing.T) { disk := NewDiskSource(namespace, env) ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - disk.Collect(ctx, nil, channel) - // wg.Wait() + disk.Collect(ctx, channel) actual := <-channel diff --git a/src/core/metrics/sources/load.go b/src/core/metrics/sources/load.go index 8615636937..7a123dc136 100644 --- a/src/core/metrics/sources/load.go +++ b/src/core/metrics/sources/load.go @@ -10,7 +10,6 @@ package sources import ( "context" "fmt" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -28,7 +27,7 @@ func NewLoadSource(namespace string) *Load { return &Load{logger: NewMetricSourceLogger(), namedMetric: &namedMetric{namespace, "load"}, avgStatsFunc: load.Avg} } -func (c *Load) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *Load) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() loadStats, err := c.avgStatsFunc() if err != nil { diff --git a/src/core/metrics/sources/load_test.go b/src/core/metrics/sources/load_test.go index 4d8bf4589a..e1fa43b5c2 100644 --- a/src/core/metrics/sources/load_test.go +++ b/src/core/metrics/sources/load_test.go @@ -35,11 +35,8 @@ func TestLoadCollect(t *testing.T) { } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - loadSource.Collect(ctx, nil, channel) - // wg.Wait() + loadSource.Collect(ctx, channel) actual := <-channel diff --git a/src/core/metrics/sources/mem.go b/src/core/metrics/sources/mem.go index f586252157..6a0fab2365 100644 --- a/src/core/metrics/sources/mem.go +++ b/src/core/metrics/sources/mem.go @@ -11,7 +11,6 @@ import ( "context" "fmt" "os" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -38,7 +37,7 @@ func NewVirtualMemorySource(namespace string, env core.Environment) *VirtualMemo return &VirtualMemory{NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}, statFunc} } -func (c *VirtualMemory) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *VirtualMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() memstats, err := c.statFunc(ctx) if err != nil { diff --git a/src/core/metrics/sources/mem_test.go b/src/core/metrics/sources/mem_test.go index 6bfe2a4254..bc1c26f28f 100644 --- a/src/core/metrics/sources/mem_test.go +++ b/src/core/metrics/sources/mem_test.go @@ -59,7 +59,7 @@ func TestVirtualMemoryCollect(t *testing.T) { // wg := &sync.WaitGroup{} // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 1) - go virtualMemorySource.Collect(ctx, nil, channel) + go virtualMemorySource.Collect(ctx, channel) // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/net_io.go b/src/core/metrics/sources/net_io.go index 41f6c0a6a9..2df0e985bf 100644 --- a/src/core/metrics/sources/net_io.go +++ b/src/core/metrics/sources/net_io.go @@ -46,7 +46,7 @@ func NewNetIOSource(namespace string, env core.Environment) *NetIO { } } -func (nio *NetIO) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (nio *NetIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() nio.init.Do(func() { ifs, err := nio.newNetInterfaces(ctx) diff --git a/src/core/metrics/sources/net_io_test.go b/src/core/metrics/sources/net_io_test.go index 7bd15a0d45..1dbea21fd0 100644 --- a/src/core/metrics/sources/net_io_test.go +++ b/src/core/metrics/sources/net_io_test.go @@ -51,7 +51,7 @@ func TestNetIOCollect(t *testing.T) { // wg := &sync.WaitGroup{} // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - nioSource.Collect(ctx, nil, channel) + nioSource.Collect(ctx, channel) // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/nginx_access_log.go b/src/core/metrics/sources/nginx_access_log.go index a4d01e193b..53026a0ff8 100644 --- a/src/core/metrics/sources/nginx_access_log.go +++ b/src/core/metrics/sources/nginx_access_log.go @@ -108,7 +108,7 @@ func NewNginxAccessLog( return nginxAccessLog } -func (c *NginxAccessLog) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxAccessLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() c.collectLogStats(ctx, m) } diff --git a/src/core/metrics/sources/nginx_error_log.go b/src/core/metrics/sources/nginx_error_log.go index b05dcdef6e..57f04395a6 100644 --- a/src/core/metrics/sources/nginx_error_log.go +++ b/src/core/metrics/sources/nginx_error_log.go @@ -101,7 +101,7 @@ func NewNginxErrorLog( return nginxErrorLog } -func (c *NginxErrorLog) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxErrorLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() c.collectLogStats(ctx, m) diff --git a/src/core/metrics/sources/nginx_oss.go b/src/core/metrics/sources/nginx_oss.go index a4d9c5b3c9..903bb944c8 100644 --- a/src/core/metrics/sources/nginx_oss.go +++ b/src/core/metrics/sources/nginx_oss.go @@ -34,7 +34,7 @@ func NewNginxOSS(baseDimensions *metrics.CommonDim, namespace, stubStatus string return &NginxOSS{baseDimensions: baseDimensions, stubStatus: stubStatus, namedMetric: &namedMetric{namespace: namespace}, logger: NewMetricSourceLogger()} } -func (c *NginxOSS) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxOSS) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() var err error c.init.Do(func() { diff --git a/src/core/metrics/sources/nginx_oss_test.go b/src/core/metrics/sources/nginx_oss_test.go index 61dff74abd..5bbb7af938 100644 --- a/src/core/metrics/sources/nginx_oss_test.go +++ b/src/core/metrics/sources/nginx_oss_test.go @@ -111,7 +111,7 @@ Reading: 0 Writing: 1 Waiting: 0 ctx := context.TODO() // wg := &sync.WaitGroup{} // wg.Add(1) - go c.Collect(ctx, nil, test.m) + go c.Collect(ctx, test.m) // wg.Wait() statEntity := <-test.m assert.Len(tt, statEntity.Data.Simplemetrics, len(test.expectedMetrics)) diff --git a/src/core/metrics/sources/nginx_plus.go b/src/core/metrics/sources/nginx_plus.go index baefbc9f16..fa6e08770b 100644 --- a/src/core/metrics/sources/nginx_plus.go +++ b/src/core/metrics/sources/nginx_plus.go @@ -85,7 +85,7 @@ func NewNginxPlus(baseDimensions *metrics.CommonDim, nginxNamespace, plusNamespa return &NginxPlus{baseDimensions: baseDimensions, nginxNamespace: nginxNamespace, plusNamespace: plusNamespace, plusAPI: plusAPI, clientVersion: clientVersion, logger: NewMetricSourceLogger()} } -func (c *NginxPlus) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() c.init.Do(func() { latestAPIVersion, err := c.getLatestAPIVersion(ctx, c.plusAPI) diff --git a/src/core/metrics/sources/nginx_plus_test.go b/src/core/metrics/sources/nginx_plus_test.go index 86e8c28001..92b4a0329a 100644 --- a/src/core/metrics/sources/nginx_plus_test.go +++ b/src/core/metrics/sources/nginx_plus_test.go @@ -12,7 +12,6 @@ import ( "fmt" "net/http" "net/http/httptest" - "sync" "testing" "github.com/nginx/agent/sdk/v2/proto" @@ -565,7 +564,7 @@ type FakeNginxPlus struct { } // Collect is fake collector that hard codes a stats struct response to avoid dependency on external NGINX Plus api -func (f *FakeNginxPlus) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (f *FakeNginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() f.baseDimensions.NginxType = "plus" @@ -984,7 +983,7 @@ func TestNginxPlus_Collect(t *testing.T) { f := &FakeNginxPlus{NewNginxPlus(test.baseDimensions, "nginx", "plus", "", 6)} // wg := &sync.WaitGroup{} // wg.Add(1) - go f.Collect(ctx, nil, test.m) + go f.Collect(ctx, test.m) // wg.Wait() instanceMetrics := <-test.m diff --git a/src/core/metrics/sources/nginx_process.go b/src/core/metrics/sources/nginx_process.go index d432de436c..e85a8e2171 100644 --- a/src/core/metrics/sources/nginx_process.go +++ b/src/core/metrics/sources/nginx_process.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -44,7 +43,7 @@ func (c *NginxProcess) getNginxCount() float64 { return 0.0 } -func (c *NginxProcess) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxProcess) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() l := &namedMetric{namespace: PlusNamespace, group: ""} diff --git a/src/core/metrics/sources/nginx_process_test.go b/src/core/metrics/sources/nginx_process_test.go index 3d14e67959..b54921cc79 100644 --- a/src/core/metrics/sources/nginx_process_test.go +++ b/src/core/metrics/sources/nginx_process_test.go @@ -60,7 +60,7 @@ func TestNginxProcessCollector_Collect_Process(t *testing.T) { // wg := sync.WaitGroup{} // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, nil, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) @@ -104,7 +104,7 @@ func TestNginxProcessCollector_Collect_NoProcess(t *testing.T) { // wg := sync.WaitGroup{} // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, nil, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) @@ -151,7 +151,7 @@ func TestNginxProcessCollector_Collect_NotPlus(t *testing.T) { // wg := sync.WaitGroup{} // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, nil, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) diff --git a/src/core/metrics/sources/nginx_static.go b/src/core/metrics/sources/nginx_static.go index 12ec6aca76..cd32b25ae8 100644 --- a/src/core/metrics/sources/nginx_static.go +++ b/src/core/metrics/sources/nginx_static.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "github.com/nginx/agent/v2/src/core/metrics" log "github.com/sirupsen/logrus" @@ -26,7 +25,7 @@ func NewNginxStatic(baseDimensions *metrics.CommonDim, namespace string) *NginxS return &NginxStatic{baseDimensions: baseDimensions, namedMetric: &namedMetric{namespace: namespace}} } -func (c *NginxStatic) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxStatic) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() SendNginxDownStatus(ctx, c.baseDimensions.ToDimensions(), m) diff --git a/src/core/metrics/sources/nginx_static_test.go b/src/core/metrics/sources/nginx_static_test.go index c7a3d1432d..7c8e77b124 100644 --- a/src/core/metrics/sources/nginx_static_test.go +++ b/src/core/metrics/sources/nginx_static_test.go @@ -66,7 +66,7 @@ func TestNginxStatic_Collect(t *testing.T) { ctx := context.TODO() // wg := &sync.WaitGroup{} // wg.Add(1) - go c.Collect(ctx, nil, test.m) + go c.Collect(ctx, test.m) // wg.Wait() statEntity := <-test.m assert.Len(tt, statEntity.Data.Simplemetrics, len(expectedMetrics)) diff --git a/src/core/metrics/sources/nginx_worker.go b/src/core/metrics/sources/nginx_worker.go index 514be451a3..3f0324d8e1 100644 --- a/src/core/metrics/sources/nginx_worker.go +++ b/src/core/metrics/sources/nginx_worker.go @@ -49,7 +49,7 @@ func NewNginxWorker(baseDimensions *metrics.CommonDim, } } -func (c *NginxWorker) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxWorker) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var err error // defer wg.Done() childProcs := c.binary.GetChildProcesses() diff --git a/src/core/metrics/sources/nginx_worker_test.go b/src/core/metrics/sources/nginx_worker_test.go index 795b27bd3e..fad25db24d 100644 --- a/src/core/metrics/sources/nginx_worker_test.go +++ b/src/core/metrics/sources/nginx_worker_test.go @@ -80,7 +80,7 @@ func TestNginxWorkerCollector(t *testing.T) { // wg := sync.WaitGroup{} // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, nil, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockClient.AssertNumberOfCalls(t, "GetWorkerStats", 2) @@ -123,7 +123,7 @@ func TestNginxWorkerCollector(t *testing.T) { // wg.Add(1) - go n.Collect(ctx, nil, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockClient.AssertNumberOfCalls(t, "GetWorkerStats", 3) diff --git a/src/core/metrics/sources/swap.go b/src/core/metrics/sources/swap.go index a617f91738..095234bcf9 100644 --- a/src/core/metrics/sources/swap.go +++ b/src/core/metrics/sources/swap.go @@ -12,7 +12,6 @@ import ( "fmt" "math/big" "os" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -49,7 +48,7 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { return &Swap{NewMetricSourceLogger(), &namedMetric{namespace, "swap"}, statFunc} } -func (c *Swap) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *Swap) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() swapStats, err := c.statFunc() if err != nil { diff --git a/src/core/metrics/sources/swap_test.go b/src/core/metrics/sources/swap_test.go index 7ecce5d3af..da079d5029 100644 --- a/src/core/metrics/sources/swap_test.go +++ b/src/core/metrics/sources/swap_test.go @@ -92,7 +92,7 @@ func TestSwapSource_Collect(t *testing.T) { } // wg := &sync.WaitGroup{} // wg.Add(1) - go c.Collect(ctx, nil, test.m) + go c.Collect(ctx, test.m) // wg.Wait() statsEntity := <-test.m diff --git a/src/extensions/leak_test.go b/src/extensions/leak_test.go deleted file mode 100644 index dc97c1c105..0000000000 --- a/src/extensions/leak_test.go +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) F5, Inc. - * - * This source code is licensed under the Apache License, Version 2.0 license found in the - * LICENSE file in the root directory of this source tree. - */ - -package extensions - -import ( - "testing" - - "go.uber.org/goleak" -) - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -} diff --git a/src/extensions/nginx-app-protect/monitoring/collector/collector.go b/src/extensions/nginx-app-protect/monitoring/collector/collector.go index 59f78c2fe6..dd18ccec2d 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/collector.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/collector.go @@ -9,7 +9,6 @@ package collector import ( "context" - "sync" "github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring" ) @@ -18,5 +17,5 @@ import ( // collect Raw Log data from WAF Instances. type Collector interface { // Collect starts collecting on collect chan until ctx.Done() chan gets a signal - Collect(ctx context.Context, _ *sync.WaitGroup, collect chan<- *monitoring.RawLog) + Collect(ctx context.Context, collect chan<- *monitoring.RawLog) } diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap.go b/src/extensions/nginx-app-protect/monitoring/collector/nap.go index 816265d058..87d3953bcd 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap.go @@ -10,7 +10,6 @@ package collector import ( "context" "fmt" - "sync" "github.com/sirupsen/logrus" "gopkg.in/mcuadros/go-syslog.v2" @@ -84,7 +83,7 @@ func newSyslogServer(logger *logrus.Entry, ip string, port int) (*syslogServer, } // Collect starts collecting on collect chan until done chan gets a signal. -func (nap *NAPCollector) Collect(ctx context.Context, _ *sync.WaitGroup, collect chan<- *monitoring.RawLog) { +func (nap *NAPCollector) Collect(ctx context.Context, collect chan<- *monitoring.RawLog) { // defer wg.Done() nap.logger.Infof("Starting collection for %s", monitoring.NAP) diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go index 6227a98c19..5c6c014786 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go @@ -90,7 +90,7 @@ func TestNAPCollect(t *testing.T) { // wg := &sync.WaitGroup{} // wg.Add(1) - go waf.Collect(ctx, nil, collect) + go waf.Collect(ctx, collect) logwriter, err = syslog.Dial("tcp4", testIP+":"+strconv.Itoa(testPort), syslog.LOG_INFO|syslog.LOG_USER, "test") if err != nil { diff --git a/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/src/extensions/nginx-app-protect/monitoring/manager/manager.go index 4fbd3f4923..c22eedcc52 100644 --- a/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -151,16 +151,13 @@ func (s *Manager) Run(ctx context.Context) { chtx, cancel := context.WithCancel(ctx) defer cancel() - // waitGroup := &sync.WaitGroup{} - // waitGroup.Add(2) - go s.collector.Collect(chtx, nil, s.collectChan) - go s.processor.Process(chtx, nil, s.collectChan, s.processorChan) + go s.collector.Collect(chtx, s.collectChan) + go s.processor.Process(chtx, s.collectChan, s.processorChan) <-ctx.Done() s.logger.Infof("Received Context cancellation, %s is wrapping up...", componentName) - // waitGroup.Wait() s.logger.Infof("Context cancellation, %s wrapped up...", componentName) } diff --git a/src/extensions/nginx-app-protect/monitoring/processor/processor.go b/src/extensions/nginx-app-protect/monitoring/processor/processor.go index fe86feaea3..0c5324a875 100644 --- a/src/extensions/nginx-app-protect/monitoring/processor/processor.go +++ b/src/extensions/nginx-app-protect/monitoring/processor/processor.go @@ -121,13 +121,10 @@ func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int } // Process processes the raw log entries from collected chan into Security Events on processed chan. -func (c *Client) Process(ctx context.Context, _ *sync.WaitGroup, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - // defer wg.Done() - +func (c *Client) Process(ctx context.Context, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { c.logger.Info("Setting up Processor") for id := 1; id <= c.workers; id++ { - // wg.Add(1) go c.processorWorker(ctx, nil, id, collected, processed) } diff --git a/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go b/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go index b10eab5fe8..4b8cde67b5 100644 --- a/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go +++ b/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go @@ -1214,11 +1214,8 @@ func TestNAPProcess(t *testing.T) { t.Fatalf("Could not get a Processor Client: %s", err) } - // wg := &sync.WaitGroup{} - - // wg.Add(1) // Start Processor - go p.Process(ctx, nil, collect, processed) + go p.Process(ctx, collect, processed) // Briefly sleep so map can be reconciled before event is collected // and processed diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index 1a7d86688c..f9a6b381d5 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -237,14 +237,10 @@ func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // maybe we can fine tune the lock later, but the collection has been very quick so far. m.collectorsMutex.Lock() defer m.collectorsMutex.Unlock() - // wg := &sync.WaitGroup{} start := time.Now() for _, s := range m.collectors { - // wg.Add(1) - go s.Collect(ctx, nil, m.buf) + go s.Collect(ctx, m.buf) } - // wait until all the collection go routines are done, which either context timeout or exit - // wg.Wait() log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) return diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go index bcb2b4dbdb..4e5439a21b 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" log "github.com/sirupsen/logrus" @@ -46,17 +45,12 @@ func NewContainerCollector(env core.Environment, conf *config.Config) *Container } func (c *ContainerCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf - // wg := &sync.WaitGroup{} for _, containerSource := range c.sources { - // wg.Add(1) - go containerSource.Collect(ctx, nil, c.buf) + go containerSource.Collect(ctx, c.buf) } - // wg.Wait() } -func (c *ContainerCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() c.collectMetrics(ctx) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go index eaf900a971..b6355e6929 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" agent_config "github.com/nginx/agent/sdk/v2/agent/config" "github.com/nginx/agent/v2/src/core" @@ -73,14 +72,12 @@ func buildSources(dimensions *metrics.CommonDim, binary core.NginxBinary, collec } func (c *NginxCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf for _, nginxSource := range c.sources { - go nginxSource.Collect(ctx, nil, c.buf) + go nginxSource.Collect(ctx, c.buf) } } -func (c *NginxCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) for { select { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go index 6e5a1573e5..cd91e7b1c7 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" @@ -57,15 +56,12 @@ func NewSystemCollector(env core.Environment, conf *config.Config) *SystemCollec } func (c *SystemCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf for _, systemSource := range c.sources { - go systemSource.Collect(ctx, nil, c.buf) + go systemSource.Collect(ctx, c.buf) } } -func (c *SystemCollector) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() +func (c *SystemCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go index 43b2ea7381..4128c87e5e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go @@ -11,7 +11,6 @@ import ( "context" "math" "sort" - "sync" "time" "github.com/nginx/agent/sdk/v2/proto" @@ -22,16 +21,16 @@ import ( ) type Collector interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) UpdateConfig(config *config.Config) } type Source interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) } type NginxSource interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) Update(dimensions *CommonDim, collectorConf *NginxCollectorConfig) Stop() } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go index 4ef7eb6aa5..998b1653fc 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go @@ -13,7 +13,6 @@ import ( "path" "strconv" "strings" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -47,9 +46,8 @@ func NewContainerCPUSource(namespace string, basePath string) *ContainerCPU { return &ContainerCPU{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, CpuGroup}} } -func (c *ContainerCPU) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerCPU) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container CPU metrics") - // defer wg.Done() containerStats := map[string]float64{} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go index 2db6b6d81a..086ac5b345 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go @@ -13,7 +13,6 @@ import ( "path" "strconv" "strings" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -40,9 +39,8 @@ func NewContainerMemorySource(namespace string, basePath string) *ContainerMemor return &ContainerMemory{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}} } -func (c *ContainerMemory) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container memory metrics") - // defer wg.Done() var containerStats map[string]float64 diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go index 080b192314..f7bb0046ca 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go @@ -69,8 +69,7 @@ func diffTimeStat(t1, t2 cpu.TimesStat) cpu.TimesStat { } } -func (c *CPUTimes) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() +func (c *CPUTimes) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var simpleMetrics []*proto.SimpleMetric if c.isDocker { dockerCpuPercentages, err := c.cgroupCPUSource.Percentages() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go index 7203fe1be2..98a3847a2d 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go @@ -10,7 +10,6 @@ package sources import ( "context" "fmt" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -32,8 +31,7 @@ func NewDiskSource(namespace string, env core.Environment) *Disk { return &Disk{NewMetricSourceLogger(), &namedMetric{namespace, "disk"}, disks, env} } -func (c *Disk) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() +func (c *Disk) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { for _, part := range c.disks { if part.Device == "" || part.FsType == "" { continue diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go index 98de097092..3a8f692275 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go @@ -37,8 +37,7 @@ func NewDiskIOSource(namespace string, env core.Environment) *DiskIO { return &DiskIO{namedMetric: &namedMetric{namespace, "io"}, env: env, diskIOStatsFunc: disk.IOCountersWithContext} } -func (dio *DiskIO) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() +func (dio *DiskIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { dio.init.Do(func() { dio.diskDevs, _ = dio.env.DiskDevices() dio.diskIOStats = dio.newDiskIOCounters(ctx, dio.diskDevs) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go index 8615636937..7a123dc136 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go @@ -10,7 +10,6 @@ package sources import ( "context" "fmt" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -28,7 +27,7 @@ func NewLoadSource(namespace string) *Load { return &Load{logger: NewMetricSourceLogger(), namedMetric: &namedMetric{namespace, "load"}, avgStatsFunc: load.Avg} } -func (c *Load) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *Load) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() loadStats, err := c.avgStatsFunc() if err != nil { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go index f586252157..6a0fab2365 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go @@ -11,7 +11,6 @@ import ( "context" "fmt" "os" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -38,7 +37,7 @@ func NewVirtualMemorySource(namespace string, env core.Environment) *VirtualMemo return &VirtualMemory{NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}, statFunc} } -func (c *VirtualMemory) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *VirtualMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() memstats, err := c.statFunc(ctx) if err != nil { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go index 41f6c0a6a9..2df0e985bf 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go @@ -46,7 +46,7 @@ func NewNetIOSource(namespace string, env core.Environment) *NetIO { } } -func (nio *NetIO) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (nio *NetIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() nio.init.Do(func() { ifs, err := nio.newNetInterfaces(ctx) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go index a4d01e193b..53026a0ff8 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go @@ -108,7 +108,7 @@ func NewNginxAccessLog( return nginxAccessLog } -func (c *NginxAccessLog) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxAccessLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() c.collectLogStats(ctx, m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go index b05dcdef6e..57f04395a6 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go @@ -101,7 +101,7 @@ func NewNginxErrorLog( return nginxErrorLog } -func (c *NginxErrorLog) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxErrorLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() c.collectLogStats(ctx, m) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go index a4d9c5b3c9..903bb944c8 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go @@ -34,7 +34,7 @@ func NewNginxOSS(baseDimensions *metrics.CommonDim, namespace, stubStatus string return &NginxOSS{baseDimensions: baseDimensions, stubStatus: stubStatus, namedMetric: &namedMetric{namespace: namespace}, logger: NewMetricSourceLogger()} } -func (c *NginxOSS) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxOSS) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() var err error c.init.Do(func() { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go index baefbc9f16..fa6e08770b 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go @@ -85,7 +85,7 @@ func NewNginxPlus(baseDimensions *metrics.CommonDim, nginxNamespace, plusNamespa return &NginxPlus{baseDimensions: baseDimensions, nginxNamespace: nginxNamespace, plusNamespace: plusNamespace, plusAPI: plusAPI, clientVersion: clientVersion, logger: NewMetricSourceLogger()} } -func (c *NginxPlus) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() c.init.Do(func() { latestAPIVersion, err := c.getLatestAPIVersion(ctx, c.plusAPI) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go index d432de436c..e85a8e2171 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -44,7 +43,7 @@ func (c *NginxProcess) getNginxCount() float64 { return 0.0 } -func (c *NginxProcess) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxProcess) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() l := &namedMetric{namespace: PlusNamespace, group: ""} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go index 12ec6aca76..cd32b25ae8 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "github.com/nginx/agent/v2/src/core/metrics" log "github.com/sirupsen/logrus" @@ -26,7 +25,7 @@ func NewNginxStatic(baseDimensions *metrics.CommonDim, namespace string) *NginxS return &NginxStatic{baseDimensions: baseDimensions, namedMetric: &namedMetric{namespace: namespace}} } -func (c *NginxStatic) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxStatic) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() SendNginxDownStatus(ctx, c.baseDimensions.ToDimensions(), m) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go index 514be451a3..3f0324d8e1 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go @@ -49,7 +49,7 @@ func NewNginxWorker(baseDimensions *metrics.CommonDim, } } -func (c *NginxWorker) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxWorker) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var err error // defer wg.Done() childProcs := c.binary.GetChildProcesses() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go index a617f91738..095234bcf9 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go @@ -12,7 +12,6 @@ import ( "fmt" "math/big" "os" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -49,7 +48,7 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { return &Swap{NewMetricSourceLogger(), &namedMetric{namespace, "swap"}, statFunc} } -func (c *Swap) Collect(ctx context.Context, _ *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *Swap) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { // defer wg.Done() swapStats, err := c.statFunc() if err != nil { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go index 59f78c2fe6..dd18ccec2d 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go @@ -9,7 +9,6 @@ package collector import ( "context" - "sync" "github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring" ) @@ -18,5 +17,5 @@ import ( // collect Raw Log data from WAF Instances. type Collector interface { // Collect starts collecting on collect chan until ctx.Done() chan gets a signal - Collect(ctx context.Context, _ *sync.WaitGroup, collect chan<- *monitoring.RawLog) + Collect(ctx context.Context, collect chan<- *monitoring.RawLog) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go index 816265d058..87d3953bcd 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go @@ -10,7 +10,6 @@ package collector import ( "context" "fmt" - "sync" "github.com/sirupsen/logrus" "gopkg.in/mcuadros/go-syslog.v2" @@ -84,7 +83,7 @@ func newSyslogServer(logger *logrus.Entry, ip string, port int) (*syslogServer, } // Collect starts collecting on collect chan until done chan gets a signal. -func (nap *NAPCollector) Collect(ctx context.Context, _ *sync.WaitGroup, collect chan<- *monitoring.RawLog) { +func (nap *NAPCollector) Collect(ctx context.Context, collect chan<- *monitoring.RawLog) { // defer wg.Done() nap.logger.Infof("Starting collection for %s", monitoring.NAP) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go index 4fbd3f4923..c22eedcc52 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -151,16 +151,13 @@ func (s *Manager) Run(ctx context.Context) { chtx, cancel := context.WithCancel(ctx) defer cancel() - // waitGroup := &sync.WaitGroup{} - // waitGroup.Add(2) - go s.collector.Collect(chtx, nil, s.collectChan) - go s.processor.Process(chtx, nil, s.collectChan, s.processorChan) + go s.collector.Collect(chtx, s.collectChan) + go s.processor.Process(chtx, s.collectChan, s.processorChan) <-ctx.Done() s.logger.Infof("Received Context cancellation, %s is wrapping up...", componentName) - // waitGroup.Wait() s.logger.Infof("Context cancellation, %s wrapped up...", componentName) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go index fe86feaea3..0c5324a875 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go @@ -121,13 +121,10 @@ func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int } // Process processes the raw log entries from collected chan into Security Events on processed chan. -func (c *Client) Process(ctx context.Context, _ *sync.WaitGroup, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - // defer wg.Done() - +func (c *Client) Process(ctx context.Context, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { c.logger.Info("Setting up Processor") for id := 1; id <= c.workers; id++ { - // wg.Add(1) go c.processorWorker(ctx, nil, id, collected, processed) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index 1a7d86688c..f9a6b381d5 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -237,14 +237,10 @@ func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // maybe we can fine tune the lock later, but the collection has been very quick so far. m.collectorsMutex.Lock() defer m.collectorsMutex.Unlock() - // wg := &sync.WaitGroup{} start := time.Now() for _, s := range m.collectors { - // wg.Add(1) - go s.Collect(ctx, nil, m.buf) + go s.Collect(ctx, m.buf) } - // wait until all the collection go routines are done, which either context timeout or exit - // wg.Wait() log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) return From b27d7ef30bdbc07f4f749ee9b3119c9466dd140c Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 11:14:41 +0100 Subject: [PATCH 23/49] remove defer in main --- main.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/main.go b/main.go index 50c9e2e590..12debc3d34 100644 --- a/main.go +++ b/main.go @@ -33,12 +33,6 @@ var ( func main() { config.InitFlags(version, commit) - defer func() { - if err := recover(); err != nil { - log.Printf("Recovered: %v", err) - } - }() - config.RegisterRunner(func(cmd *cobra.Command, _ []string) { config.InitConfigurationFiles() From 2a97002344933de8ef4211ead302a5fc889e5d34 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 11:20:11 +0100 Subject: [PATCH 24/49] removed comment out code --- src/core/metrics/sources/mem_test.go | 3 --- src/core/metrics/sources/net_io_test.go | 3 --- src/core/metrics/sources/nginx_oss_test.go | 3 --- src/core/metrics/sources/nginx_plus_test.go | 5 +---- src/core/metrics/sources/nginx_process_test.go | 6 ------ src/core/metrics/sources/nginx_static_test.go | 3 --- src/core/metrics/sources/nginx_worker_test.go | 4 ---- src/core/metrics/sources/swap_test.go | 3 --- .../nginx-app-protect/monitoring/collector/nap_test.go | 5 +---- test/performance/metrics_test.go | 9 --------- 10 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/core/metrics/sources/mem_test.go b/src/core/metrics/sources/mem_test.go index bc1c26f28f..81c1330ab0 100644 --- a/src/core/metrics/sources/mem_test.go +++ b/src/core/metrics/sources/mem_test.go @@ -56,11 +56,8 @@ func TestVirtualMemoryCollect(t *testing.T) { virtualMemorySource := NewVirtualMemorySource("test", env) ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 1) go virtualMemorySource.Collect(ctx, channel) - // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/net_io_test.go b/src/core/metrics/sources/net_io_test.go index 1dbea21fd0..cd58e1e588 100644 --- a/src/core/metrics/sources/net_io_test.go +++ b/src/core/metrics/sources/net_io_test.go @@ -48,11 +48,8 @@ func TestNetIOCollect(t *testing.T) { } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) nioSource.Collect(ctx, channel) - // wg.Wait() actual := <-channel diff --git a/src/core/metrics/sources/nginx_oss_test.go b/src/core/metrics/sources/nginx_oss_test.go index 5bbb7af938..d86532866d 100644 --- a/src/core/metrics/sources/nginx_oss_test.go +++ b/src/core/metrics/sources/nginx_oss_test.go @@ -109,10 +109,7 @@ Reading: 0 Writing: 1 Waiting: 0 logger: NewMetricSourceLogger(), } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) go c.Collect(ctx, test.m) - // wg.Wait() statEntity := <-test.m assert.Len(tt, statEntity.Data.Simplemetrics, len(test.expectedMetrics)) for _, metric := range statEntity.Data.Simplemetrics { diff --git a/src/core/metrics/sources/nginx_plus_test.go b/src/core/metrics/sources/nginx_plus_test.go index 92b4a0329a..8905efc4e7 100644 --- a/src/core/metrics/sources/nginx_plus_test.go +++ b/src/core/metrics/sources/nginx_plus_test.go @@ -565,7 +565,7 @@ type FakeNginxPlus struct { // Collect is fake collector that hard codes a stats struct response to avoid dependency on external NGINX Plus api func (f *FakeNginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() + f.baseDimensions.NginxType = "plus" f.baseDimensions.PublishedAPI = f.plusAPI @@ -981,10 +981,7 @@ func TestNginxPlus_Collect(t *testing.T) { ctx := context.TODO() f := &FakeNginxPlus{NewNginxPlus(test.baseDimensions, "nginx", "plus", "", 6)} - // wg := &sync.WaitGroup{} - // wg.Add(1) go f.Collect(ctx, test.m) - // wg.Wait() instanceMetrics := <-test.m assert.Len(t, instanceMetrics.Data.Simplemetrics, len(expectedInstanceMetrics)) diff --git a/src/core/metrics/sources/nginx_process_test.go b/src/core/metrics/sources/nginx_process_test.go index b54921cc79..8bdb4756d2 100644 --- a/src/core/metrics/sources/nginx_process_test.go +++ b/src/core/metrics/sources/nginx_process_test.go @@ -57,8 +57,6 @@ func TestNginxProcessCollector_Collect_Process(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - // wg := sync.WaitGroup{} - // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) go n.Collect(ctx, m) @@ -101,8 +99,6 @@ func TestNginxProcessCollector_Collect_NoProcess(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - // wg := sync.WaitGroup{} - // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) go n.Collect(ctx, m) @@ -148,8 +144,6 @@ func TestNginxProcessCollector_Collect_NotPlus(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - // wg := sync.WaitGroup{} - // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) go n.Collect(ctx, m) diff --git a/src/core/metrics/sources/nginx_static_test.go b/src/core/metrics/sources/nginx_static_test.go index 7c8e77b124..fa93e0a9d8 100644 --- a/src/core/metrics/sources/nginx_static_test.go +++ b/src/core/metrics/sources/nginx_static_test.go @@ -64,10 +64,7 @@ func TestNginxStatic_Collect(t *testing.T) { namedMetric: test.namedMetric, } ctx := context.TODO() - // wg := &sync.WaitGroup{} - // wg.Add(1) go c.Collect(ctx, test.m) - // wg.Wait() statEntity := <-test.m assert.Len(tt, statEntity.Data.Simplemetrics, len(expectedMetrics)) for _, metric := range statEntity.Data.Simplemetrics { diff --git a/src/core/metrics/sources/nginx_worker_test.go b/src/core/metrics/sources/nginx_worker_test.go index fad25db24d..a67ee8c67e 100644 --- a/src/core/metrics/sources/nginx_worker_test.go +++ b/src/core/metrics/sources/nginx_worker_test.go @@ -77,8 +77,6 @@ func TestNginxWorkerCollector(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - // wg := sync.WaitGroup{} - // wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) go n.Collect(ctx, m) @@ -121,8 +119,6 @@ func TestNginxWorkerCollector(t *testing.T) { } } - // wg.Add(1) - go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) diff --git a/src/core/metrics/sources/swap_test.go b/src/core/metrics/sources/swap_test.go index da079d5029..d0ada3c25d 100644 --- a/src/core/metrics/sources/swap_test.go +++ b/src/core/metrics/sources/swap_test.go @@ -90,10 +90,7 @@ func TestSwapSource_Collect(t *testing.T) { UsedPercent: 30, }, nil } - // wg := &sync.WaitGroup{} - // wg.Add(1) go c.Collect(ctx, test.m) - // wg.Wait() statsEntity := <-test.m assert.Len(tt, statsEntity.Data.Simplemetrics, len(expectedMetrics)) diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go index 5c6c014786..39daa86620 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go @@ -86,10 +86,7 @@ func TestNAPCollect(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - - // wg := &sync.WaitGroup{} - // wg.Add(1) - + go waf.Collect(ctx, collect) logwriter, err = syslog.Dial("tcp4", testIP+":"+strconv.Itoa(testPort), syslog.LOG_INFO|syslog.LOG_USER, "test") diff --git a/test/performance/metrics_test.go b/test/performance/metrics_test.go index 932db1bfad..f93650dc4e 100644 --- a/test/performance/metrics_test.go +++ b/test/performance/metrics_test.go @@ -75,28 +75,22 @@ type ( ) func (m *MetricsServer) Stream(stream proto.MetricsService_StreamServer) error { - // wg := &sync.WaitGroup{} h := m.ensureHandler() - // wg.Add(1) hf := h.metricHandlerFunc if hf == nil { hf = h.metricsHandle } go hf(stream, nil) - // wg.Wait() return nil } func (m *MetricsServer) StreamEvents(stream proto.MetricsService_StreamEventsServer) error { - // wg := &sync.WaitGroup{} h := m.ensureHandler() - // wg.Add(1) hf := h.eventReportHandlerFunc if hf == nil { hf = h.eventReportHandle } go hf(stream, nil) - // wg.Wait() return nil } @@ -157,15 +151,12 @@ type cmdService struct { } func (c *cmdService) CommandChannel(server proto.Commander_CommandChannelServer) error { - // wg := &sync.WaitGroup{} h := c.ensureHandler() - // wg.Add(1) hf := h.handleFunc if hf == nil { hf = h.handle } go hf(server, nil) - // wg.Wait() return nil } From 0f2842115f961e4ac142364f1204a074bcb15b46 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 11:25:59 +0100 Subject: [PATCH 25/49] removed comment out code --- src/core/metrics/collectors/container.go | 1 - src/core/metrics/sources/load.go | 1 - src/core/metrics/sources/mem.go | 1 - src/core/metrics/sources/net_io.go | 1 - src/core/metrics/sources/nginx_access_log.go | 1 - src/core/metrics/sources/nginx_error_log.go | 2 -- src/core/metrics/sources/nginx_oss.go | 1 - src/core/metrics/sources/nginx_plus.go | 1 - src/core/metrics/sources/nginx_plus_test.go | 2 -- src/core/metrics/sources/nginx_process.go | 2 -- src/core/metrics/sources/nginx_static.go | 2 -- src/core/metrics/sources/nginx_worker.go | 1 - src/core/metrics/sources/swap.go | 1 - src/core/pipe_test.go | 20 ------------------- .../monitoring/collector/nap.go | 2 -- .../monitoring/collector/nap_test.go | 2 +- .../monitoring/manager/manager.go | 2 -- .../monitoring/processor/processor.go | 2 -- src/plugins/metrics_throlling.go | 5 ----- .../src/core/metrics/collectors/container.go | 1 - .../agent/v2/src/core/metrics/sources/load.go | 1 - .../agent/v2/src/core/metrics/sources/mem.go | 1 - .../v2/src/core/metrics/sources/net_io.go | 1 - .../core/metrics/sources/nginx_access_log.go | 1 - .../core/metrics/sources/nginx_error_log.go | 2 -- .../v2/src/core/metrics/sources/nginx_oss.go | 1 - .../v2/src/core/metrics/sources/nginx_plus.go | 1 - .../src/core/metrics/sources/nginx_process.go | 2 -- .../src/core/metrics/sources/nginx_static.go | 2 -- .../src/core/metrics/sources/nginx_worker.go | 1 - .../agent/v2/src/core/metrics/sources/swap.go | 1 - .../monitoring/collector/nap.go | 2 -- .../monitoring/manager/manager.go | 2 -- .../monitoring/processor/processor.go | 2 -- .../agent/v2/src/plugins/metrics_throlling.go | 5 ----- 35 files changed, 1 insertion(+), 75 deletions(-) diff --git a/src/core/metrics/collectors/container.go b/src/core/metrics/collectors/container.go index 4e5439a21b..1c7cf82292 100644 --- a/src/core/metrics/collectors/container.go +++ b/src/core/metrics/collectors/container.go @@ -51,7 +51,6 @@ func (c *ContainerCollector) collectMetrics(ctx context.Context) { } func (c *ContainerCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/src/core/metrics/sources/load.go b/src/core/metrics/sources/load.go index 7a123dc136..e4395f01b4 100644 --- a/src/core/metrics/sources/load.go +++ b/src/core/metrics/sources/load.go @@ -28,7 +28,6 @@ func NewLoadSource(namespace string) *Load { } func (c *Load) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() loadStats, err := c.avgStatsFunc() if err != nil { c.logger.Log(fmt.Sprintf("Failed to collect Load metrics, %v", err)) diff --git a/src/core/metrics/sources/mem.go b/src/core/metrics/sources/mem.go index 6a0fab2365..6b0c7e9fdf 100644 --- a/src/core/metrics/sources/mem.go +++ b/src/core/metrics/sources/mem.go @@ -38,7 +38,6 @@ func NewVirtualMemorySource(namespace string, env core.Environment) *VirtualMemo } func (c *VirtualMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() memstats, err := c.statFunc(ctx) if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/src/core/metrics/sources/net_io.go b/src/core/metrics/sources/net_io.go index 2df0e985bf..e3ef91cd83 100644 --- a/src/core/metrics/sources/net_io.go +++ b/src/core/metrics/sources/net_io.go @@ -47,7 +47,6 @@ func NewNetIOSource(namespace string, env core.Environment) *NetIO { } func (nio *NetIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() nio.init.Do(func() { ifs, err := nio.newNetInterfaces(ctx) if err != nil || ifs == nil { diff --git a/src/core/metrics/sources/nginx_access_log.go b/src/core/metrics/sources/nginx_access_log.go index 53026a0ff8..46c50b5830 100644 --- a/src/core/metrics/sources/nginx_access_log.go +++ b/src/core/metrics/sources/nginx_access_log.go @@ -109,7 +109,6 @@ func NewNginxAccessLog( } func (c *NginxAccessLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() c.collectLogStats(ctx, m) } diff --git a/src/core/metrics/sources/nginx_error_log.go b/src/core/metrics/sources/nginx_error_log.go index 57f04395a6..06368eb93a 100644 --- a/src/core/metrics/sources/nginx_error_log.go +++ b/src/core/metrics/sources/nginx_error_log.go @@ -102,8 +102,6 @@ func NewNginxErrorLog( } func (c *NginxErrorLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() - c.collectLogStats(ctx, m) } diff --git a/src/core/metrics/sources/nginx_oss.go b/src/core/metrics/sources/nginx_oss.go index 903bb944c8..a633cedd58 100644 --- a/src/core/metrics/sources/nginx_oss.go +++ b/src/core/metrics/sources/nginx_oss.go @@ -35,7 +35,6 @@ func NewNginxOSS(baseDimensions *metrics.CommonDim, namespace, stubStatus string } func (c *NginxOSS) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() var err error c.init.Do(func() { cl := client.NewNginxClient(&http.Client{}, c.stubStatus) diff --git a/src/core/metrics/sources/nginx_plus.go b/src/core/metrics/sources/nginx_plus.go index fa6e08770b..105b063dfc 100644 --- a/src/core/metrics/sources/nginx_plus.go +++ b/src/core/metrics/sources/nginx_plus.go @@ -86,7 +86,6 @@ func NewNginxPlus(baseDimensions *metrics.CommonDim, nginxNamespace, plusNamespa } func (c *NginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() c.init.Do(func() { latestAPIVersion, err := c.getLatestAPIVersion(ctx, c.plusAPI) if err != nil { diff --git a/src/core/metrics/sources/nginx_plus_test.go b/src/core/metrics/sources/nginx_plus_test.go index 8905efc4e7..bc9d65049c 100644 --- a/src/core/metrics/sources/nginx_plus_test.go +++ b/src/core/metrics/sources/nginx_plus_test.go @@ -565,8 +565,6 @@ type FakeNginxPlus struct { // Collect is fake collector that hard codes a stats struct response to avoid dependency on external NGINX Plus api func (f *FakeNginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - - f.baseDimensions.NginxType = "plus" f.baseDimensions.PublishedAPI = f.plusAPI f.baseDimensions.NginxBuild = stats.NginxInfo.Build diff --git a/src/core/metrics/sources/nginx_process.go b/src/core/metrics/sources/nginx_process.go index e85a8e2171..61852b4eab 100644 --- a/src/core/metrics/sources/nginx_process.go +++ b/src/core/metrics/sources/nginx_process.go @@ -44,8 +44,6 @@ func (c *NginxProcess) getNginxCount() float64 { } func (c *NginxProcess) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() - l := &namedMetric{namespace: PlusNamespace, group: ""} countSimpleMetric := l.convertSamplesToSimpleMetrics(map[string]float64{ "instance.count": c.getNginxCount(), diff --git a/src/core/metrics/sources/nginx_static.go b/src/core/metrics/sources/nginx_static.go index cd32b25ae8..e7d6adfb18 100644 --- a/src/core/metrics/sources/nginx_static.go +++ b/src/core/metrics/sources/nginx_static.go @@ -26,8 +26,6 @@ func NewNginxStatic(baseDimensions *metrics.CommonDim, namespace string) *NginxS } func (c *NginxStatic) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() - SendNginxDownStatus(ctx, c.baseDimensions.ToDimensions(), m) } diff --git a/src/core/metrics/sources/nginx_worker.go b/src/core/metrics/sources/nginx_worker.go index 3f0324d8e1..e2312494bf 100644 --- a/src/core/metrics/sources/nginx_worker.go +++ b/src/core/metrics/sources/nginx_worker.go @@ -51,7 +51,6 @@ func NewNginxWorker(baseDimensions *metrics.CommonDim, func (c *NginxWorker) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var err error - // defer wg.Done() childProcs := c.binary.GetChildProcesses() c.init.Do(func() { for pid, children := range childProcs { diff --git a/src/core/metrics/sources/swap.go b/src/core/metrics/sources/swap.go index 095234bcf9..a8d2e30223 100644 --- a/src/core/metrics/sources/swap.go +++ b/src/core/metrics/sources/swap.go @@ -49,7 +49,6 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { } func (c *Swap) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() swapStats, err := c.statFunc() if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/src/core/pipe_test.go b/src/core/pipe_test.go index 302a8b729c..6c8585ffcf 100644 --- a/src/core/pipe_test.go +++ b/src/core/pipe_test.go @@ -112,26 +112,6 @@ func TestMessagePipe_Process(t *testing.T) { pipe.Close() } -// func TestPipe_DeRegister(t *testing.T) { -// plugin := new(testPlugin) -// plugin.On("Close").Times(1) - -// ctx, cancel := context.WithCancel(context.Background()) -// defer cancel() - -// messagePipe := NewMessagePipe(ctx, 10) -// messagePipe.Register(10, []Plugin{plugin}, nil) - -// err := messagePipe.DeRegister([]string{*plugin.Info().name}) -// require.NoError(t, err) - -// assert.Equal(t, 0, len(messagePipe.GetPlugins())) - -// cancel() -// messagePipe.Close() -// plugin.AssertExpectations(t) -// } - func TestPipe_IsPluginAlreadyRegistered(t *testing.T) { plugin := new(testPlugin) plugin.On("Close").Times(1) diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap.go b/src/extensions/nginx-app-protect/monitoring/collector/nap.go index 87d3953bcd..70af0ab9eb 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap.go @@ -84,8 +84,6 @@ func newSyslogServer(logger *logrus.Entry, ip string, port int) (*syslogServer, // Collect starts collecting on collect chan until done chan gets a signal. func (nap *NAPCollector) Collect(ctx context.Context, collect chan<- *monitoring.RawLog) { - // defer wg.Done() - nap.logger.Infof("Starting collection for %s", monitoring.NAP) for { diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go index 39daa86620..851579decd 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go @@ -86,7 +86,7 @@ func TestNAPCollect(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - + go waf.Collect(ctx, collect) logwriter, err = syslog.Dial("tcp4", testIP+":"+strconv.Itoa(testPort), syslog.LOG_INFO|syslog.LOG_USER, "test") diff --git a/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/src/extensions/nginx-app-protect/monitoring/manager/manager.go index c22eedcc52..4c0700a00f 100644 --- a/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -151,14 +151,12 @@ func (s *Manager) Run(ctx context.Context) { chtx, cancel := context.WithCancel(ctx) defer cancel() - go s.collector.Collect(chtx, s.collectChan) go s.processor.Process(chtx, s.collectChan, s.processorChan) <-ctx.Done() s.logger.Infof("Received Context cancellation, %s is wrapping up...", componentName) - s.logger.Infof("Context cancellation, %s wrapped up...", componentName) } diff --git a/src/extensions/nginx-app-protect/monitoring/processor/processor.go b/src/extensions/nginx-app-protect/monitoring/processor/processor.go index 0c5324a875..810f334e81 100644 --- a/src/extensions/nginx-app-protect/monitoring/processor/processor.go +++ b/src/extensions/nginx-app-protect/monitoring/processor/processor.go @@ -76,8 +76,6 @@ func GetClient(cfg *Config) (*Client, error) { // processorWorker is a worker process to process events. func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - // defer wg.Done() - c.logger.Debugf("Setting up Processor Worker: %d", id) for { diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index 6f7cdefd83..b108bfdb02 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -201,11 +201,6 @@ func (r *MetricsThrottle) syncAgentConfigChange() { } func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { - // r.mu.Lock() - // localMetricsCollections := r.metricsCollections - // r.metricsCollections = make(map[proto.MetricsReport_Type]*metrics.Collections) - // r.mu.Unlock() - for reportType, collection := range r.metricsCollections { reports = append(reports, &proto.MetricsReport{ Meta: &proto.Metadata{ diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go index 4e5439a21b..1c7cf82292 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go @@ -51,7 +51,6 @@ func (c *ContainerCollector) collectMetrics(ctx context.Context) { } func (c *ContainerCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go index 7a123dc136..e4395f01b4 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go @@ -28,7 +28,6 @@ func NewLoadSource(namespace string) *Load { } func (c *Load) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() loadStats, err := c.avgStatsFunc() if err != nil { c.logger.Log(fmt.Sprintf("Failed to collect Load metrics, %v", err)) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go index 6a0fab2365..6b0c7e9fdf 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go @@ -38,7 +38,6 @@ func NewVirtualMemorySource(namespace string, env core.Environment) *VirtualMemo } func (c *VirtualMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() memstats, err := c.statFunc(ctx) if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go index 2df0e985bf..e3ef91cd83 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go @@ -47,7 +47,6 @@ func NewNetIOSource(namespace string, env core.Environment) *NetIO { } func (nio *NetIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() nio.init.Do(func() { ifs, err := nio.newNetInterfaces(ctx) if err != nil || ifs == nil { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go index 53026a0ff8..46c50b5830 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go @@ -109,7 +109,6 @@ func NewNginxAccessLog( } func (c *NginxAccessLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() c.collectLogStats(ctx, m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go index 57f04395a6..06368eb93a 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go @@ -102,8 +102,6 @@ func NewNginxErrorLog( } func (c *NginxErrorLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() - c.collectLogStats(ctx, m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go index 903bb944c8..a633cedd58 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go @@ -35,7 +35,6 @@ func NewNginxOSS(baseDimensions *metrics.CommonDim, namespace, stubStatus string } func (c *NginxOSS) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() var err error c.init.Do(func() { cl := client.NewNginxClient(&http.Client{}, c.stubStatus) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go index fa6e08770b..105b063dfc 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go @@ -86,7 +86,6 @@ func NewNginxPlus(baseDimensions *metrics.CommonDim, nginxNamespace, plusNamespa } func (c *NginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() c.init.Do(func() { latestAPIVersion, err := c.getLatestAPIVersion(ctx, c.plusAPI) if err != nil { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go index e85a8e2171..61852b4eab 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go @@ -44,8 +44,6 @@ func (c *NginxProcess) getNginxCount() float64 { } func (c *NginxProcess) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() - l := &namedMetric{namespace: PlusNamespace, group: ""} countSimpleMetric := l.convertSamplesToSimpleMetrics(map[string]float64{ "instance.count": c.getNginxCount(), diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go index cd32b25ae8..e7d6adfb18 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go @@ -26,8 +26,6 @@ func NewNginxStatic(baseDimensions *metrics.CommonDim, namespace string) *NginxS } func (c *NginxStatic) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() - SendNginxDownStatus(ctx, c.baseDimensions.ToDimensions(), m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go index 3f0324d8e1..e2312494bf 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go @@ -51,7 +51,6 @@ func NewNginxWorker(baseDimensions *metrics.CommonDim, func (c *NginxWorker) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var err error - // defer wg.Done() childProcs := c.binary.GetChildProcesses() c.init.Do(func() { for pid, children := range childProcs { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go index 095234bcf9..a8d2e30223 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go @@ -49,7 +49,6 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { } func (c *Swap) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { - // defer wg.Done() swapStats, err := c.statFunc() if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go index 87d3953bcd..70af0ab9eb 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go @@ -84,8 +84,6 @@ func newSyslogServer(logger *logrus.Entry, ip string, port int) (*syslogServer, // Collect starts collecting on collect chan until done chan gets a signal. func (nap *NAPCollector) Collect(ctx context.Context, collect chan<- *monitoring.RawLog) { - // defer wg.Done() - nap.logger.Infof("Starting collection for %s", monitoring.NAP) for { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go index c22eedcc52..4c0700a00f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -151,14 +151,12 @@ func (s *Manager) Run(ctx context.Context) { chtx, cancel := context.WithCancel(ctx) defer cancel() - go s.collector.Collect(chtx, s.collectChan) go s.processor.Process(chtx, s.collectChan, s.processorChan) <-ctx.Done() s.logger.Infof("Received Context cancellation, %s is wrapping up...", componentName) - s.logger.Infof("Context cancellation, %s wrapped up...", componentName) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go index 0c5324a875..810f334e81 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go @@ -76,8 +76,6 @@ func GetClient(cfg *Config) (*Client, error) { // processorWorker is a worker process to process events. func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - // defer wg.Done() - c.logger.Debugf("Setting up Processor Worker: %d", id) for { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index 6f7cdefd83..b108bfdb02 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -201,11 +201,6 @@ func (r *MetricsThrottle) syncAgentConfigChange() { } func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { - // r.mu.Lock() - // localMetricsCollections := r.metricsCollections - // r.metricsCollections = make(map[proto.MetricsReport_Type]*metrics.Collections) - // r.mu.Unlock() - for reportType, collection := range r.metricsCollections { reports = append(reports, &proto.MetricsReport{ Meta: &proto.Metadata{ From b71c3f40dd230c58162993e1e21aff220c59378e Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 11:34:09 +0100 Subject: [PATCH 26/49] revert performance test --- test/performance/metrics_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/performance/metrics_test.go b/test/performance/metrics_test.go index f93650dc4e..899a976626 100644 --- a/test/performance/metrics_test.go +++ b/test/performance/metrics_test.go @@ -75,22 +75,28 @@ type ( ) func (m *MetricsServer) Stream(stream proto.MetricsService_StreamServer) error { + wg := &sync.WaitGroup{} h := m.ensureHandler() + wg.Add(1) hf := h.metricHandlerFunc if hf == nil { hf = h.metricsHandle } - go hf(stream, nil) + go hf(stream, wg) + wg.Wait() return nil } func (m *MetricsServer) StreamEvents(stream proto.MetricsService_StreamEventsServer) error { + wg := &sync.WaitGroup{} h := m.ensureHandler() + wg.Add(1) hf := h.eventReportHandlerFunc if hf == nil { hf = h.eventReportHandle } - go hf(stream, nil) + go hf(stream, wg) + wg.Wait() return nil } @@ -151,12 +157,15 @@ type cmdService struct { } func (c *cmdService) CommandChannel(server proto.Commander_CommandChannelServer) error { + wg := &sync.WaitGroup{} h := c.ensureHandler() + wg.Add(1) hf := h.handleFunc if hf == nil { hf = h.handle } - go hf(server, nil) + go hf(server, wg) + wg.Wait() return nil } From 2499d45a50df0a8a07d5c1a6e29fdfcfcd9d1528 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 12:01:41 +0100 Subject: [PATCH 27/49] fixed some stuff --- go.mod | 2 +- go.sum | 4 +- sdk/go.mod | 2 +- sdk/go.sum | 4 +- sdk/vendor/golang.org/x/sys/LICENSE | 4 +- sdk/vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + .../golang.org/x/sys/unix/syscall_darwin.go | 12 ++++ .../golang.org/x/sys/unix/syscall_linux.go | 1 + .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../x/sys/unix/zerrors_darwin_amd64.go | 5 ++ .../x/sys/unix/zerrors_darwin_arm64.go | 5 ++ .../golang.org/x/sys/unix/zerrors_linux.go | 38 +++++++++- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 2 + .../x/sys/unix/zerrors_linux_arm64.go | 2 + .../x/sys/unix/zerrors_linux_loong64.go | 2 + .../x/sys/unix/zerrors_linux_mips.go | 2 + .../x/sys/unix/zerrors_linux_mips64.go | 2 + .../x/sys/unix/zerrors_linux_mips64le.go | 2 + .../x/sys/unix/zerrors_linux_mipsle.go | 2 + .../x/sys/unix/zerrors_linux_ppc.go | 2 + .../x/sys/unix/zerrors_linux_ppc64.go | 2 + .../x/sys/unix/zerrors_linux_ppc64le.go | 2 + .../x/sys/unix/zerrors_linux_riscv64.go | 2 + .../x/sys/unix/zerrors_linux_s390x.go | 2 + .../x/sys/unix/zerrors_linux_sparc64.go | 2 + .../x/sys/unix/zsyscall_darwin_amd64.go | 48 +++++++++++++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 +++ .../x/sys/unix/zsyscall_darwin_arm64.go | 48 +++++++++++++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 +++ .../golang.org/x/sys/unix/zsyscall_linux.go | 16 +++++ .../x/sys/unix/zsyscall_openbsd_386.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_386.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_amd64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_arm.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_arm.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_arm64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_mips64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 ++ .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + .../golang.org/x/sys/unix/ztypes_linux.go | 10 ++- .../x/sys/windows/security_windows.go | 2 +- .../x/sys/windows/syscall_windows.go | 12 +++- .../golang.org/x/sys/windows/types_windows.go | 71 ++++++++++++++++++- .../x/sys/windows/zsyscall_windows.go | 49 ++++++++++--- sdk/vendor/modules.txt | 2 +- src/core/metrics/sources/mem.go | 2 +- src/core/tailer/tailer.go | 6 +- src/core/tailer/tailer_test.go | 18 ++++- src/plugins/metrics.go | 1 - src/plugins/metrics_throlling.go | 1 - test/integration/go.mod | 2 +- test/integration/go.sum | 4 +- .../grpc/grpc_config_apply_test.go | 2 +- .../vendor/golang.org/x/sys/LICENSE | 4 +- .../vendor/golang.org/x/sys/cpu/cpu.go | 2 + .../vendor/golang.org/x/sys/cpu/cpu_arm64.go | 12 ++++ .../golang.org/x/sys/cpu/cpu_linux_arm64.go | 5 ++ .../vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + .../golang.org/x/sys/unix/syscall_darwin.go | 12 ++++ .../golang.org/x/sys/unix/syscall_linux.go | 1 + .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../x/sys/unix/zerrors_darwin_amd64.go | 5 ++ .../x/sys/unix/zerrors_darwin_arm64.go | 5 ++ .../golang.org/x/sys/unix/zerrors_linux.go | 38 +++++++++- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 2 + .../x/sys/unix/zerrors_linux_arm64.go | 2 + .../x/sys/unix/zerrors_linux_loong64.go | 2 + .../x/sys/unix/zerrors_linux_mips.go | 2 + .../x/sys/unix/zerrors_linux_mips64.go | 2 + .../x/sys/unix/zerrors_linux_mips64le.go | 2 + .../x/sys/unix/zerrors_linux_mipsle.go | 2 + .../x/sys/unix/zerrors_linux_ppc.go | 2 + .../x/sys/unix/zerrors_linux_ppc64.go | 2 + .../x/sys/unix/zerrors_linux_ppc64le.go | 2 + .../x/sys/unix/zerrors_linux_riscv64.go | 2 + .../x/sys/unix/zerrors_linux_s390x.go | 2 + .../x/sys/unix/zerrors_linux_sparc64.go | 2 + .../x/sys/unix/zsyscall_darwin_amd64.go | 48 +++++++++++++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 +++ .../x/sys/unix/zsyscall_darwin_arm64.go | 48 +++++++++++++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 +++ .../golang.org/x/sys/unix/zsyscall_linux.go | 16 +++++ .../x/sys/unix/zsyscall_openbsd_386.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_386.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_amd64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_arm.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_arm.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_arm64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_mips64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 ++ .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + .../golang.org/x/sys/unix/ztypes_linux.go | 10 ++- .../x/sys/windows/security_windows.go | 2 +- .../x/sys/windows/syscall_windows.go | 12 +++- .../golang.org/x/sys/windows/types_windows.go | 71 ++++++++++++++++++- .../x/sys/windows/zsyscall_windows.go | 49 ++++++++++--- test/integration/vendor/modules.txt | 2 +- test/performance/go.mod | 2 +- test/performance/go.sum | 4 +- .../agent/v2/src/core/metrics/sources/mem.go | 2 +- .../nginx/agent/v2/src/core/tailer/tailer.go | 6 +- .../nginx/agent/v2/src/plugins/metrics.go | 1 - .../agent/v2/src/plugins/metrics_throlling.go | 1 - .../vendor/golang.org/x/sys/LICENSE | 4 +- .../vendor/golang.org/x/sys/cpu/cpu.go | 2 + .../vendor/golang.org/x/sys/cpu/cpu_arm64.go | 12 ++++ .../golang.org/x/sys/cpu/cpu_linux_arm64.go | 5 ++ .../vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + .../golang.org/x/sys/unix/syscall_darwin.go | 12 ++++ .../golang.org/x/sys/unix/syscall_linux.go | 1 + .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../x/sys/unix/zerrors_darwin_amd64.go | 5 ++ .../x/sys/unix/zerrors_darwin_arm64.go | 5 ++ .../golang.org/x/sys/unix/zerrors_linux.go | 38 +++++++++- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 2 + .../x/sys/unix/zerrors_linux_arm64.go | 2 + .../x/sys/unix/zerrors_linux_loong64.go | 2 + .../x/sys/unix/zerrors_linux_mips.go | 2 + .../x/sys/unix/zerrors_linux_mips64.go | 2 + .../x/sys/unix/zerrors_linux_mips64le.go | 2 + .../x/sys/unix/zerrors_linux_mipsle.go | 2 + .../x/sys/unix/zerrors_linux_ppc.go | 2 + .../x/sys/unix/zerrors_linux_ppc64.go | 2 + .../x/sys/unix/zerrors_linux_ppc64le.go | 2 + .../x/sys/unix/zerrors_linux_riscv64.go | 2 + .../x/sys/unix/zerrors_linux_s390x.go | 2 + .../x/sys/unix/zerrors_linux_sparc64.go | 2 + .../x/sys/unix/zsyscall_darwin_amd64.go | 48 +++++++++++++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 +++ .../x/sys/unix/zsyscall_darwin_arm64.go | 48 +++++++++++++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 +++ .../golang.org/x/sys/unix/zsyscall_linux.go | 16 +++++ .../x/sys/unix/zsyscall_openbsd_386.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_386.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_amd64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_arm.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_arm.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_arm64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_mips64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 ++ .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + .../golang.org/x/sys/unix/ztypes_linux.go | 10 ++- .../x/sys/windows/security_windows.go | 2 +- .../x/sys/windows/syscall_windows.go | 12 +++- .../golang.org/x/sys/windows/types_windows.go | 71 ++++++++++++++++++- .../x/sys/windows/zsyscall_windows.go | 49 ++++++++++--- test/performance/vendor/modules.txt | 2 +- vendor/golang.org/x/sys/LICENSE | 4 +- vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + .../golang.org/x/sys/unix/syscall_darwin.go | 12 ++++ vendor/golang.org/x/sys/unix/syscall_linux.go | 1 + .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../x/sys/unix/zerrors_darwin_amd64.go | 5 ++ .../x/sys/unix/zerrors_darwin_arm64.go | 5 ++ vendor/golang.org/x/sys/unix/zerrors_linux.go | 38 +++++++++- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 2 + .../x/sys/unix/zerrors_linux_arm64.go | 2 + .../x/sys/unix/zerrors_linux_loong64.go | 2 + .../x/sys/unix/zerrors_linux_mips.go | 2 + .../x/sys/unix/zerrors_linux_mips64.go | 2 + .../x/sys/unix/zerrors_linux_mips64le.go | 2 + .../x/sys/unix/zerrors_linux_mipsle.go | 2 + .../x/sys/unix/zerrors_linux_ppc.go | 2 + .../x/sys/unix/zerrors_linux_ppc64.go | 2 + .../x/sys/unix/zerrors_linux_ppc64le.go | 2 + .../x/sys/unix/zerrors_linux_riscv64.go | 2 + .../x/sys/unix/zerrors_linux_s390x.go | 2 + .../x/sys/unix/zerrors_linux_sparc64.go | 2 + .../x/sys/unix/zsyscall_darwin_amd64.go | 48 +++++++++++++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 +++ .../x/sys/unix/zsyscall_darwin_arm64.go | 48 +++++++++++++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 +++ .../golang.org/x/sys/unix/zsyscall_linux.go | 16 +++++ .../x/sys/unix/zsyscall_openbsd_386.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_386.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_amd64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_arm.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_arm.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_arm64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_mips64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.go | 24 +++++++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 ++ .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + vendor/golang.org/x/sys/unix/ztypes_linux.go | 10 ++- .../x/sys/windows/security_windows.go | 2 +- .../x/sys/windows/syscall_windows.go | 12 +++- .../golang.org/x/sys/windows/types_windows.go | 71 ++++++++++++++++++- .../x/sys/windows/zsyscall_windows.go | 49 ++++++++++--- vendor/modules.txt | 2 +- 276 files changed, 2370 insertions(+), 108 deletions(-) diff --git a/go.mod b/go.mod index 7ec7455407..b93bcd8d31 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/rs/cors v1.11.0 go.uber.org/goleak v1.3.0 go.uber.org/mock v0.4.0 - golang.org/x/sys v0.22.0 + golang.org/x/sys v0.24.0 golang.org/x/text v0.16.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index c2bdf05e17..e22fe475d3 100644 --- a/go.sum +++ b/go.sum @@ -250,8 +250,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= diff --git a/sdk/go.mod b/sdk/go.mod index 5cd996148c..af91062698 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/tools v0.23.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect diff --git a/sdk/go.sum b/sdk/go.sum index 9027ec7270..fc3200948b 100644 --- a/sdk/go.sum +++ b/sdk/go.sum @@ -120,8 +120,8 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= diff --git a/sdk/vendor/golang.org/x/sys/LICENSE b/sdk/vendor/golang.org/x/sys/LICENSE index 6a66aea5ea..2a7cf70da6 100644 --- a/sdk/vendor/golang.org/x/sys/LICENSE +++ b/sdk/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/sdk/vendor/golang.org/x/sys/unix/mkerrors.sh b/sdk/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b6..d07dd09eb5 100644 --- a/sdk/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/sdk/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/sdk/vendor/golang.org/x/sys/unix/syscall_darwin.go b/sdk/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b00596..2d15200adb 100644 --- a/sdk/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/sdk/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/sdk/vendor/golang.org/x/sys/unix/syscall_linux.go b/sdk/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628a..3f1d3d4cb2 100644 --- a/sdk/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/sdk/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/sdk/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/sdk/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a..b86ded549c 100644 --- a/sdk/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/sdk/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245..4308ac1772 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c05..c8068a7a16 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479..01a70b2463 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c..684a5168da 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdb..61d74b592d 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac3..a28c9e3e89 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b0..ab5d1fe8ea 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb..c523090e7c 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb4..01e6ea7804 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78..7aa610b1e7 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da..92af771b44 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b..b27ef5e6f1 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af..237a2cefb3 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281b..4a5c555a36 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e015033..a02fb49a5f 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9f..e26a7c61b2 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a7..c48f7c2103 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d901..ad4b9aace7 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c308d..b622533ef2 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb79..cfe6646baf 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda647..13f624f69f 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 057700111e..fe222b75df 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1d..1bc1a5adb2 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b7..1851df14e8 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316..0b43c69365 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd..e1ec0dbe4e 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6..880c6d6e31 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db..7c8452a63e 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f90..b8ef95b0fa 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072f..2ffdf861f7 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121..2af3b5c762 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e..1da08d5267 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c..b7a251353b 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c8..6e85b0aac9 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d..f15dadf055 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed584..28b487df25 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b..1e7f321e43 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58..524b0820cb 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d..d3e38f681a 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131..70b35bf3b0 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d..6c778c2327 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf..37281cf51a 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018da..7e567f1eff 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b81..38ae55e5ef 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a..55e92e60a8 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39f..60658d6a02 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435..e203e8a7ed 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b44..5944b97d54 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d..c66d416dad 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7..9889f6a559 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad50..01d86825bb 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741..7b703e77cd 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/ztypes_linux.go b/sdk/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b83485..7f1961b907 100644 --- a/sdk/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/sdk/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/sdk/vendor/golang.org/x/sys/windows/security_windows.go b/sdk/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5bd0..b6e1ab76f8 100644 --- a/sdk/vendor/golang.org/x/sys/windows/security_windows.go +++ b/sdk/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/sdk/vendor/golang.org/x/sys/windows/syscall_windows.go b/sdk/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c..1fa34fd17c 100644 --- a/sdk/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/sdk/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/sdk/vendor/golang.org/x/sys/windows/types_windows.go b/sdk/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a..3f03b3d57c 100644 --- a/sdk/vendor/golang.org/x/sys/windows/types_windows.go +++ b/sdk/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/sdk/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/sdk/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba761018a..9bb979a3e4 100644 --- a/sdk/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/sdk/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/sdk/vendor/modules.txt b/sdk/vendor/modules.txt index 0e518d815f..c9841dbd19 100644 --- a/sdk/vendor/modules.txt +++ b/sdk/vendor/modules.txt @@ -79,7 +79,7 @@ golang.org/x/net/trace # golang.org/x/sync v0.7.0 ## explicit; go 1.18 golang.org/x/sync/errgroup -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/unix golang.org/x/sys/windows diff --git a/src/core/metrics/sources/mem.go b/src/core/metrics/sources/mem.go index 6b0c7e9fdf..a3177253d3 100644 --- a/src/core/metrics/sources/mem.go +++ b/src/core/metrics/sources/mem.go @@ -59,7 +59,7 @@ func (c *VirtualMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEnti "available": float64(memstats.Available), }) - log.Debugf("Memory metrics collected: %v", len(simpleMetrics)) + log.Debugf("Memory metrics count: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/src/core/tailer/tailer.go b/src/core/tailer/tailer.go index ab9f0e1768..52c430ce9c 100644 --- a/src/core/tailer/tailer.go +++ b/src/core/tailer/tailer.go @@ -20,7 +20,7 @@ import ( var tailConfig = tail.Config{ Follow: true, - ReOpen: false, + ReOpen: true, MustExist: true, Poll: true, Location: &tail.SeekInfo{ @@ -127,6 +127,8 @@ func (t *Tailer) Tail(ctx context.Context, data chan<- string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + t.handle.Stop() + t.handle.Cleanup() log.Trace("Tailer is done") return } @@ -156,6 +158,7 @@ func (t *PatternTailer) Tail(ctx context.Context, data chan<- map[string]string) case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + t.handle.Cleanup() log.Tracef("Tailer is done") return } @@ -185,6 +188,7 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } log.Tracef("Tailer is done") + t.handle.Cleanup() return } } diff --git a/src/core/tailer/tailer_test.go b/src/core/tailer/tailer_test.go index 251838ecf4..0cafbd3c84 100644 --- a/src/core/tailer/tailer_test.go +++ b/src/core/tailer/tailer_test.go @@ -10,6 +10,7 @@ package tailer import ( "context" "os" + "sync" "testing" "time" @@ -70,11 +71,17 @@ func TestTailer(t *testing.T) { timeoutDuration := time.Millisecond * 300 ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration) - defer cancel() data := make(chan string, 100) - go tailer.Tail(ctx, data) - + + wg := sync.WaitGroup{} + wg.Add(1) + + go func () { + tailer.Tail(ctx, data) + wg.Done() + }() + time.Sleep(time.Millisecond * 100) _, err = errorLogFile.WriteString(logLine) if err != nil { @@ -95,9 +102,14 @@ T: break T } } + cancel() + + wg.Wait() os.Remove(errorLogFile.Name()) assert.Equal(t, 1, count) + + time.Sleep(500 * time.Millisecond) } func TestPatternTailer(t *testing.T) { diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index f9a6b381d5..d4ba738c56 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -231,7 +231,6 @@ func (m *Metrics) drainBuffer(ctx context.Context) { func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // set a timeout for a millisecond less than the collection interval ctx := context.Background() - // defer cancel() // locks the m.collectors to make sure it doesn't get deleted in the middle // of collection, as we will delete the old one if config changes. // maybe we can fine tune the lock later, but the collection has been very quick so far. diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index b108bfdb02..a3ebbaa1a7 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -38,7 +38,6 @@ type MetricsThrottle struct { ctx context.Context cancel context.CancelFunc wg sync.WaitGroup - // mu sync.Mutex env core.Environment conf *config.Config errors chan error diff --git a/test/integration/go.mod b/test/integration/go.mod index f23f029922..efc2f15d35 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -187,7 +187,7 @@ require ( golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/sys v0.24.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/test/integration/go.sum b/test/integration/go.sum index ad1188a24f..8bb7d68290 100644 --- a/test/integration/go.sum +++ b/test/integration/go.sum @@ -706,8 +706,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/test/integration/grpc/grpc_config_apply_test.go b/test/integration/grpc/grpc_config_apply_test.go index dd68e186c5..302949ac39 100644 --- a/test/integration/grpc/grpc_config_apply_test.go +++ b/test/integration/grpc/grpc_config_apply_test.go @@ -94,7 +94,7 @@ func TestRegistrationAndConfigApply(t *testing.T) { t, "grpc-registration-and-config-apply", "./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf", - "The following core plugins have being registered", + "The following core plugins have been registered", ) // Validate that registration is complete diff --git a/test/integration/vendor/golang.org/x/sys/LICENSE b/test/integration/vendor/golang.org/x/sys/LICENSE index 6a66aea5ea..2a7cf70da6 100644 --- a/test/integration/vendor/golang.org/x/sys/LICENSE +++ b/test/integration/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/test/integration/vendor/golang.org/x/sys/cpu/cpu.go b/test/integration/vendor/golang.org/x/sys/cpu/cpu.go index 8fa707aa4b..ec07aab057 100644 --- a/test/integration/vendor/golang.org/x/sys/cpu/cpu.go +++ b/test/integration/vendor/golang.org/x/sys/cpu/cpu.go @@ -105,6 +105,8 @@ var ARM64 struct { HasSVE bool // Scalable Vector Extensions HasSVE2 bool // Scalable Vector Extensions 2 HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32 + HasDIT bool // Data Independent Timing support + HasI8MM bool // Advanced SIMD Int8 matrix multiplication instructions _ CacheLinePad } diff --git a/test/integration/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/test/integration/vendor/golang.org/x/sys/cpu/cpu_arm64.go index 0e27a21e1f..af2aa99f9f 100644 --- a/test/integration/vendor/golang.org/x/sys/cpu/cpu_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/cpu/cpu_arm64.go @@ -38,6 +38,8 @@ func initOptions() { {Name: "dcpop", Feature: &ARM64.HasDCPOP}, {Name: "asimddp", Feature: &ARM64.HasASIMDDP}, {Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, + {Name: "dit", Feature: &ARM64.HasDIT}, + {Name: "i8mm", Feature: &ARM64.HasI8MM}, } } @@ -145,6 +147,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { ARM64.HasLRCPC = true } + switch extractBits(isar1, 52, 55) { + case 1: + ARM64.HasI8MM = true + } + // ID_AA64PFR0_EL1 switch extractBits(pfr0, 16, 19) { case 0: @@ -168,6 +175,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { parseARM64SVERegister(getzfr0()) } + + switch extractBits(pfr0, 48, 51) { + case 1: + ARM64.HasDIT = true + } } func parseARM64SVERegister(zfr0 uint64) { diff --git a/test/integration/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go b/test/integration/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go index 3d386d0fc2..08f35ea177 100644 --- a/test/integration/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go @@ -35,8 +35,10 @@ const ( hwcap_SHA512 = 1 << 21 hwcap_SVE = 1 << 22 hwcap_ASIMDFHM = 1 << 23 + hwcap_DIT = 1 << 24 hwcap2_SVE2 = 1 << 1 + hwcap2_I8MM = 1 << 13 ) // linuxKernelCanEmulateCPUID reports whether we're running @@ -106,9 +108,12 @@ func doinit() { ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512) ARM64.HasSVE = isSet(hwCap, hwcap_SVE) ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM) + ARM64.HasDIT = isSet(hwCap, hwcap_DIT) + // HWCAP2 feature bits ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2) + ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM) } func isSet(hwc uint, value uint) bool { diff --git a/test/integration/vendor/golang.org/x/sys/unix/mkerrors.sh b/test/integration/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b6..d07dd09eb5 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/test/integration/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/test/integration/vendor/golang.org/x/sys/unix/syscall_darwin.go b/test/integration/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b00596..2d15200adb 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/test/integration/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/test/integration/vendor/golang.org/x/sys/unix/syscall_linux.go b/test/integration/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628a..3f1d3d4cb2 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/test/integration/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/test/integration/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/test/integration/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a..b86ded549c 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/test/integration/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245..4308ac1772 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c05..c8068a7a16 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479..01a70b2463 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c..684a5168da 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdb..61d74b592d 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac3..a28c9e3e89 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b0..ab5d1fe8ea 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb..c523090e7c 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb4..01e6ea7804 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78..7aa610b1e7 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da..92af771b44 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b..b27ef5e6f1 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af..237a2cefb3 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281b..4a5c555a36 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e015033..a02fb49a5f 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9f..e26a7c61b2 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a7..c48f7c2103 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d901..ad4b9aace7 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c308d..b622533ef2 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb79..cfe6646baf 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda647..13f624f69f 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 057700111e..fe222b75df 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1d..1bc1a5adb2 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b7..1851df14e8 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316..0b43c69365 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd..e1ec0dbe4e 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6..880c6d6e31 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db..7c8452a63e 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f90..b8ef95b0fa 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072f..2ffdf861f7 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121..2af3b5c762 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e..1da08d5267 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c..b7a251353b 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c8..6e85b0aac9 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d..f15dadf055 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed584..28b487df25 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b..1e7f321e43 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58..524b0820cb 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d..d3e38f681a 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131..70b35bf3b0 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d..6c778c2327 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf..37281cf51a 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018da..7e567f1eff 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b81..38ae55e5ef 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a..55e92e60a8 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39f..60658d6a02 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435..e203e8a7ed 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b44..5944b97d54 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d..c66d416dad 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7..9889f6a559 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad50..01d86825bb 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741..7b703e77cd 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/ztypes_linux.go b/test/integration/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b83485..7f1961b907 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/test/integration/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/test/integration/vendor/golang.org/x/sys/windows/security_windows.go b/test/integration/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5bd0..b6e1ab76f8 100644 --- a/test/integration/vendor/golang.org/x/sys/windows/security_windows.go +++ b/test/integration/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/test/integration/vendor/golang.org/x/sys/windows/syscall_windows.go b/test/integration/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c..1fa34fd17c 100644 --- a/test/integration/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/test/integration/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/test/integration/vendor/golang.org/x/sys/windows/types_windows.go b/test/integration/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a..3f03b3d57c 100644 --- a/test/integration/vendor/golang.org/x/sys/windows/types_windows.go +++ b/test/integration/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/test/integration/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/test/integration/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba761018a..9bb979a3e4 100644 --- a/test/integration/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/test/integration/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/test/integration/vendor/modules.txt b/test/integration/vendor/modules.txt index 42170d97ab..8145f90040 100644 --- a/test/integration/vendor/modules.txt +++ b/test/integration/vendor/modules.txt @@ -1007,7 +1007,7 @@ golang.org/x/oauth2/internal golang.org/x/sync/errgroup golang.org/x/sync/semaphore golang.org/x/sync/singleflight -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/execabs diff --git a/test/performance/go.mod b/test/performance/go.mod index 6270306223..4986b7fbda 100644 --- a/test/performance/go.mod +++ b/test/performance/go.mod @@ -81,7 +81,7 @@ require ( golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.23.0 // indirect diff --git a/test/performance/go.sum b/test/performance/go.sum index f781ad5759..d8f87fdb9c 100644 --- a/test/performance/go.sum +++ b/test/performance/go.sum @@ -274,8 +274,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go index 6b0c7e9fdf..a3177253d3 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go @@ -59,7 +59,7 @@ func (c *VirtualMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEnti "available": float64(memstats.Available), }) - log.Debugf("Memory metrics collected: %v", len(simpleMetrics)) + log.Debugf("Memory metrics count: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go index ab9f0e1768..52c430ce9c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go @@ -20,7 +20,7 @@ import ( var tailConfig = tail.Config{ Follow: true, - ReOpen: false, + ReOpen: true, MustExist: true, Poll: true, Location: &tail.SeekInfo{ @@ -127,6 +127,8 @@ func (t *Tailer) Tail(ctx context.Context, data chan<- string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + t.handle.Stop() + t.handle.Cleanup() log.Trace("Tailer is done") return } @@ -156,6 +158,7 @@ func (t *PatternTailer) Tail(ctx context.Context, data chan<- map[string]string) case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + t.handle.Cleanup() log.Tracef("Tailer is done") return } @@ -185,6 +188,7 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } log.Tracef("Tailer is done") + t.handle.Cleanup() return } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index f9a6b381d5..d4ba738c56 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -231,7 +231,6 @@ func (m *Metrics) drainBuffer(ctx context.Context) { func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // set a timeout for a millisecond less than the collection interval ctx := context.Background() - // defer cancel() // locks the m.collectors to make sure it doesn't get deleted in the middle // of collection, as we will delete the old one if config changes. // maybe we can fine tune the lock later, but the collection has been very quick so far. diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index b108bfdb02..a3ebbaa1a7 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -38,7 +38,6 @@ type MetricsThrottle struct { ctx context.Context cancel context.CancelFunc wg sync.WaitGroup - // mu sync.Mutex env core.Environment conf *config.Config errors chan error diff --git a/test/performance/vendor/golang.org/x/sys/LICENSE b/test/performance/vendor/golang.org/x/sys/LICENSE index 6a66aea5ea..2a7cf70da6 100644 --- a/test/performance/vendor/golang.org/x/sys/LICENSE +++ b/test/performance/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/test/performance/vendor/golang.org/x/sys/cpu/cpu.go b/test/performance/vendor/golang.org/x/sys/cpu/cpu.go index 8fa707aa4b..ec07aab057 100644 --- a/test/performance/vendor/golang.org/x/sys/cpu/cpu.go +++ b/test/performance/vendor/golang.org/x/sys/cpu/cpu.go @@ -105,6 +105,8 @@ var ARM64 struct { HasSVE bool // Scalable Vector Extensions HasSVE2 bool // Scalable Vector Extensions 2 HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32 + HasDIT bool // Data Independent Timing support + HasI8MM bool // Advanced SIMD Int8 matrix multiplication instructions _ CacheLinePad } diff --git a/test/performance/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/test/performance/vendor/golang.org/x/sys/cpu/cpu_arm64.go index 0e27a21e1f..af2aa99f9f 100644 --- a/test/performance/vendor/golang.org/x/sys/cpu/cpu_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/cpu/cpu_arm64.go @@ -38,6 +38,8 @@ func initOptions() { {Name: "dcpop", Feature: &ARM64.HasDCPOP}, {Name: "asimddp", Feature: &ARM64.HasASIMDDP}, {Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, + {Name: "dit", Feature: &ARM64.HasDIT}, + {Name: "i8mm", Feature: &ARM64.HasI8MM}, } } @@ -145,6 +147,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { ARM64.HasLRCPC = true } + switch extractBits(isar1, 52, 55) { + case 1: + ARM64.HasI8MM = true + } + // ID_AA64PFR0_EL1 switch extractBits(pfr0, 16, 19) { case 0: @@ -168,6 +175,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { parseARM64SVERegister(getzfr0()) } + + switch extractBits(pfr0, 48, 51) { + case 1: + ARM64.HasDIT = true + } } func parseARM64SVERegister(zfr0 uint64) { diff --git a/test/performance/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go b/test/performance/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go index 3d386d0fc2..08f35ea177 100644 --- a/test/performance/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go @@ -35,8 +35,10 @@ const ( hwcap_SHA512 = 1 << 21 hwcap_SVE = 1 << 22 hwcap_ASIMDFHM = 1 << 23 + hwcap_DIT = 1 << 24 hwcap2_SVE2 = 1 << 1 + hwcap2_I8MM = 1 << 13 ) // linuxKernelCanEmulateCPUID reports whether we're running @@ -106,9 +108,12 @@ func doinit() { ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512) ARM64.HasSVE = isSet(hwCap, hwcap_SVE) ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM) + ARM64.HasDIT = isSet(hwCap, hwcap_DIT) + // HWCAP2 feature bits ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2) + ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM) } func isSet(hwc uint, value uint) bool { diff --git a/test/performance/vendor/golang.org/x/sys/unix/mkerrors.sh b/test/performance/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b6..d07dd09eb5 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/test/performance/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/test/performance/vendor/golang.org/x/sys/unix/syscall_darwin.go b/test/performance/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b00596..2d15200adb 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/test/performance/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/test/performance/vendor/golang.org/x/sys/unix/syscall_linux.go b/test/performance/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628a..3f1d3d4cb2 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/test/performance/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/test/performance/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/test/performance/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a..b86ded549c 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/test/performance/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245..4308ac1772 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c05..c8068a7a16 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479..01a70b2463 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c..684a5168da 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdb..61d74b592d 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac3..a28c9e3e89 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b0..ab5d1fe8ea 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb..c523090e7c 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb4..01e6ea7804 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78..7aa610b1e7 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da..92af771b44 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b..b27ef5e6f1 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af..237a2cefb3 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281b..4a5c555a36 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e015033..a02fb49a5f 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9f..e26a7c61b2 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a7..c48f7c2103 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d901..ad4b9aace7 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c308d..b622533ef2 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb79..cfe6646baf 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda647..13f624f69f 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 057700111e..fe222b75df 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1d..1bc1a5adb2 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b7..1851df14e8 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316..0b43c69365 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd..e1ec0dbe4e 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6..880c6d6e31 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db..7c8452a63e 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f90..b8ef95b0fa 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072f..2ffdf861f7 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121..2af3b5c762 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e..1da08d5267 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c..b7a251353b 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c8..6e85b0aac9 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d..f15dadf055 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed584..28b487df25 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b..1e7f321e43 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58..524b0820cb 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d..d3e38f681a 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131..70b35bf3b0 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d..6c778c2327 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf..37281cf51a 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018da..7e567f1eff 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b81..38ae55e5ef 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a..55e92e60a8 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39f..60658d6a02 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435..e203e8a7ed 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b44..5944b97d54 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d..c66d416dad 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7..9889f6a559 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad50..01d86825bb 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741..7b703e77cd 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/ztypes_linux.go b/test/performance/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b83485..7f1961b907 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/test/performance/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/test/performance/vendor/golang.org/x/sys/windows/security_windows.go b/test/performance/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5bd0..b6e1ab76f8 100644 --- a/test/performance/vendor/golang.org/x/sys/windows/security_windows.go +++ b/test/performance/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/test/performance/vendor/golang.org/x/sys/windows/syscall_windows.go b/test/performance/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c..1fa34fd17c 100644 --- a/test/performance/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/test/performance/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/test/performance/vendor/golang.org/x/sys/windows/types_windows.go b/test/performance/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a..3f03b3d57c 100644 --- a/test/performance/vendor/golang.org/x/sys/windows/types_windows.go +++ b/test/performance/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/test/performance/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/test/performance/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba761018a..9bb979a3e4 100644 --- a/test/performance/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/test/performance/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/test/performance/vendor/modules.txt b/test/performance/vendor/modules.txt index 1106fc7f9d..c249f8da63 100644 --- a/test/performance/vendor/modules.txt +++ b/test/performance/vendor/modules.txt @@ -372,7 +372,7 @@ golang.org/x/net/trace ## explicit; go 1.18 golang.org/x/sync/errgroup golang.org/x/sync/singleflight -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/unix diff --git a/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE index 6a66aea5ea..2a7cf70da6 100644 --- a/vendor/golang.org/x/sys/LICENSE +++ b/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b6..d07dd09eb5 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b00596..2d15200adb 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628a..3f1d3d4cb2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a..b86ded549c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245..4308ac1772 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c05..c8068a7a16 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479..01a70b2463 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c..684a5168da 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdb..61d74b592d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac3..a28c9e3e89 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b0..ab5d1fe8ea 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb..c523090e7c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb4..01e6ea7804 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78..7aa610b1e7 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da..92af771b44 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b..b27ef5e6f1 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af..237a2cefb3 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281b..4a5c555a36 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e015033..a02fb49a5f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9f..e26a7c61b2 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a7..c48f7c2103 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d901..ad4b9aace7 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c308d..b622533ef2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb79..cfe6646baf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda647..13f624f69f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 057700111e..fe222b75df 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1d..1bc1a5adb2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b7..1851df14e8 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316..0b43c69365 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd..e1ec0dbe4e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6..880c6d6e31 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db..7c8452a63e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f90..b8ef95b0fa 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072f..2ffdf861f7 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121..2af3b5c762 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e..1da08d5267 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c..b7a251353b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c8..6e85b0aac9 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d..f15dadf055 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed584..28b487df25 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b..1e7f321e43 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58..524b0820cb 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d..d3e38f681a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131..70b35bf3b0 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d..6c778c2327 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf..37281cf51a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018da..7e567f1eff 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b81..38ae55e5ef 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a..55e92e60a8 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39f..60658d6a02 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435..e203e8a7ed 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b44..5944b97d54 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d..c66d416dad 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7..9889f6a559 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad50..01d86825bb 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741..7b703e77cd 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b83485..7f1961b907 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5bd0..b6e1ab76f8 100644 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ b/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c..1fa34fd17c 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a..3f03b3d57c 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba761018a..9bb979a3e4 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/vendor/modules.txt b/vendor/modules.txt index 87663b50c3..cef883482e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -289,7 +289,7 @@ golang.org/x/net/trace ## explicit; go 1.18 golang.org/x/sync/errgroup golang.org/x/sync/singleflight -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/unix golang.org/x/sys/windows From 03e410e471cff16c5d51e1901431651a8d26f1a3 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 13:44:45 +0100 Subject: [PATCH 28/49] fixed unit tests --- src/core/metrics/sources/load.go | 2 +- src/core/tailer/tailer.go | 23 ++++++++++++++---- src/core/tailer/tailer_test.go | 24 ++++++++----------- .../agent/v2/src/core/metrics/sources/load.go | 2 +- .../nginx/agent/v2/src/core/tailer/tailer.go | 23 ++++++++++++++---- 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/core/metrics/sources/load.go b/src/core/metrics/sources/load.go index e4395f01b4..d71cde8a0e 100644 --- a/src/core/metrics/sources/load.go +++ b/src/core/metrics/sources/load.go @@ -40,7 +40,7 @@ func (c *Load) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper "15": loadStats.Load15, }) - log.Debugf("load metrics collected: %v", len(simpleMetrics)) + log.Debugf("load metrics count: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/src/core/tailer/tailer.go b/src/core/tailer/tailer.go index 52c430ce9c..2980ee6c3f 100644 --- a/src/core/tailer/tailer.go +++ b/src/core/tailer/tailer.go @@ -127,8 +127,11 @@ func (t *Tailer) Tail(ctx context.Context, data chan<- string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } - t.handle.Stop() - t.handle.Cleanup() + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } log.Trace("Tailer is done") return } @@ -158,7 +161,13 @@ func (t *PatternTailer) Tail(ctx context.Context, data chan<- map[string]string) case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } - t.handle.Cleanup() + + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } + log.Tracef("Tailer is done") return } @@ -187,8 +196,14 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } + log.Tracef("Tailer is done") - t.handle.Cleanup() return } } diff --git a/src/core/tailer/tailer_test.go b/src/core/tailer/tailer_test.go index 0cafbd3c84..a2bf4716bb 100644 --- a/src/core/tailer/tailer_test.go +++ b/src/core/tailer/tailer_test.go @@ -10,7 +10,6 @@ package tailer import ( "context" "os" - "sync" "testing" "time" @@ -74,13 +73,7 @@ func TestTailer(t *testing.T) { data := make(chan string, 100) - wg := sync.WaitGroup{} - wg.Add(1) - - go func () { - tailer.Tail(ctx, data) - wg.Done() - }() + go tailer.Tail(ctx, data) time.Sleep(time.Millisecond * 100) _, err = errorLogFile.WriteString(logLine) @@ -104,8 +97,6 @@ T: } cancel() - wg.Wait() - os.Remove(errorLogFile.Name()) assert.Equal(t, 1, count) @@ -114,18 +105,19 @@ T: func TestPatternTailer(t *testing.T) { accessLogFile, _ := os.CreateTemp(os.TempDir(), "access.log") - logLine := "127.0.0.1 - - [19/May/2022:09:30:39 +0000] \"GET /nginx_status HTTP/1.1\" 500 98 \"-\" \"Go-http-client/1.1\" \"-\"\n" + logLine := "127.0.0.1 - - [19/May/2022:09:30:39 +0000] \"GET /nginx_status HTTP/1.1\" 500 98 \"-\" \"Go-http-client/1.1\"" tailer, err := NewPatternTailer(accessLogFile.Name(), defaultPatterns) require.Nil(t, err) timeoutDuration := time.Millisecond * 300 + ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration) - defer cancel() data := make(chan map[string]string, 100) + go tailer.Tail(ctx, data) - + time.Sleep(time.Millisecond * 100) _, err = accessLogFile.WriteString(logLine) if err != nil { @@ -137,7 +129,8 @@ func TestPatternTailer(t *testing.T) { T: for { select { - case <-data: + case d := <-data: + assert.Equal(t, logLine, d["DEFAULT"]) count++ case <-time.After(timeoutDuration): break T @@ -145,9 +138,12 @@ T: break T } } + cancel() os.Remove(accessLogFile.Name()) assert.Equal(t, 1, count) + + time.Sleep(500 * time.Millisecond) } func TestLTSVTailer(t *testing.T) { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go index e4395f01b4..d71cde8a0e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go @@ -40,7 +40,7 @@ func (c *Load) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper "15": loadStats.Load15, }) - log.Debugf("load metrics collected: %v", len(simpleMetrics)) + log.Debugf("load metrics count: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go index 52c430ce9c..2980ee6c3f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go @@ -127,8 +127,11 @@ func (t *Tailer) Tail(ctx context.Context, data chan<- string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } - t.handle.Stop() - t.handle.Cleanup() + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } log.Trace("Tailer is done") return } @@ -158,7 +161,13 @@ func (t *PatternTailer) Tail(ctx context.Context, data chan<- map[string]string) case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } - t.handle.Cleanup() + + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } + log.Tracef("Tailer is done") return } @@ -187,8 +196,14 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } + log.Tracef("Tailer is done") - t.handle.Cleanup() return } } From b67ed8b2e6fc5ab8df1abde1db3779c471191e82 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 14:04:27 +0100 Subject: [PATCH 29/49] testing int --- src/plugins/agent_api.go | 4 ++-- src/plugins/metrics.go | 8 ++++---- .../github.com/nginx/agent/v2/src/plugins/agent_api.go | 4 ++-- .../github.com/nginx/agent/v2/src/plugins/metrics.go | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/plugins/agent_api.go b/src/plugins/agent_api.go index ba212bd7cc..aa5227d71e 100644 --- a/src/plugins/agent_api.go +++ b/src/plugins/agent_api.go @@ -204,7 +204,7 @@ func (a *AgentAPI) Process(message *core.Message) { default: log.Warnf("Unknown Command_NginxConfigResponse type: %T(%v)", message.Data(), message.Data()) } - case core.MetricReport: + case core.CommMetrics: switch response := message.Data().(type) { case *metrics.MetricsReportBundle: a.exporter.SetLatestMetricReport(response) @@ -240,7 +240,6 @@ func (a *AgentAPI) Info() *core.Info { func (a *AgentAPI) Subscriptions() []string { return []string{ core.AgentAPIConfigApplyResponse, - core.MetricReport, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, @@ -248,6 +247,7 @@ func (a *AgentAPI) Subscriptions() []string { core.AgentConnected, core.CommandSent, core.MetricReportSent, + core.CommMetrics, } } diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index d4ba738c56..0ac475f5fa 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -44,7 +44,7 @@ type Metrics struct { } func NewMetrics(config *config.Config, env core.Environment, binary core.NginxBinary, processes []*core.Process) *Metrics { - collectorConfigsMap := createCollectorConfigsMap(config, env, binary, processes) + collectorConfigsMap := createCollectorConfigsMap(config, binary, processes) return &Metrics{ collectorsUpdate: atomic.NewBool(false), ticker: time.NewTicker(config.AgentMetrics.CollectionInterval), @@ -81,7 +81,7 @@ func (m *Metrics) Process(msg *core.Message) { case msg.Exact(core.AgentConfigChanged), msg.Exact(core.NginxConfigApplySucceeded): // If the agent config on disk changed or the NGINX statusAPI was updated // Then update Metrics with relevant config info - collectorConfigsMap := createCollectorConfigsMap(m.conf, m.env, m.binary, m.getNginxProccessInfo()) + collectorConfigsMap := createCollectorConfigsMap(m.conf, m.binary, m.getNginxProccessInfo()) m.collectorConfigsMapMutex.Lock() m.collectorConfigsMap = collectorConfigsMap m.collectorConfigsMapMutex.Unlock() @@ -102,7 +102,7 @@ func (m *Metrics) Process(msg *core.Message) { case msg.Exact(core.NginxDetailProcUpdate): m.syncProcessInfo(msg.Data().([]*core.Process)) - collectorConfigsMap := createCollectorConfigsMap(m.conf, m.env, m.binary, m.getNginxProccessInfo()) + collectorConfigsMap := createCollectorConfigsMap(m.conf, m.binary, m.getNginxProccessInfo()) for key, collectorConfig := range collectorConfigsMap { if _, ok := m.collectorConfigsMap[key]; !ok { log.Debugf("Adding new nginx collector for nginx id: %s", collectorConfig.NginxId) @@ -301,7 +301,7 @@ func (m *Metrics) syncAgentConfigChange() { m.conf = conf } -func createCollectorConfigsMap(config *config.Config, env core.Environment, binary core.NginxBinary, processes []*core.Process) map[string]*metrics.NginxCollectorConfig { +func createCollectorConfigsMap(config *config.Config, binary core.NginxBinary, processes []*core.Process) map[string]*metrics.NginxCollectorConfig { collectorConfigsMap := make(map[string]*metrics.NginxCollectorConfig) for _, p := range processes { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go index ba212bd7cc..aa5227d71e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go @@ -204,7 +204,7 @@ func (a *AgentAPI) Process(message *core.Message) { default: log.Warnf("Unknown Command_NginxConfigResponse type: %T(%v)", message.Data(), message.Data()) } - case core.MetricReport: + case core.CommMetrics: switch response := message.Data().(type) { case *metrics.MetricsReportBundle: a.exporter.SetLatestMetricReport(response) @@ -240,7 +240,6 @@ func (a *AgentAPI) Info() *core.Info { func (a *AgentAPI) Subscriptions() []string { return []string{ core.AgentAPIConfigApplyResponse, - core.MetricReport, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, @@ -248,6 +247,7 @@ func (a *AgentAPI) Subscriptions() []string { core.AgentConnected, core.CommandSent, core.MetricReportSent, + core.CommMetrics, } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index d4ba738c56..0ac475f5fa 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -44,7 +44,7 @@ type Metrics struct { } func NewMetrics(config *config.Config, env core.Environment, binary core.NginxBinary, processes []*core.Process) *Metrics { - collectorConfigsMap := createCollectorConfigsMap(config, env, binary, processes) + collectorConfigsMap := createCollectorConfigsMap(config, binary, processes) return &Metrics{ collectorsUpdate: atomic.NewBool(false), ticker: time.NewTicker(config.AgentMetrics.CollectionInterval), @@ -81,7 +81,7 @@ func (m *Metrics) Process(msg *core.Message) { case msg.Exact(core.AgentConfigChanged), msg.Exact(core.NginxConfigApplySucceeded): // If the agent config on disk changed or the NGINX statusAPI was updated // Then update Metrics with relevant config info - collectorConfigsMap := createCollectorConfigsMap(m.conf, m.env, m.binary, m.getNginxProccessInfo()) + collectorConfigsMap := createCollectorConfigsMap(m.conf, m.binary, m.getNginxProccessInfo()) m.collectorConfigsMapMutex.Lock() m.collectorConfigsMap = collectorConfigsMap m.collectorConfigsMapMutex.Unlock() @@ -102,7 +102,7 @@ func (m *Metrics) Process(msg *core.Message) { case msg.Exact(core.NginxDetailProcUpdate): m.syncProcessInfo(msg.Data().([]*core.Process)) - collectorConfigsMap := createCollectorConfigsMap(m.conf, m.env, m.binary, m.getNginxProccessInfo()) + collectorConfigsMap := createCollectorConfigsMap(m.conf, m.binary, m.getNginxProccessInfo()) for key, collectorConfig := range collectorConfigsMap { if _, ok := m.collectorConfigsMap[key]; !ok { log.Debugf("Adding new nginx collector for nginx id: %s", collectorConfig.NginxId) @@ -301,7 +301,7 @@ func (m *Metrics) syncAgentConfigChange() { m.conf = conf } -func createCollectorConfigsMap(config *config.Config, env core.Environment, binary core.NginxBinary, processes []*core.Process) map[string]*metrics.NginxCollectorConfig { +func createCollectorConfigsMap(config *config.Config, binary core.NginxBinary, processes []*core.Process) map[string]*metrics.NginxCollectorConfig { collectorConfigsMap := make(map[string]*metrics.NginxCollectorConfig) for _, p := range processes { From dbfa9f2ac0e54a635f084c0672fca3bb6cf15102 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 14:31:29 +0100 Subject: [PATCH 30/49] fix some tests --- src/plugins/agent_api_test.go | 4 ++-- src/plugins/metrics_throlling.go | 2 -- .../nginx/agent/v2/src/plugins/metrics_throlling.go | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/plugins/agent_api_test.go b/src/plugins/agent_api_test.go index 39a05368f0..7a74ceaa76 100644 --- a/src/plugins/agent_api_test.go +++ b/src/plugins/agent_api_test.go @@ -51,7 +51,6 @@ func TestAgentAPI_Info(t *testing.T) { func TestAgentAPI_Subscriptions(t *testing.T) { expectedSubscriptions := []string{ core.AgentAPIConfigApplyResponse, - core.MetricReport, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, @@ -59,6 +58,7 @@ func TestAgentAPI_Subscriptions(t *testing.T) { core.AgentConnected, core.CommandSent, core.MetricReportSent, + core.CommMetrics, } agentAPI := AgentAPI{} @@ -420,7 +420,7 @@ func TestProcess_metricReport(t *testing.T) { // Check that latest metric report isn't set assert.NotEqual(t, metricReport, agentAPI.exporter.GetLatestMetricReports()[0]) - agentAPI.Process(core.NewMessage(core.MetricReport, metricReportBundle)) + agentAPI.Process(core.NewMessage(core.CommMetrics, metricReportBundle)) // Check that latest metric report matches the report that was processed assert.Equal(t, metricReport, agentAPI.exporter.GetLatestMetricReports()[0]) diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index a3ebbaa1a7..5a9bba0bbd 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -93,7 +93,6 @@ func (r *MetricsThrottle) Process(msg *core.Message) { switch bundle := msg.Data().(type) { case *metrics.MetricsReportBundle: if len(bundle.Data) > 0 { - // r.mu.Lock() for _, report := range bundle.Data { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { @@ -107,7 +106,6 @@ func (r *MetricsThrottle) Process(msg *core.Message) { log.Debugf("MetricsThrottle: Metrics collection saved [Type: %d]", report.Type) } } - // r.mu.Unlock() r.reportsReady.Store(true) } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index a3ebbaa1a7..5a9bba0bbd 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -93,7 +93,6 @@ func (r *MetricsThrottle) Process(msg *core.Message) { switch bundle := msg.Data().(type) { case *metrics.MetricsReportBundle: if len(bundle.Data) > 0 { - // r.mu.Lock() for _, report := range bundle.Data { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { @@ -107,7 +106,6 @@ func (r *MetricsThrottle) Process(msg *core.Message) { log.Debugf("MetricsThrottle: Metrics collection saved [Type: %d]", report.Type) } } - // r.mu.Unlock() r.reportsReady.Store(true) } } From 731e47f67b97116bc09c113f190828e02ffc9e1c Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 14:56:29 +0100 Subject: [PATCH 31/49] removed close from pipe --- src/core/pipe.go | 16 +++++----- src/core/pipe_test.go | 30 +++++++------------ src/core/signals.go | 1 - src/plugins/agent_api.go | 2 +- src/plugins/features.go | 22 +++++++------- src/plugins/registration.go | 2 +- .../nginx/agent/v2/src/core/pipe.go | 16 +++++----- .../nginx/agent/v2/src/core/signals.go | 1 - .../nginx/agent/v2/src/core/pipe.go | 16 +++++----- .../nginx/agent/v2/src/core/signals.go | 1 - .../nginx/agent/v2/src/plugins/agent_api.go | 2 +- .../nginx/agent/v2/src/plugins/features.go | 22 +++++++------- .../agent/v2/src/plugins/registration.go | 2 +- 13 files changed, 60 insertions(+), 73 deletions(-) diff --git a/src/core/pipe.go b/src/core/pipe.go index 226876f27c..47311e79dc 100644 --- a/src/core/pipe.go +++ b/src/core/pipe.go @@ -29,7 +29,6 @@ type MessagePipeInterface interface { GetPlugins() []Plugin GetExtensionPlugins() []ExtensionPlugin IsPluginAlreadyRegistered(string) bool - Close() } type MessagePipe struct { @@ -129,10 +128,6 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { return nil } -func (p *MessagePipe) Close() { - p.cleanup() -} - func getIndex(pluginName string, plugins []Plugin) int { for index, plugin := range plugins { if pluginName == plugin.Info().Name() { @@ -146,7 +141,6 @@ func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { case <-p.ctx.Done(): - p.cleanup() return case p.messageChannel <- m: default: @@ -190,16 +184,22 @@ func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { } func (p *MessagePipe) cleanup() { + p.mu.RLock() + defer p.mu.RUnlock() for _, r := range p.plugins { for _, subscription := range r.Subscriptions() { - p.bus.Close(subscription) + if p.bus != nil { + p.bus.Close(subscription) + } } r.Close() } for _, r := range p.extensionPlugins { for _, subscription := range r.Subscriptions() { - p.bus.Close(subscription) + if p.bus != nil { + p.bus.Close(subscription) + } } r.Close() } diff --git a/src/core/pipe_test.go b/src/core/pipe_test.go index 6c8585ffcf..fc47645b75 100644 --- a/src/core/pipe_test.go +++ b/src/core/pipe_test.go @@ -41,22 +41,6 @@ func (p *testPlugin) Subscriptions() []string { return []string{"test.message"} } -func TestMessagePipe_Register(t *testing.T) { - plugin := new(testPlugin) - plugin.On("Close").Times(1) - - ctx, cancel := context.WithCancel(context.Background()) - - messagePipe := NewMessagePipe(ctx, 100) - err := messagePipe.Register(10, []Plugin{plugin}, nil) - - require.NoError(t, err) - - cancel() - messagePipe.Close() - plugin.AssertExpectations(t) -} - func TestMessagePipe_Run(t *testing.T) { messages := []*Message{ NewMessage("test.message", 1), @@ -86,7 +70,8 @@ func TestMessagePipe_Run(t *testing.T) { cancel() - pipe.Close() + time.Sleep(200 * time.Millisecond) + plugin.AssertExpectations(t) } @@ -109,24 +94,29 @@ func TestMessagePipe_Process(t *testing.T) { } cancel() - pipe.Close() + time.Sleep(200 * time.Millisecond) } func TestPipe_IsPluginAlreadyRegistered(t *testing.T) { plugin := new(testPlugin) + plugin.On("Init").Times(1) plugin.On("Close").Times(1) ctx, cancel := context.WithCancel(context.Background()) - defer cancel() messagePipe := NewMessagePipe(ctx, 100) err := messagePipe.Register(10, []Plugin{plugin}, nil) require.NoError(t, err) + go messagePipe.Run() + assert.True(t, messagePipe.IsPluginAlreadyRegistered(*plugin.Info().name)) assert.False(t, messagePipe.IsPluginAlreadyRegistered("metrics")) - messagePipe.Close() + cancel() + + time.Sleep(200 * time.Millisecond) + plugin.AssertExpectations(t) } diff --git a/src/core/signals.go b/src/core/signals.go index 70496f0471..c8a1ed8d89 100644 --- a/src/core/signals.go +++ b/src/core/signals.go @@ -63,7 +63,6 @@ func HandleSignals( } log.Warn("NGINX Agent exiting") - pipe.Close() cancel() timeout := time.Second * 5 diff --git a/src/plugins/agent_api.go b/src/plugins/agent_api.go index aa5227d71e..4e9c311d2e 100644 --- a/src/plugins/agent_api.go +++ b/src/plugins/agent_api.go @@ -383,7 +383,7 @@ func (h *NginxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // // 200: []NginxDetails // 500 -func (h *NginxHandler) sendInstanceDetailsPayload(w http.ResponseWriter, r *http.Request) error { +func (h *NginxHandler) sendInstanceDetailsPayload(w http.ResponseWriter, _ *http.Request) error { nginxDetails := h.getNginxDetails() w.WriteHeader(http.StatusOK) diff --git a/src/plugins/features.go b/src/plugins/features.go index 6beeee9f5d..1f38ab54f0 100644 --- a/src/plugins/features.go +++ b/src/plugins/features.go @@ -133,7 +133,7 @@ func (f *Features) Process(msg *core.Message) { } } -func (f *Features) enableMetricsFeature(data string) []core.Plugin { +func (f *Features) enableMetricsFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) { conf, err := config.GetConfig(f.conf.ClientID) @@ -151,7 +151,7 @@ func (f *Features) enableMetricsFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsCollectionFeature(data string) []core.Plugin { +func (f *Features) enableMetricsCollectionFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsCollection) { @@ -168,7 +168,7 @@ func (f *Features) enableMetricsCollectionFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsThrottleFeature(data string) []core.Plugin { +func (f *Features) enableMetricsThrottleFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsThrottle) { @@ -185,7 +185,7 @@ func (f *Features) enableMetricsThrottleFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsSenderFeature(data string) []core.Plugin { +func (f *Features) enableMetricsSenderFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsSender) { @@ -202,7 +202,7 @@ func (f *Features) enableMetricsSenderFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableAgentAPIFeature(data string) []core.Plugin { +func (f *Features) enableAgentAPIFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureAgentAPI) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -217,7 +217,7 @@ func (f *Features) enableAgentAPIFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableRegistrationFeature(data string) []core.Plugin { +func (f *Features) enableRegistrationFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureRegistration) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -232,7 +232,7 @@ func (f *Features) enableRegistrationFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableDataPlaneStatusFeature(data string) []core.Plugin { +func (f *Features) enableDataPlaneStatusFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureDataPlaneStatus) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -247,7 +247,7 @@ func (f *Features) enableDataPlaneStatusFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableProcessWatcherFeature(data string) []core.Plugin { +func (f *Features) enableProcessWatcherFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureProcessWatcher) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -262,7 +262,7 @@ func (f *Features) enableProcessWatcherFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableActivityEventsFeature(data string) []core.Plugin { +func (f *Features) enableActivityEventsFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureActivityEvents) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -277,7 +277,7 @@ func (f *Features) enableActivityEventsFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableFileWatcherFeature(data string) []core.Plugin { +func (f *Features) enableFileWatcherFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureFileWatcher) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -293,7 +293,7 @@ func (f *Features) enableFileWatcherFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableNginxCountingFeature(data string) []core.Plugin { +func (f *Features) enableNginxCountingFeature(_ string) []core.Plugin { countingPlugins := []core.Plugin{} if len(f.conf.Nginx.NginxCountingSocket) > 0 { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureNginxCounting) { diff --git a/src/plugins/registration.go b/src/plugins/registration.go index e4d7d5ac3e..e2c059dff7 100644 --- a/src/plugins/registration.go +++ b/src/plugins/registration.go @@ -148,7 +148,7 @@ func (r *OneTimeRegistration) areDataplaneSoftwareDetailsReady() error { for _, extension := range r.config.Extensions { if _, ok := r.dataplaneSoftwareDetails[extension]; !ok { - return fmt.Errorf("Registration max retries has been met before the extension %s was ready for registration", extension) + return fmt.Errorf("registration max retries has been met before the extension %s was ready for registration", extension) } } diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go index 226876f27c..47311e79dc 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -29,7 +29,6 @@ type MessagePipeInterface interface { GetPlugins() []Plugin GetExtensionPlugins() []ExtensionPlugin IsPluginAlreadyRegistered(string) bool - Close() } type MessagePipe struct { @@ -129,10 +128,6 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { return nil } -func (p *MessagePipe) Close() { - p.cleanup() -} - func getIndex(pluginName string, plugins []Plugin) int { for index, plugin := range plugins { if pluginName == plugin.Info().Name() { @@ -146,7 +141,6 @@ func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { case <-p.ctx.Done(): - p.cleanup() return case p.messageChannel <- m: default: @@ -190,16 +184,22 @@ func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { } func (p *MessagePipe) cleanup() { + p.mu.RLock() + defer p.mu.RUnlock() for _, r := range p.plugins { for _, subscription := range r.Subscriptions() { - p.bus.Close(subscription) + if p.bus != nil { + p.bus.Close(subscription) + } } r.Close() } for _, r := range p.extensionPlugins { for _, subscription := range r.Subscriptions() { - p.bus.Close(subscription) + if p.bus != nil { + p.bus.Close(subscription) + } } r.Close() } diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/signals.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/signals.go index 70496f0471..c8a1ed8d89 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/signals.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/signals.go @@ -63,7 +63,6 @@ func HandleSignals( } log.Warn("NGINX Agent exiting") - pipe.Close() cancel() timeout := time.Second * 5 diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go index 226876f27c..47311e79dc 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -29,7 +29,6 @@ type MessagePipeInterface interface { GetPlugins() []Plugin GetExtensionPlugins() []ExtensionPlugin IsPluginAlreadyRegistered(string) bool - Close() } type MessagePipe struct { @@ -129,10 +128,6 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { return nil } -func (p *MessagePipe) Close() { - p.cleanup() -} - func getIndex(pluginName string, plugins []Plugin) int { for index, plugin := range plugins { if pluginName == plugin.Info().Name() { @@ -146,7 +141,6 @@ func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { case <-p.ctx.Done(): - p.cleanup() return case p.messageChannel <- m: default: @@ -190,16 +184,22 @@ func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { } func (p *MessagePipe) cleanup() { + p.mu.RLock() + defer p.mu.RUnlock() for _, r := range p.plugins { for _, subscription := range r.Subscriptions() { - p.bus.Close(subscription) + if p.bus != nil { + p.bus.Close(subscription) + } } r.Close() } for _, r := range p.extensionPlugins { for _, subscription := range r.Subscriptions() { - p.bus.Close(subscription) + if p.bus != nil { + p.bus.Close(subscription) + } } r.Close() } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/signals.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/signals.go index 70496f0471..c8a1ed8d89 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/signals.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/signals.go @@ -63,7 +63,6 @@ func HandleSignals( } log.Warn("NGINX Agent exiting") - pipe.Close() cancel() timeout := time.Second * 5 diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go index aa5227d71e..4e9c311d2e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go @@ -383,7 +383,7 @@ func (h *NginxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // // 200: []NginxDetails // 500 -func (h *NginxHandler) sendInstanceDetailsPayload(w http.ResponseWriter, r *http.Request) error { +func (h *NginxHandler) sendInstanceDetailsPayload(w http.ResponseWriter, _ *http.Request) error { nginxDetails := h.getNginxDetails() w.WriteHeader(http.StatusOK) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/features.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/features.go index 6beeee9f5d..1f38ab54f0 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/features.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/features.go @@ -133,7 +133,7 @@ func (f *Features) Process(msg *core.Message) { } } -func (f *Features) enableMetricsFeature(data string) []core.Plugin { +func (f *Features) enableMetricsFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) { conf, err := config.GetConfig(f.conf.ClientID) @@ -151,7 +151,7 @@ func (f *Features) enableMetricsFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsCollectionFeature(data string) []core.Plugin { +func (f *Features) enableMetricsCollectionFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsCollection) { @@ -168,7 +168,7 @@ func (f *Features) enableMetricsCollectionFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsThrottleFeature(data string) []core.Plugin { +func (f *Features) enableMetricsThrottleFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsThrottle) { @@ -185,7 +185,7 @@ func (f *Features) enableMetricsThrottleFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsSenderFeature(data string) []core.Plugin { +func (f *Features) enableMetricsSenderFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsSender) { @@ -202,7 +202,7 @@ func (f *Features) enableMetricsSenderFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableAgentAPIFeature(data string) []core.Plugin { +func (f *Features) enableAgentAPIFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureAgentAPI) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -217,7 +217,7 @@ func (f *Features) enableAgentAPIFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableRegistrationFeature(data string) []core.Plugin { +func (f *Features) enableRegistrationFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureRegistration) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -232,7 +232,7 @@ func (f *Features) enableRegistrationFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableDataPlaneStatusFeature(data string) []core.Plugin { +func (f *Features) enableDataPlaneStatusFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureDataPlaneStatus) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -247,7 +247,7 @@ func (f *Features) enableDataPlaneStatusFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableProcessWatcherFeature(data string) []core.Plugin { +func (f *Features) enableProcessWatcherFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureProcessWatcher) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -262,7 +262,7 @@ func (f *Features) enableProcessWatcherFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableActivityEventsFeature(data string) []core.Plugin { +func (f *Features) enableActivityEventsFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureActivityEvents) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -277,7 +277,7 @@ func (f *Features) enableActivityEventsFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableFileWatcherFeature(data string) []core.Plugin { +func (f *Features) enableFileWatcherFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureFileWatcher) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -293,7 +293,7 @@ func (f *Features) enableFileWatcherFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableNginxCountingFeature(data string) []core.Plugin { +func (f *Features) enableNginxCountingFeature(_ string) []core.Plugin { countingPlugins := []core.Plugin{} if len(f.conf.Nginx.NginxCountingSocket) > 0 { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureNginxCounting) { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/registration.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/registration.go index e4d7d5ac3e..e2c059dff7 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/registration.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/registration.go @@ -148,7 +148,7 @@ func (r *OneTimeRegistration) areDataplaneSoftwareDetailsReady() error { for _, extension := range r.config.Extensions { if _, ok := r.dataplaneSoftwareDetails[extension]; !ok { - return fmt.Errorf("Registration max retries has been met before the extension %s was ready for registration", extension) + return fmt.Errorf("registration max retries has been met before the extension %s was ready for registration", extension) } } From 462ab191369eb2c4a56722a90f34fe9bbc39e8ab Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 14:59:13 +0100 Subject: [PATCH 32/49] fix comp test --- test/component/agent_api_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/component/agent_api_test.go b/test/component/agent_api_test.go index 9ef0b1bbb4..f6980074f9 100644 --- a/test/component/agent_api_test.go +++ b/test/component/agent_api_test.go @@ -148,7 +148,7 @@ func TestMetrics(t *testing.T) { agentAPI := plugins.NewAgentAPI(conf, mockEnvironment, mockNginxBinary, []*core.Process{}) agentAPI.Init(core.NewMockMessagePipe(context.TODO())) - agentAPI.Process(core.NewMessage(core.MetricReport, &metrics.MetricsReportBundle{Data: []*proto.MetricsReport{ + agentAPI.Process(core.NewMessage(core.CommMetrics, &metrics.MetricsReportBundle{Data: []*proto.MetricsReport{ { Type: proto.MetricsReport_SYSTEM, Meta: &proto.Metadata{ From 798625b492aa103318dc069c5303dbbd8b13ce49 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 15:48:24 +0100 Subject: [PATCH 33/49] updated agent api to handle new payload --- nginx-agent.conf | 18 ++++++------------ .../prometheus-metrics/prometheus_exporter.go | 11 ++++++++--- src/plugins/agent_api.go | 2 ++ .../prometheus-metrics/prometheus_exporter.go | 11 ++++++++--- .../nginx/agent/v2/src/plugins/agent_api.go | 2 ++ 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/nginx-agent.conf b/nginx-agent.conf index da4660cb87..d0f651b8c2 100644 --- a/nginx-agent.conf +++ b/nginx-agent.conf @@ -28,21 +28,15 @@ metrics: # specify the size of a buffer to build before sending metrics bulk_size: 20 # specify metrics poll interval - report_interval: 1m - collection_interval: 15s + report_interval: 5s + collection_interval: 2s mode: aggregated # OSS NGINX default config path # path to aux file dirs can also be added config_dirs: "/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms" - # api: - # The port at which NGINX Agent accepts remote connections - # The API address and port allow for remote management of NGINX and NGINX Agent - # - # ~~~ WARNING ~~~ - # Set API address to allow remote management - # host: 127.0.0.1 - # - # Set this value to a secure port number to prevent information leaks. - # port: 8038 +api: + + host: 127.0.0.1 + port: 8038 diff --git a/src/extensions/prometheus-metrics/prometheus_exporter.go b/src/extensions/prometheus-metrics/prometheus_exporter.go index a7688a48d5..24880e6c93 100644 --- a/src/extensions/prometheus-metrics/prometheus_exporter.go +++ b/src/extensions/prometheus-metrics/prometheus_exporter.go @@ -4,6 +4,7 @@ import ( "strings" "github.com/nginx/agent/sdk/v2/proto" + "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" "github.com/prometheus/client_golang/prometheus" @@ -21,10 +22,14 @@ func (e *Exporter) SetLatestMetricReport(latest *metrics.MetricsReportBundle) { e.latestMetricReports = latest } -func (e *Exporter) GetLatestMetricReports() (reports []*proto.MetricsReport) { - for _, report := range e.latestMetricReports.Data { - reports = append(reports, report) +func (e *Exporter) SetLatestMetricReports(data []core.Payload) { + for _, report := range data { + e.latestMetricReports.Data = append(e.latestMetricReports.Data, report.(*proto.MetricsReport)) } +} + +func (e *Exporter) GetLatestMetricReports() (reports []*proto.MetricsReport) { + reports = append(reports, e.latestMetricReports.Data...) return } diff --git a/src/plugins/agent_api.go b/src/plugins/agent_api.go index 4e9c311d2e..e8e55899b0 100644 --- a/src/plugins/agent_api.go +++ b/src/plugins/agent_api.go @@ -208,6 +208,8 @@ func (a *AgentAPI) Process(message *core.Message) { switch response := message.Data().(type) { case *metrics.MetricsReportBundle: a.exporter.SetLatestMetricReport(response) + case []core.Payload: + a.exporter.SetLatestMetricReports(response) default: log.Warnf("Unknown MetricReportBundle type: %T(%v)", message.Data(), message.Data()) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go index a7688a48d5..24880e6c93 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go @@ -4,6 +4,7 @@ import ( "strings" "github.com/nginx/agent/sdk/v2/proto" + "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" "github.com/prometheus/client_golang/prometheus" @@ -21,10 +22,14 @@ func (e *Exporter) SetLatestMetricReport(latest *metrics.MetricsReportBundle) { e.latestMetricReports = latest } -func (e *Exporter) GetLatestMetricReports() (reports []*proto.MetricsReport) { - for _, report := range e.latestMetricReports.Data { - reports = append(reports, report) +func (e *Exporter) SetLatestMetricReports(data []core.Payload) { + for _, report := range data { + e.latestMetricReports.Data = append(e.latestMetricReports.Data, report.(*proto.MetricsReport)) } +} + +func (e *Exporter) GetLatestMetricReports() (reports []*proto.MetricsReport) { + reports = append(reports, e.latestMetricReports.Data...) return } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go index 4e9c311d2e..e8e55899b0 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go @@ -208,6 +208,8 @@ func (a *AgentAPI) Process(message *core.Message) { switch response := message.Data().(type) { case *metrics.MetricsReportBundle: a.exporter.SetLatestMetricReport(response) + case []core.Payload: + a.exporter.SetLatestMetricReports(response) default: log.Warnf("Unknown MetricReportBundle type: %T(%v)", message.Data(), message.Data()) } From 2b19468f9535374be626139420ab45dcdd6f6d75 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 16:02:44 +0100 Subject: [PATCH 34/49] extend time of agent api tests --- .../prometheus-metrics/prometheus_exporter.go | 2 ++ test/integration/api/api_test.go | 12 ++++++++++++ test/integration/api/nginx-agent.conf | 2 +- .../prometheus-metrics/prometheus_exporter.go | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/extensions/prometheus-metrics/prometheus_exporter.go b/src/extensions/prometheus-metrics/prometheus_exporter.go index 24880e6c93..31b45ba333 100644 --- a/src/extensions/prometheus-metrics/prometheus_exporter.go +++ b/src/extensions/prometheus-metrics/prometheus_exporter.go @@ -23,6 +23,8 @@ func (e *Exporter) SetLatestMetricReport(latest *metrics.MetricsReportBundle) { } func (e *Exporter) SetLatestMetricReports(data []core.Payload) { + e.latestMetricReports.Data = nil + for _, report := range data { e.latestMetricReports.Data = append(e.latestMetricReports.Data, report.(*proto.MetricsReport)) } diff --git a/test/integration/api/api_test.go b/test/integration/api/api_test.go index 909074da1e..7d1f83df54 100644 --- a/test/integration/api/api_test.go +++ b/test/integration/api/api_test.go @@ -22,6 +22,10 @@ const ( API_HOST = "0.0.0.0" ) +var ( + delay = time.Duration(5 * time.Second) +) + func TestAPI_Nginx(t *testing.T) { testContainer := utils.SetupTestContainerWithAgent( t, @@ -30,6 +34,9 @@ func TestAPI_Nginx(t *testing.T) { "Starting Agent API HTTP server with port from config and TLS disabled", ) + // wait for report interval to send metrics + time.Sleep(delay) + client := resty.New() client.SetRetryCount(3).SetRetryWaitTime(50 * time.Millisecond).SetRetryMaxWaitTime(200 * time.Millisecond) @@ -64,10 +71,15 @@ func TestAPI_Metrics(t *testing.T) { "./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf", "Starting Agent API HTTP server with port from config and TLS disabled", ) + + // wait for report interval to send metrics + time.Sleep(delay) client := resty.New() url := fmt.Sprintf("http://%s:%d/metrics/", API_HOST, API_PORT) + + time.Sleep() client.SetRetryCount(5).SetRetryWaitTime(5 * time.Second).SetRetryMaxWaitTime(5 * time.Second) client.AddRetryCondition( func(r *resty.Response, err error) bool { diff --git a/test/integration/api/nginx-agent.conf b/test/integration/api/nginx-agent.conf index fedca4030b..069dfdc44e 100644 --- a/test/integration/api/nginx-agent.conf +++ b/test/integration/api/nginx-agent.conf @@ -48,7 +48,7 @@ metrics: # specify the size of a buffer to build before sending metrics bulk_size: 20 # specify metrics poll interval - report_interval: 1m + report_interval: 2s collection_interval: 1s mode: aggregated diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go index 24880e6c93..31b45ba333 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go @@ -23,6 +23,8 @@ func (e *Exporter) SetLatestMetricReport(latest *metrics.MetricsReportBundle) { } func (e *Exporter) SetLatestMetricReports(data []core.Payload) { + e.latestMetricReports.Data = nil + for _, report := range data { e.latestMetricReports.Data = append(e.latestMetricReports.Data, report.(*proto.MetricsReport)) } From f576824c1630b1fe05279e0003ba78a2b0178c98 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 16:36:05 +0100 Subject: [PATCH 35/49] typo --- test/integration/api/api_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/api/api_test.go b/test/integration/api/api_test.go index 7d1f83df54..09096ae4f5 100644 --- a/test/integration/api/api_test.go +++ b/test/integration/api/api_test.go @@ -79,7 +79,7 @@ func TestAPI_Metrics(t *testing.T) { url := fmt.Sprintf("http://%s:%d/metrics/", API_HOST, API_PORT) - time.Sleep() + time.Sleep(delay) client.SetRetryCount(5).SetRetryWaitTime(5 * time.Second).SetRetryMaxWaitTime(5 * time.Second) client.AddRetryCondition( func(r *resty.Response, err error) bool { From 4bad7640d318aa914addd9935df300731c26d038 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 15 Aug 2024 16:45:13 +0100 Subject: [PATCH 36/49] typo --- test/integration/api/api_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration/api/api_test.go b/test/integration/api/api_test.go index 09096ae4f5..6997db6bbc 100644 --- a/test/integration/api/api_test.go +++ b/test/integration/api/api_test.go @@ -79,7 +79,6 @@ func TestAPI_Metrics(t *testing.T) { url := fmt.Sprintf("http://%s:%d/metrics/", API_HOST, API_PORT) - time.Sleep(delay) client.SetRetryCount(5).SetRetryWaitTime(5 * time.Second).SetRetryMaxWaitTime(5 * time.Second) client.AddRetryCondition( func(r *resty.Response, err error) bool { From 7d014225668528868848baca2c500be84a66c8ea Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Fri, 16 Aug 2024 15:46:12 +0100 Subject: [PATCH 37/49] revert default config --- nginx-agent.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx-agent.conf b/nginx-agent.conf index d0f651b8c2..16afeb001e 100644 --- a/nginx-agent.conf +++ b/nginx-agent.conf @@ -28,8 +28,8 @@ metrics: # specify the size of a buffer to build before sending metrics bulk_size: 20 # specify metrics poll interval - report_interval: 5s - collection_interval: 2s + report_interval: 1m + collection_interval: 15s mode: aggregated # OSS NGINX default config path From 41e9e8ed2670362fea462071ab892e7d907a4e80 Mon Sep 17 00:00:00 2001 From: dhurley Date: Mon, 19 Aug 2024 15:24:29 +0100 Subject: [PATCH 38/49] Fix metrics --- src/core/metrics/aggregate.go | 25 +++++++++++++------ src/plugins/metrics_throlling.go | 25 +++++++++++++++++-- .../agent/v2/src/core/metrics/aggregate.go | 25 +++++++++++++------ .../agent/v2/src/plugins/metrics_throlling.go | 25 +++++++++++++++++-- 4 files changed, 82 insertions(+), 18 deletions(-) diff --git a/src/core/metrics/aggregate.go b/src/core/metrics/aggregate.go index 663f995737..0a46c2af78 100644 --- a/src/core/metrics/aggregate.go +++ b/src/core/metrics/aggregate.go @@ -10,6 +10,7 @@ package metrics import ( "encoding/json" "fmt" + log "github.com/sirupsen/logrus" "regexp" "github.com/nginx/agent/sdk/v2/checksum" @@ -31,6 +32,7 @@ type MetricsHandler func(float64, int) float64 type Collections struct { Count int // this is the number of collections run. Will use this to calculate the average. + MetricsCount map[string]PerDimension Data map[string]PerDimension } @@ -57,6 +59,10 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe Dimensions: stats.GetDimensions(), RunningSumMap: make(map[string]float64), } + metricsCollections.MetricsCount[dimensionsChecksum] = PerDimension{ + Dimensions: stats.GetDimensions(), + RunningSumMap: make(map[string]float64), + } } simpleMetrics := stats.GetSimplemetrics() @@ -64,8 +70,10 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe if simpleMetrics != nil { for _, simpleMetric := range simpleMetrics { if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name]++ metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() } else { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = 1 metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() } } @@ -79,8 +87,8 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe func GenerateMetrics(metricsCollections Collections) []*proto.StatsEntity { results := make([]*proto.StatsEntity, 0, 200) - for _, metricsPerDimension := range metricsCollections.Data { - simpleMetrics := getAggregatedSimpleMetric(metricsCollections.Count, metricsPerDimension.RunningSumMap) + for name, metricsPerDimension := range metricsCollections.Data { + simpleMetrics := getAggregatedSimpleMetric(metricsCollections.MetricsCount[name], metricsPerDimension.RunningSumMap) results = append(results, NewStatsEntity( metricsPerDimension.Dimensions, simpleMetrics, @@ -90,7 +98,7 @@ func GenerateMetrics(metricsCollections Collections) []*proto.StatsEntity { return results } -func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpleMetrics []*proto.SimpleMetric) { +func getAggregatedSimpleMetric(count PerDimension, internalMap map[string]float64) (simpleMetrics []*proto.SimpleMetric) { variableMetrics := map[*regexp.Regexp]MetricsHandler{ failsRegex: sum, freeRegex: avg, @@ -100,18 +108,21 @@ func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpl calMap := GetCalculationMap() + log.Infof("\n\nCount: %v", count) + for name, value := range internalMap { + log.Infof("%s: %v", name, value) if valueType, ok := calMap[name]; ok { var aggregatedValue float64 switch valueType { case "sum": - aggregatedValue = sum(value, count) + aggregatedValue = sum(value, int(count.RunningSumMap[name])) case "avg": - aggregatedValue = avg(value, count) + aggregatedValue = avg(value, int(count.RunningSumMap[name])) case "boolean": - aggregatedValue = boolean(value, count) + aggregatedValue = boolean(value, int(count.RunningSumMap[name])) } // Only aggregate metrics when the aggregation method is defined @@ -122,7 +133,7 @@ func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpl } else { for reg, calculation := range variableMetrics { if reg.MatchString(name) { - result := calculation(value, count) + result := calculation(value, int(count.RunningSumMap[name])) simpleMetrics = append(simpleMetrics, &proto.SimpleMetric{ Name: name, diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index 5a9bba0bbd..3b43affd74 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -38,6 +38,7 @@ type MetricsThrottle struct { ctx context.Context cancel context.CancelFunc wg sync.WaitGroup + mu sync.Mutex env core.Environment conf *config.Config errors chan error @@ -93,11 +94,13 @@ func (r *MetricsThrottle) Process(msg *core.Message) { switch bundle := msg.Data().(type) { case *metrics.MetricsReportBundle: if len(bundle.Data) > 0 { + r.mu.Lock() for _, report := range bundle.Data { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { r.metricsCollections[report.Type] = &metrics.Collections{ Count: 0, + MetricsCount: map[string]metrics.PerDimension{}, Data: make(map[string]metrics.PerDimension), } } @@ -106,6 +109,7 @@ func (r *MetricsThrottle) Process(msg *core.Message) { log.Debugf("MetricsThrottle: Metrics collection saved [Type: %d]", report.Type) } } + r.mu.Unlock() r.reportsReady.Store(true) } } @@ -198,14 +202,31 @@ func (r *MetricsThrottle) syncAgentConfigChange() { } func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { + r.mu.Lock() + defer r.mu.Unlock() + for reportType, collection := range r.metricsCollections { - reports = append(reports, &proto.MetricsReport{ + report := &proto.MetricsReport{ Meta: &proto.Metadata{ Timestamp: types.TimestampNow(), }, Type: reportType, Data: metrics.GenerateMetrics(*collection), - }) + } + + log.Infof("%v report created with %d stats entities", report.Type, len(report.Data)) + for _, entity := range report.GetData() { + log.Infof("%v", entity) + } + + reports = append(reports, report) + + r.metricsCollections[reportType] = &metrics.Collections{ + Count: 0, + MetricsCount: map[string]metrics.PerDimension{}, + Data: make(map[string]metrics.PerDimension), + } } + return reports } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go index 663f995737..0a46c2af78 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go @@ -10,6 +10,7 @@ package metrics import ( "encoding/json" "fmt" + log "github.com/sirupsen/logrus" "regexp" "github.com/nginx/agent/sdk/v2/checksum" @@ -31,6 +32,7 @@ type MetricsHandler func(float64, int) float64 type Collections struct { Count int // this is the number of collections run. Will use this to calculate the average. + MetricsCount map[string]PerDimension Data map[string]PerDimension } @@ -57,6 +59,10 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe Dimensions: stats.GetDimensions(), RunningSumMap: make(map[string]float64), } + metricsCollections.MetricsCount[dimensionsChecksum] = PerDimension{ + Dimensions: stats.GetDimensions(), + RunningSumMap: make(map[string]float64), + } } simpleMetrics := stats.GetSimplemetrics() @@ -64,8 +70,10 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe if simpleMetrics != nil { for _, simpleMetric := range simpleMetrics { if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name]++ metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() } else { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = 1 metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() } } @@ -79,8 +87,8 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe func GenerateMetrics(metricsCollections Collections) []*proto.StatsEntity { results := make([]*proto.StatsEntity, 0, 200) - for _, metricsPerDimension := range metricsCollections.Data { - simpleMetrics := getAggregatedSimpleMetric(metricsCollections.Count, metricsPerDimension.RunningSumMap) + for name, metricsPerDimension := range metricsCollections.Data { + simpleMetrics := getAggregatedSimpleMetric(metricsCollections.MetricsCount[name], metricsPerDimension.RunningSumMap) results = append(results, NewStatsEntity( metricsPerDimension.Dimensions, simpleMetrics, @@ -90,7 +98,7 @@ func GenerateMetrics(metricsCollections Collections) []*proto.StatsEntity { return results } -func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpleMetrics []*proto.SimpleMetric) { +func getAggregatedSimpleMetric(count PerDimension, internalMap map[string]float64) (simpleMetrics []*proto.SimpleMetric) { variableMetrics := map[*regexp.Regexp]MetricsHandler{ failsRegex: sum, freeRegex: avg, @@ -100,18 +108,21 @@ func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpl calMap := GetCalculationMap() + log.Infof("\n\nCount: %v", count) + for name, value := range internalMap { + log.Infof("%s: %v", name, value) if valueType, ok := calMap[name]; ok { var aggregatedValue float64 switch valueType { case "sum": - aggregatedValue = sum(value, count) + aggregatedValue = sum(value, int(count.RunningSumMap[name])) case "avg": - aggregatedValue = avg(value, count) + aggregatedValue = avg(value, int(count.RunningSumMap[name])) case "boolean": - aggregatedValue = boolean(value, count) + aggregatedValue = boolean(value, int(count.RunningSumMap[name])) } // Only aggregate metrics when the aggregation method is defined @@ -122,7 +133,7 @@ func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpl } else { for reg, calculation := range variableMetrics { if reg.MatchString(name) { - result := calculation(value, count) + result := calculation(value, int(count.RunningSumMap[name])) simpleMetrics = append(simpleMetrics, &proto.SimpleMetric{ Name: name, diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index 5a9bba0bbd..3b43affd74 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -38,6 +38,7 @@ type MetricsThrottle struct { ctx context.Context cancel context.CancelFunc wg sync.WaitGroup + mu sync.Mutex env core.Environment conf *config.Config errors chan error @@ -93,11 +94,13 @@ func (r *MetricsThrottle) Process(msg *core.Message) { switch bundle := msg.Data().(type) { case *metrics.MetricsReportBundle: if len(bundle.Data) > 0 { + r.mu.Lock() for _, report := range bundle.Data { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { r.metricsCollections[report.Type] = &metrics.Collections{ Count: 0, + MetricsCount: map[string]metrics.PerDimension{}, Data: make(map[string]metrics.PerDimension), } } @@ -106,6 +109,7 @@ func (r *MetricsThrottle) Process(msg *core.Message) { log.Debugf("MetricsThrottle: Metrics collection saved [Type: %d]", report.Type) } } + r.mu.Unlock() r.reportsReady.Store(true) } } @@ -198,14 +202,31 @@ func (r *MetricsThrottle) syncAgentConfigChange() { } func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { + r.mu.Lock() + defer r.mu.Unlock() + for reportType, collection := range r.metricsCollections { - reports = append(reports, &proto.MetricsReport{ + report := &proto.MetricsReport{ Meta: &proto.Metadata{ Timestamp: types.TimestampNow(), }, Type: reportType, Data: metrics.GenerateMetrics(*collection), - }) + } + + log.Infof("%v report created with %d stats entities", report.Type, len(report.Data)) + for _, entity := range report.GetData() { + log.Infof("%v", entity) + } + + reports = append(reports, report) + + r.metricsCollections[reportType] = &metrics.Collections{ + Count: 0, + MetricsCount: map[string]metrics.PerDimension{}, + Data: make(map[string]metrics.PerDimension), + } } + return reports } From b4bc2bc6715df8580e6c5c9342def981ddd98395 Mon Sep 17 00:00:00 2001 From: dhurley Date: Mon, 19 Aug 2024 15:21:16 +0100 Subject: [PATCH 39/49] Fix metrics --- src/core/metrics/aggregate.go | 7 ++++--- src/core/tailer/tailer.go | 2 +- src/core/tailer/tailer_test.go | 8 ++++---- src/plugins/metrics_throlling.go | 18 +++++++++--------- test/integration/api/api_test.go | 6 ++---- .../agent/v2/src/core/metrics/aggregate.go | 7 ++++--- .../nginx/agent/v2/src/core/tailer/tailer.go | 2 +- .../agent/v2/src/plugins/metrics_throlling.go | 18 +++++++++--------- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/core/metrics/aggregate.go b/src/core/metrics/aggregate.go index 0a46c2af78..ef74c9c52d 100644 --- a/src/core/metrics/aggregate.go +++ b/src/core/metrics/aggregate.go @@ -10,9 +10,10 @@ package metrics import ( "encoding/json" "fmt" - log "github.com/sirupsen/logrus" "regexp" + log "github.com/sirupsen/logrus" + "github.com/nginx/agent/sdk/v2/checksum" "github.com/nginx/agent/sdk/v2/proto" ) @@ -31,9 +32,9 @@ type PerDimension struct { type MetricsHandler func(float64, int) float64 type Collections struct { - Count int // this is the number of collections run. Will use this to calculate the average. + Count int // this is the number of collections run. Will use this to calculate the average. MetricsCount map[string]PerDimension - Data map[string]PerDimension + Data map[string]PerDimension } func dimChecksum(stats *proto.StatsEntity) string { diff --git a/src/core/tailer/tailer.go b/src/core/tailer/tailer.go index 2980ee6c3f..1c9a2239c7 100644 --- a/src/core/tailer/tailer.go +++ b/src/core/tailer/tailer.go @@ -196,7 +196,7 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } - + stopErr := t.handle.Stop() if stopErr != nil { log.Tracef("Unable to stop tailer, %v", stopErr) diff --git a/src/core/tailer/tailer_test.go b/src/core/tailer/tailer_test.go index a2bf4716bb..b6cd5f5274 100644 --- a/src/core/tailer/tailer_test.go +++ b/src/core/tailer/tailer_test.go @@ -72,9 +72,9 @@ func TestTailer(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration) data := make(chan string, 100) - + go tailer.Tail(ctx, data) - + time.Sleep(time.Millisecond * 100) _, err = errorLogFile.WriteString(logLine) if err != nil { @@ -115,9 +115,9 @@ func TestPatternTailer(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration) data := make(chan map[string]string, 100) - + go tailer.Tail(ctx, data) - + time.Sleep(time.Millisecond * 100) _, err = accessLogFile.WriteString(logLine) if err != nil { diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index 3b43affd74..9ab9735ef6 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -39,9 +39,9 @@ type MetricsThrottle struct { cancel context.CancelFunc wg sync.WaitGroup mu sync.Mutex - env core.Environment - conf *config.Config - errors chan error + env core.Environment + conf *config.Config + errors chan error } func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrottle { @@ -99,9 +99,9 @@ func (r *MetricsThrottle) Process(msg *core.Message) { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { r.metricsCollections[report.Type] = &metrics.Collections{ - Count: 0, + Count: 0, MetricsCount: map[string]metrics.PerDimension{}, - Data: make(map[string]metrics.PerDimension), + Data: make(map[string]metrics.PerDimension), } } collection := metrics.SaveCollections(*r.metricsCollections[report.Type], report) @@ -220,11 +220,11 @@ func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { } reports = append(reports, report) - + r.metricsCollections[reportType] = &metrics.Collections{ - Count: 0, - MetricsCount: map[string]metrics.PerDimension{}, - Data: make(map[string]metrics.PerDimension), + Count: 0, + MetricsCount: map[string]metrics.PerDimension{}, + Data: make(map[string]metrics.PerDimension), } } diff --git a/test/integration/api/api_test.go b/test/integration/api/api_test.go index 6997db6bbc..3062b8f7ef 100644 --- a/test/integration/api/api_test.go +++ b/test/integration/api/api_test.go @@ -22,9 +22,7 @@ const ( API_HOST = "0.0.0.0" ) -var ( - delay = time.Duration(5 * time.Second) -) +var delay = time.Duration(5 * time.Second) func TestAPI_Nginx(t *testing.T) { testContainer := utils.SetupTestContainerWithAgent( @@ -71,7 +69,7 @@ func TestAPI_Metrics(t *testing.T) { "./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf", "Starting Agent API HTTP server with port from config and TLS disabled", ) - + // wait for report interval to send metrics time.Sleep(delay) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go index 0a46c2af78..ef74c9c52d 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go @@ -10,9 +10,10 @@ package metrics import ( "encoding/json" "fmt" - log "github.com/sirupsen/logrus" "regexp" + log "github.com/sirupsen/logrus" + "github.com/nginx/agent/sdk/v2/checksum" "github.com/nginx/agent/sdk/v2/proto" ) @@ -31,9 +32,9 @@ type PerDimension struct { type MetricsHandler func(float64, int) float64 type Collections struct { - Count int // this is the number of collections run. Will use this to calculate the average. + Count int // this is the number of collections run. Will use this to calculate the average. MetricsCount map[string]PerDimension - Data map[string]PerDimension + Data map[string]PerDimension } func dimChecksum(stats *proto.StatsEntity) string { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go index 2980ee6c3f..1c9a2239c7 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go @@ -196,7 +196,7 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } - + stopErr := t.handle.Stop() if stopErr != nil { log.Tracef("Unable to stop tailer, %v", stopErr) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index 3b43affd74..9ab9735ef6 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -39,9 +39,9 @@ type MetricsThrottle struct { cancel context.CancelFunc wg sync.WaitGroup mu sync.Mutex - env core.Environment - conf *config.Config - errors chan error + env core.Environment + conf *config.Config + errors chan error } func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrottle { @@ -99,9 +99,9 @@ func (r *MetricsThrottle) Process(msg *core.Message) { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { r.metricsCollections[report.Type] = &metrics.Collections{ - Count: 0, + Count: 0, MetricsCount: map[string]metrics.PerDimension{}, - Data: make(map[string]metrics.PerDimension), + Data: make(map[string]metrics.PerDimension), } } collection := metrics.SaveCollections(*r.metricsCollections[report.Type], report) @@ -220,11 +220,11 @@ func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { } reports = append(reports, report) - + r.metricsCollections[reportType] = &metrics.Collections{ - Count: 0, - MetricsCount: map[string]metrics.PerDimension{}, - Data: make(map[string]metrics.PerDimension), + Count: 0, + MetricsCount: map[string]metrics.PerDimension{}, + Data: make(map[string]metrics.PerDimension), } } From 3fbcb396f3bd8bf8e04766e4a015b477e10d9a23 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Mon, 19 Aug 2024 16:15:18 +0100 Subject: [PATCH 40/49] merge --- src/core/metrics/aggregate_test.go | 290 ++++++++++++------ src/core/tailer/tailer.go | 3 + .../nginx/agent/v2/src/core/tailer/tailer.go | 3 + 3 files changed, 202 insertions(+), 94 deletions(-) diff --git a/src/core/metrics/aggregate_test.go b/src/core/metrics/aggregate_test.go index 86e4d465cc..4435056ed1 100644 --- a/src/core/metrics/aggregate_test.go +++ b/src/core/metrics/aggregate_test.go @@ -17,111 +17,199 @@ import ( "github.com/nginx/agent/sdk/v2/checksum" "github.com/nginx/agent/sdk/v2/proto" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) -func TestSaveCollections(t *testing.T) { - reports := []*proto.MetricsReport{ - { - Meta: &proto.Metadata{}, - Type: proto.MetricsReport_SYSTEM, - Data: []*proto.StatsEntity{ - { - Simplemetrics: []*proto.SimpleMetric{ - { - Name: "system.mem.used", - Value: 5, - }, - { - Name: "system.io.kbs_w", - Value: 5.3, - }, - { - Name: "system.cpu.system", - Value: 2.4, - }, - { - Name: "system.cpu.user", - Value: 6.8, - }, +var reports = []*proto.MetricsReport{ + { + Meta: &proto.Metadata{}, + Type: proto.MetricsReport_SYSTEM, + Data: []*proto.StatsEntity{ + { + Simplemetrics: []*proto.SimpleMetric{ + { + Name: "system.mem.used", + Value: 5, }, - Dimensions: []*proto.Dimension{ - { - Name: "hostname", - Value: "test-host", - }, + { + Name: "system.io.kbs_w", + Value: 5.3, + }, + { + Name: "system.cpu.system", + Value: 2.4, + }, + { + Name: "system.cpu.user", + Value: 6.8, + }, + }, + Dimensions: []*proto.Dimension{ + { + Name: "hostname", + Value: "test-host", }, }, }, }, + }, + { + Meta: &proto.Metadata{}, + Type: proto.MetricsReport_SYSTEM, + Data: []*proto.StatsEntity{ + { + Simplemetrics: []*proto.SimpleMetric{ + { + Name: "system.mem.used", + Value: 6, + }, + { + Name: "system.io.kbs_w", + Value: 7.3, + }, + { + Name: "system.cpu.system", + Value: 8.3, + }, + { + Name: "system.cpu.user", + Value: 3.8, + }, + }, + Dimensions: []*proto.Dimension{ + { + Name: "hostname", + Value: "test-host2", + }, + }, + }, + }, + }, +} + +func TestSaveCollections(t *testing.T) { + tests := []struct { + name string + reports []*proto.MetricsReport + expected map[string]float64 + }{ { - Meta: &proto.Metadata{}, - Type: proto.MetricsReport_SYSTEM, - Data: []*proto.StatsEntity{ - { - Simplemetrics: []*proto.SimpleMetric{ - { - Name: "system.mem.used", - Value: 6, - }, - { - Name: "system.io.kbs_w", - Value: 7.3, - }, - { - Name: "system.cpu.system", - Value: 8.3, - }, - { - Name: "system.cpu.user", - Value: 3.8, + name: "save collection test", + reports: reports, + expected: map[string]float64{ + "system.mem.used": 5, + "system.io.kbs_w": 5.3, + "system.io.kbs_r": 0, + "system.cpu.system": 2.4, + "system.cpu.user": 6.8, + }, + }, + { + name: "save collection test with duplicates", + reports: append(reports, &proto.MetricsReport{ + Meta: &proto.Metadata{}, + Type: proto.MetricsReport_SYSTEM, + Data: []*proto.StatsEntity{ + { + Simplemetrics: []*proto.SimpleMetric{ + { + Name: "system.mem.used", + Value: 7, + }, + { + Name: "system.io.kbs_w", + Value: 4.3, + }, + { + Name: "system.cpu.system", + Value: 2.3, + }, + { + Name: "system.cpu.user", + Value: 1.8, + }, }, - }, - Dimensions: []*proto.Dimension{ - { - Name: "hostname", - Value: "test-host2", + Dimensions: []*proto.Dimension{ + { + Name: "hostname", + Value: "test-host", + }, }, }, }, + }), + expected: map[string]float64{ + "system.mem.used": 12, + "system.io.kbs_w": 9.6, + "system.io.kbs_r": 0, + "system.cpu.system": 4.699999999999999, + "system.cpu.user": 8.6, }, }, } + for _, test := range tests { + + metricsCollections := Collections{ + Count: len(test.reports), + Data: make(map[string]PerDimension), + } + dimension1 := []*proto.Dimension{ + { + Name: "hostname", + Value: "test-host", + }, + } + var dimensionsChecksum string + data, err := json.Marshal(dimension1) + if err == nil { + dimensionsChecksum = checksum.HexChecksum(data) + } else { + dimensionsChecksum = checksum.HexChecksum([]byte(fmt.Sprintf("%v", dimension1))) + } + metricsCollections.Data[dimensionsChecksum] = PerDimension{ + Dimensions: dimension1, + RunningSumMap: make(map[string]float64), + } + + metricsCollections = SaveCollections(metricsCollections, test.reports...) + log.Info(metricsCollections) + + assert.NotNil(t, metricsCollections) + // assert.Len(t, len(metricsCollections) 3 + + for key, value := range test.expected { + assert.Equal(t, value, metricsCollections.Data[dimensionsChecksum].RunningSumMap[key]) + } + } +} + +func TestGenerateMetrics(t *testing.T) { + // Prepare a collection with some data metricsCollections := Collections{ Count: 2, - Data: make(map[string]PerDimension), - } - dimension1 := []*proto.Dimension{ - { - Name: "hostname", - Value: "test-host", + Data: map[string]PerDimension{ + "checksum1": { + Dimensions: []*proto.Dimension{ + {Name: "name1", Value: "value1"}, + }, + RunningSumMap: map[string]float64{ + "system.mem.used": 20.0, + }, + }, }, } - var dimensionsChecksum string - data, err := json.Marshal(dimension1) - if err == nil { - dimensionsChecksum = checksum.HexChecksum(data) - } else { - dimensionsChecksum = checksum.HexChecksum([]byte(fmt.Sprintf("%v", dimension1))) - } - metricsCollections.Data[dimensionsChecksum] = PerDimension{ - Dimensions: dimension1, - RunningSumMap: make(map[string]float64), - } - metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.mem.used"] = 6.2 - metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.io.kbs_w"] = 3.4 - metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.io.kbs_r"] = 2.3 - metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.cpu.system"] = 6.2 - - metricsCollections = SaveCollections(metricsCollections, reports...) - log.Info(metricsCollections) - - assert.NotNil(t, metricsCollections) - assert.Equal(t, 11.2, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.mem.used"]) - assert.Equal(t, 8.7, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.io.kbs_w"]) - assert.Equal(t, 2.3, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.io.kbs_r"]) - assert.Equal(t, 8.6, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.cpu.system"]) - assert.Equal(t, 6.8, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.cpu.user"]) + + // Generate the metrics + metrics := GenerateMetrics(metricsCollections) + + // Check the generated metrics + require.Len(t, metrics, 1) + + // Check the simple metrics + simpleMetrics := metrics[0].GetSimplemetrics() + require.Len(t, simpleMetrics, 1) + assert.Equal(t, "system.mem.used", simpleMetrics[0].Name) } func TestGenerateAggregationReport(t *testing.T) { @@ -166,30 +254,44 @@ func TestGenerateAggregationReport(t *testing.T) { assert.Equal(t, float64(1000), v.Value) } } + } +} +func TestGetAggregatedSimpleMetric(t *testing.T) { + internalMap := map[string]float64{ + "system.mem.used": 10.0, + "system.cpu.system": 20.0, } + + simpleMetrics := getAggregatedSimpleMetric(1, internalMap) + + require.Len(t, simpleMetrics, 2) + assert.Equal(t, "system.mem.used", simpleMetrics[0].Name) + assert.Equal(t, 10.0, simpleMetrics[0].GetValue()) + assert.Equal(t, "system.cpu.system", simpleMetrics[1].Name) + assert.Equal(t, 20.0, simpleMetrics[1].GetValue()) } func TestAvg(t *testing.T) { - result := avg(float64(2.12), 2) - assert.Equal(t, float64(1.06), result) + result := avg(2.12, 2) + assert.Equal(t, 1.06, result) - result = avg(float64(2.12), 0) - assert.Equal(t, float64(2.12), result) + result = avg(2.12, 0) + assert.Equal(t, 2.12, result) } func TestSum(t *testing.T) { - result := sum(float64(2.12), 2) - assert.Equal(t, float64(2.12), result) + result := sum(2.12, 2) + assert.Equal(t, 2.12, result) } func TestBoolean(t *testing.T) { - result := boolean(float64(2.12), 2) + result := boolean(2.12, 2) assert.Equal(t, 1.0, result) - result = boolean(float64(0.2), 2) + result = boolean(0.2, 2) assert.Equal(t, 0.0, result) - result = boolean(float64(2.12), 0) + result = boolean(2.12, 0) assert.Equal(t, 2.12, result) } diff --git a/src/core/tailer/tailer.go b/src/core/tailer/tailer.go index 1c9a2239c7..26c31e235f 100644 --- a/src/core/tailer/tailer.go +++ b/src/core/tailer/tailer.go @@ -196,7 +196,10 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } +<<<<<<< Updated upstream +======= +>>>>>>> Stashed changes stopErr := t.handle.Stop() if stopErr != nil { log.Tracef("Unable to stop tailer, %v", stopErr) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go index 1c9a2239c7..26c31e235f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go @@ -196,7 +196,10 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } +<<<<<<< Updated upstream +======= +>>>>>>> Stashed changes stopErr := t.handle.Stop() if stopErr != nil { log.Tracef("Unable to stop tailer, %v", stopErr) From acb9d303421f88e110e9ae54e75739db0f9d4e36 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Mon, 19 Aug 2024 16:45:40 +0100 Subject: [PATCH 41/49] added tests --- src/core/metrics/aggregate.go | 19 ++--- src/core/metrics/aggregate_test.go | 74 +++++++++++-------- src/core/tailer/tailer.go | 4 - src/plugins/metrics_throlling.go | 2 +- .../agent/v2/src/core/metrics/aggregate.go | 19 ++--- .../nginx/agent/v2/src/core/tailer/tailer.go | 4 - .../agent/v2/src/plugins/metrics_throlling.go | 2 +- 7 files changed, 66 insertions(+), 58 deletions(-) diff --git a/src/core/metrics/aggregate.go b/src/core/metrics/aggregate.go index ef74c9c52d..d4107727b0 100644 --- a/src/core/metrics/aggregate.go +++ b/src/core/metrics/aggregate.go @@ -60,6 +60,9 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe Dimensions: stats.GetDimensions(), RunningSumMap: make(map[string]float64), } + } + + if _, ok := metricsCollections.MetricsCount[dimensionsChecksum]; !ok { metricsCollections.MetricsCount[dimensionsChecksum] = PerDimension{ Dimensions: stats.GetDimensions(), RunningSumMap: make(map[string]float64), @@ -68,15 +71,13 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe simpleMetrics := stats.GetSimplemetrics() - if simpleMetrics != nil { - for _, simpleMetric := range simpleMetrics { - if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { - metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name]++ - metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() - } else { - metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = 1 - metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() - } + for _, simpleMetric := range simpleMetrics { + if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name]++ + metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() + } else { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = 1 + metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() } } } diff --git a/src/core/metrics/aggregate_test.go b/src/core/metrics/aggregate_test.go index 4435056ed1..4bc1e16b19 100644 --- a/src/core/metrics/aggregate_test.go +++ b/src/core/metrics/aggregate_test.go @@ -17,7 +17,7 @@ import ( "github.com/nginx/agent/sdk/v2/checksum" "github.com/nginx/agent/sdk/v2/proto" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + // "github.com/stretchr/testify/require" ) var reports = []*proto.MetricsReport{ @@ -153,6 +153,7 @@ func TestSaveCollections(t *testing.T) { metricsCollections := Collections{ Count: len(test.reports), Data: make(map[string]PerDimension), + MetricsCount: make(map[string]PerDimension), } dimension1 := []*proto.Dimension{ { @@ -172,11 +173,15 @@ func TestSaveCollections(t *testing.T) { RunningSumMap: make(map[string]float64), } + metricsCollections.MetricsCount[dimensionsChecksum] = PerDimension{ + Dimensions: dimension1, + RunningSumMap: make(map[string]float64), + } + metricsCollections = SaveCollections(metricsCollections, test.reports...) log.Info(metricsCollections) assert.NotNil(t, metricsCollections) - // assert.Len(t, len(metricsCollections) 3 for key, value := range test.expected { assert.Equal(t, value, metricsCollections.Data[dimensionsChecksum].RunningSumMap[key]) @@ -185,31 +190,55 @@ func TestSaveCollections(t *testing.T) { } func TestGenerateMetrics(t *testing.T) { - // Prepare a collection with some data metricsCollections := Collections{ Count: 2, Data: map[string]PerDimension{ "checksum1": { Dimensions: []*proto.Dimension{ - {Name: "name1", Value: "value1"}, + {Name: "hostname", Value: "test-host"}, + }, + RunningSumMap: map[string]float64{ + "system.mem.used": 20.0, + "system.cpu.system": 10.0, + }, + }, + }, + MetricsCount: map[string]PerDimension{ + "checksum1": { + Dimensions: []*proto.Dimension{ + {Name: "hostname", Value: "test-host"}, }, RunningSumMap: map[string]float64{ - "system.mem.used": 20.0, + "system.mem.used": 2, + "system.cpu.system": 2, }, }, }, } - // Generate the metrics - metrics := GenerateMetrics(metricsCollections) + results := GenerateMetrics(metricsCollections) - // Check the generated metrics - require.Len(t, metrics, 1) + expectedResults := []*proto.StatsEntity{ + { + Dimensions: []*proto.Dimension{ + {Name: "hostname", Value: "test-host"}, + }, + Simplemetrics: []*proto.SimpleMetric{ + {Name: "system.mem.used", Value: 10.0}, + {Name: "system.cpu.system", Value: 5.0}, + }, + }, + } - // Check the simple metrics - simpleMetrics := metrics[0].GetSimplemetrics() - require.Len(t, simpleMetrics, 1) - assert.Equal(t, "system.mem.used", simpleMetrics[0].Name) + assert.Equal(t, len(expectedResults), len(results)) + for i, expected := range expectedResults { + assert.Equal(t, expected.GetDimensions(), results[i].GetDimensions()) + assert.Equal(t, len(expected.GetSimplemetrics()), len(results[i].GetSimplemetrics())) + for j, expectedMetric := range expected.GetSimplemetrics() { + assert.Equal(t, expectedMetric.GetName(), results[i].GetSimplemetrics()[j].GetName()) + assert.Equal(t, expectedMetric.GetValue(), results[i].GetSimplemetrics()[j].GetValue()) + } + } } func TestGenerateAggregationReport(t *testing.T) { @@ -243,13 +272,13 @@ func TestGenerateAggregationReport(t *testing.T) { for _, v := range simplemetrics { switch { case v.Name == "system.mem.used": - assert.Equal(t, float64(50.1), v.Value) + assert.Equal(t, float64(100.2), v.Value) case v.Name == "system.io.kbs_w": assert.Equal(t, float64(600), v.Value) case v.Name == "system.io.kbs_r": assert.Equal(t, float64(6000), v.Value) case v.Name == "system.cpu.system": - assert.Equal(t, float64(100.1), v.Value) + assert.Equal(t, float64(200.2), v.Value) case v.Name == "system.undefined_method": assert.Equal(t, float64(1000), v.Value) } @@ -257,21 +286,6 @@ func TestGenerateAggregationReport(t *testing.T) { } } -func TestGetAggregatedSimpleMetric(t *testing.T) { - internalMap := map[string]float64{ - "system.mem.used": 10.0, - "system.cpu.system": 20.0, - } - - simpleMetrics := getAggregatedSimpleMetric(1, internalMap) - - require.Len(t, simpleMetrics, 2) - assert.Equal(t, "system.mem.used", simpleMetrics[0].Name) - assert.Equal(t, 10.0, simpleMetrics[0].GetValue()) - assert.Equal(t, "system.cpu.system", simpleMetrics[1].Name) - assert.Equal(t, 20.0, simpleMetrics[1].GetValue()) -} - func TestAvg(t *testing.T) { result := avg(2.12, 2) assert.Equal(t, 1.06, result) diff --git a/src/core/tailer/tailer.go b/src/core/tailer/tailer.go index 26c31e235f..0609ee37ec 100644 --- a/src/core/tailer/tailer.go +++ b/src/core/tailer/tailer.go @@ -196,10 +196,6 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } -<<<<<<< Updated upstream - -======= ->>>>>>> Stashed changes stopErr := t.handle.Stop() if stopErr != nil { log.Tracef("Unable to stop tailer, %v", stopErr) diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index 9ab9735ef6..c052539277 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -100,7 +100,7 @@ func (r *MetricsThrottle) Process(msg *core.Message) { if _, ok := r.metricsCollections[report.Type]; !ok { r.metricsCollections[report.Type] = &metrics.Collections{ Count: 0, - MetricsCount: map[string]metrics.PerDimension{}, + MetricsCount: make(map[string]metrics.PerDimension), Data: make(map[string]metrics.PerDimension), } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go index ef74c9c52d..d4107727b0 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go @@ -60,6 +60,9 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe Dimensions: stats.GetDimensions(), RunningSumMap: make(map[string]float64), } + } + + if _, ok := metricsCollections.MetricsCount[dimensionsChecksum]; !ok { metricsCollections.MetricsCount[dimensionsChecksum] = PerDimension{ Dimensions: stats.GetDimensions(), RunningSumMap: make(map[string]float64), @@ -68,15 +71,13 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe simpleMetrics := stats.GetSimplemetrics() - if simpleMetrics != nil { - for _, simpleMetric := range simpleMetrics { - if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { - metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name]++ - metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() - } else { - metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = 1 - metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() - } + for _, simpleMetric := range simpleMetrics { + if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name]++ + metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() + } else { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = 1 + metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() } } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go index 26c31e235f..0609ee37ec 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go @@ -196,10 +196,6 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } -<<<<<<< Updated upstream - -======= ->>>>>>> Stashed changes stopErr := t.handle.Stop() if stopErr != nil { log.Tracef("Unable to stop tailer, %v", stopErr) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index 9ab9735ef6..c052539277 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -100,7 +100,7 @@ func (r *MetricsThrottle) Process(msg *core.Message) { if _, ok := r.metricsCollections[report.Type]; !ok { r.metricsCollections[report.Type] = &metrics.Collections{ Count: 0, - MetricsCount: map[string]metrics.PerDimension{}, + MetricsCount: make(map[string]metrics.PerDimension), Data: make(map[string]metrics.PerDimension), } } From 8c54e4a5bc260de3f0d76a8f687be222602c3c84 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Mon, 19 Aug 2024 16:49:48 +0100 Subject: [PATCH 42/49] remove debug statements --- src/core/metrics/aggregate.go | 3 --- src/core/metrics/aggregate_test.go | 1 - .../github.com/nginx/agent/v2/src/core/metrics/aggregate.go | 3 --- 3 files changed, 7 deletions(-) diff --git a/src/core/metrics/aggregate.go b/src/core/metrics/aggregate.go index d4107727b0..646de7e0ef 100644 --- a/src/core/metrics/aggregate.go +++ b/src/core/metrics/aggregate.go @@ -110,10 +110,7 @@ func getAggregatedSimpleMetric(count PerDimension, internalMap map[string]float6 calMap := GetCalculationMap() - log.Infof("\n\nCount: %v", count) - for name, value := range internalMap { - log.Infof("%s: %v", name, value) if valueType, ok := calMap[name]; ok { var aggregatedValue float64 switch valueType { diff --git a/src/core/metrics/aggregate_test.go b/src/core/metrics/aggregate_test.go index 4bc1e16b19..1f46fccbf8 100644 --- a/src/core/metrics/aggregate_test.go +++ b/src/core/metrics/aggregate_test.go @@ -17,7 +17,6 @@ import ( "github.com/nginx/agent/sdk/v2/checksum" "github.com/nginx/agent/sdk/v2/proto" "github.com/stretchr/testify/assert" - // "github.com/stretchr/testify/require" ) var reports = []*proto.MetricsReport{ diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go index d4107727b0..646de7e0ef 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go @@ -110,10 +110,7 @@ func getAggregatedSimpleMetric(count PerDimension, internalMap map[string]float6 calMap := GetCalculationMap() - log.Infof("\n\nCount: %v", count) - for name, value := range internalMap { - log.Infof("%s: %v", name, value) if valueType, ok := calMap[name]; ok { var aggregatedValue float64 switch valueType { From 1c7ac984d9cdee65d6a65eb45010867a8799bb9b Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Mon, 19 Aug 2024 16:51:28 +0100 Subject: [PATCH 43/49] remove unused import --- src/core/metrics/aggregate.go | 2 -- .../github.com/nginx/agent/v2/src/core/metrics/aggregate.go | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/core/metrics/aggregate.go b/src/core/metrics/aggregate.go index 646de7e0ef..77d3f1e60e 100644 --- a/src/core/metrics/aggregate.go +++ b/src/core/metrics/aggregate.go @@ -12,8 +12,6 @@ import ( "fmt" "regexp" - log "github.com/sirupsen/logrus" - "github.com/nginx/agent/sdk/v2/checksum" "github.com/nginx/agent/sdk/v2/proto" ) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go index 646de7e0ef..77d3f1e60e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go @@ -12,8 +12,6 @@ import ( "fmt" "regexp" - log "github.com/sirupsen/logrus" - "github.com/nginx/agent/sdk/v2/checksum" "github.com/nginx/agent/sdk/v2/proto" ) From 97281450fba5a986dd17eae3d1af0e0971cd8a2d Mon Sep 17 00:00:00 2001 From: oliveromahony Date: Thu, 22 Aug 2024 14:54:40 +0100 Subject: [PATCH 44/49] updating performance test to 1s (#767) --------- Co-authored-by: Aphral Griffin --- sdk/backoff/backoff.go | 2 +- src/core/config/config.go | 3 +- src/core/environment.go | 3 +- src/core/metrics/aggregate_test.go | 15 ++- src/core/os.go | 35 +++--- src/extensions/advanced_metrics.go | 4 +- src/extensions/advanced_metrics_test.go | 5 +- src/extensions/nap_monitoring.go | 41 ++++--- src/extensions/nap_monitoring_test.go | 23 ---- src/extensions/nginx-app-protect/nap/nap.go | 11 +- src/extensions/nginx_app_protect.go | 2 +- src/plugins/features_test.go | 6 +- src/plugins/file_watcher.go | 14 ++- src/plugins/leak_test.go | 18 +++ src/plugins/nginx_counter.go | 2 +- src/plugins/process_watcher_test.go | 103 +++++++++++++++++- .../nginx/agent/sdk/v2/backoff/backoff.go | 2 +- .../nginx/agent/v2/src/core/config/config.go | 3 +- .../nginx/agent/v2/src/core/environment.go | 3 +- .../github.com/nginx/agent/v2/src/core/os.go | 35 +++--- .../nginx/agent/sdk/v2/backoff/backoff.go | 2 +- .../nginx/agent/v2/src/core/config/config.go | 3 +- .../nginx/agent/v2/src/core/environment.go | 3 +- .../github.com/nginx/agent/v2/src/core/os.go | 35 +++--- .../v2/src/extensions/advanced_metrics.go | 4 +- .../agent/v2/src/extensions/nap_monitoring.go | 41 ++++--- .../extensions/nginx-app-protect/nap/nap.go | 11 +- .../v2/src/extensions/nginx_app_protect.go | 2 +- .../agent/v2/src/plugins/file_watcher.go | 14 ++- .../agent/v2/src/plugins/nginx_counter.go | 2 +- .../nginx/agent/sdk/v2/backoff/backoff.go | 2 +- 31 files changed, 289 insertions(+), 160 deletions(-) create mode 100644 src/plugins/leak_test.go diff --git a/sdk/backoff/backoff.go b/sdk/backoff/backoff.go index f5fa9e3b0a..6c26373b02 100644 --- a/sdk/backoff/backoff.go +++ b/sdk/backoff/backoff.go @@ -41,7 +41,7 @@ func WaitUntil( expoBackoffWithContext := backoff.WithContext(exponentialBackoff, ctx) - err := backoff.Retry(backoff.Operation(operation), expoBackoffWithContext) + err := backoff.Retry(operation, expoBackoffWithContext) if err != nil { return err } diff --git a/src/core/config/config.go b/src/core/config/config.go index addc4604b4..dfee04b1bc 100644 --- a/src/core/config/config.go +++ b/src/core/config/config.go @@ -429,12 +429,11 @@ func LoadPropertiesFromFile(cfg string) error { if err != nil { return fmt.Errorf("error attempting to open dynamic config (%s): %v", dynamicCfgPath, err) } - + defer dynCfg.Close() featuresAreSet, cleanDynCfgContent, err := removeFeatures(dynCfg) if err != nil { return fmt.Errorf("error updating dynamic config with features removed (%s): %v", dynamicCfgPath, err) } - dynCfg.Close() if featuresAreSet { err = os.WriteFile(dynamicCfgPath, cleanDynCfgContent, 0o640) diff --git a/src/core/environment.go b/src/core/environment.go index 7ddfb52690..6dc2f802e0 100644 --- a/src/core/environment.go +++ b/src/core/environment.go @@ -408,7 +408,7 @@ func getContainerID(mountInfo string) (string, error) { if err != nil { return "", fmt.Errorf("could not read %s: %v", mountInfo, err) } - + defer mInfoFile.Close() fileScanner := bufio.NewScanner(mInfoFile) fileScanner.Split(bufio.ScanLines) @@ -416,7 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - err = mInfoFile.Close() if err != nil { return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) } diff --git a/src/core/metrics/aggregate_test.go b/src/core/metrics/aggregate_test.go index 1f46fccbf8..a3a98fae03 100644 --- a/src/core/metrics/aggregate_test.go +++ b/src/core/metrics/aggregate_test.go @@ -10,6 +10,7 @@ package metrics import ( "encoding/json" "fmt" + "sort" "testing" log "github.com/sirupsen/logrus" @@ -104,7 +105,7 @@ func TestSaveCollections(t *testing.T) { }, }, { - name: "save collection test with duplicates", + name: "save collection test with duplicates", reports: append(reports, &proto.MetricsReport{ Meta: &proto.Metadata{}, Type: proto.MetricsReport_SYSTEM, @@ -136,7 +137,7 @@ func TestSaveCollections(t *testing.T) { }, }, }, - }), + }), expected: map[string]float64{ "system.mem.used": 12, "system.io.kbs_w": 9.6, @@ -150,8 +151,8 @@ func TestSaveCollections(t *testing.T) { for _, test := range tests { metricsCollections := Collections{ - Count: len(test.reports), - Data: make(map[string]PerDimension), + Count: len(test.reports), + Data: make(map[string]PerDimension), MetricsCount: make(map[string]PerDimension), } dimension1 := []*proto.Dimension{ @@ -233,6 +234,12 @@ func TestGenerateMetrics(t *testing.T) { for i, expected := range expectedResults { assert.Equal(t, expected.GetDimensions(), results[i].GetDimensions()) assert.Equal(t, len(expected.GetSimplemetrics()), len(results[i].GetSimplemetrics())) + + metrics := results[i].GetSimplemetrics() + sort.Slice(metrics, func(k, l int) bool { + return metrics[k].GetName() > metrics[l].GetName() + }) + for j, expectedMetric := range expected.GetSimplemetrics() { assert.Equal(t, expectedMetric.GetName(), results[i].GetSimplemetrics()[j].GetName()) assert.Equal(t, expectedMetric.GetValue(), results[i].GetSimplemetrics()[j].GetValue()) diff --git a/src/core/os.go b/src/core/os.go index fcc9901d7f..885b91ba3c 100644 --- a/src/core/os.go +++ b/src/core/os.go @@ -8,9 +8,12 @@ package core import ( + "context" "os" "sync" "time" + + "github.com/nginx/agent/sdk/v2/backoff" ) var chmodMutex sync.Mutex @@ -47,21 +50,19 @@ func FilesExists(filePaths []string) (bool, error) { // EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. // The function continuously attempts the operation until either it succeeds or the timeout period elapses. -func EnableWritePermissionForSocket(path string) error { - timeout := time.After(time.Second * 1) - var lastError error - for { - select { - case <-timeout: - return lastError - default: - chmodMutex.Lock() - lastError = os.Chmod(path, 0o660) - chmodMutex.Unlock() - if lastError == nil { - return nil - } - } - time.Sleep(time.Microsecond * 100) - } +func EnableWritePermissionForSocket(ctx context.Context, path string) error { + err := backoff.WaitUntil(ctx, backoff.BackoffSettings{ + InitialInterval: time.Microsecond * 100, + MaxInterval: time.Microsecond * 100, + MaxElapsedTime: time.Second * 1, + Jitter: backoff.BACKOFF_JITTER, + Multiplier: backoff.BACKOFF_MULTIPLIER, + }, func() error { + chmodMutex.Lock() + lastError := os.Chmod(path, 0o660) + chmodMutex.Unlock() + return lastError + }) + + return err } diff --git a/src/extensions/advanced_metrics.go b/src/extensions/advanced_metrics.go index 33ad249be3..32b61fef2d 100644 --- a/src/extensions/advanced_metrics.go +++ b/src/extensions/advanced_metrics.go @@ -259,9 +259,9 @@ func (m *AdvancedMetrics) run() { } }() defer m.ctxCancel() - err := core.EnableWritePermissionForSocket(m.cfg.Address) + err := core.EnableWritePermissionForSocket(m.ctx, m.cfg.Address) if err != nil { - log.Error("App centric metric plugin failed to change socket permissions") + log.Errorf("App centric metric plugin failed to change socket permissions: %v", err) } commonDimensions := append(m.commonDims.ToDimensions(), &proto.Dimension{ Name: aggregationDurationDimension, diff --git a/src/extensions/advanced_metrics_test.go b/src/extensions/advanced_metrics_test.go index e44ebc027d..0a1720a05d 100644 --- a/src/extensions/advanced_metrics_test.go +++ b/src/extensions/advanced_metrics_test.go @@ -11,13 +11,12 @@ import ( "context" "testing" + "github.com/gogo/protobuf/types" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" "github.com/nginx/agent/v2/src/extensions/advanced-metrics/pkg/publisher" tutils "github.com/nginx/agent/v2/test/utils" - - "github.com/gogo/protobuf/types" "github.com/stretchr/testify/assert" ) @@ -202,10 +201,8 @@ func TestAppCentricMetricClose(t *testing.T) { defer cancelCTX() messagePipe := core.SetupMockMessagePipe(t, ctx, []core.Plugin{}, []core.ExtensionPlugin{pluginUnderTest}) - pluginUnderTest.Init(messagePipe) pluginUnderTest.Close() - env.AssertExpectations(t) } diff --git a/src/extensions/nap_monitoring.go b/src/extensions/nap_monitoring.go index a59d3bfdfa..061a31d5cd 100644 --- a/src/extensions/nap_monitoring.go +++ b/src/extensions/nap_monitoring.go @@ -11,12 +11,13 @@ import ( "context" "time" + "github.com/nginx/agent/v2/src/core/metrics" + agent_config "github.com/nginx/agent/sdk/v2/agent/config" "github.com/nginx/agent/sdk/v2/proto" models "github.com/nginx/agent/sdk/v2/proto/events" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" - "github.com/nginx/agent/v2/src/core/metrics" "github.com/nginx/agent/v2/src/core/payloads" "github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager" @@ -41,16 +42,18 @@ var nginxAppProtectMonitoringDefault = &manager.NginxAppProtectMonitoringConfig{ } type NAPMonitoring struct { - monitorMgr *manager.Manager - messagePipeline core.MessagePipeInterface - reportInterval time.Duration - reportCount int - ctx context.Context - ctxCancel context.CancelFunc + monitorMgr *manager.Manager + messagePipeline core.MessagePipeInterface + reportInterval time.Duration + reportCount int + ctx context.Context + ctxCancel context.CancelFunc + nginxAppProtectMonitoringConfig *manager.NginxAppProtectMonitoringConfig + env core.Environment + cfg *config.Config } func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectMonitoringConf interface{}) (*NAPMonitoring, error) { - commonDims := metrics.NewCommonDim(env.NewHostInfo("agentVersion", &cfg.Tags, cfg.ConfigDirs, false), cfg, "") nginxAppProtectMonitoringConfig := nginxAppProtectMonitoringDefault if nginxAppProtectMonitoringConf != nil { @@ -62,11 +65,6 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectM } } - m, err := manager.NewManager(nginxAppProtectMonitoringConfig, commonDims) - if err != nil { - return nil, err - } - if !(nginxAppProtectMonitoringConfig.ReportInterval > minReportIntervalDelimiter) { log.Warnf("NAP Monitoring report interval must be higher than %v. Defaulting to %v", minReportIntervalDelimiter, @@ -83,9 +81,11 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectM } return &NAPMonitoring{ - monitorMgr: m, - reportInterval: nginxAppProtectMonitoringConfig.ReportInterval, - reportCount: nginxAppProtectMonitoringConfig.ReportCount, + cfg: cfg, + nginxAppProtectMonitoringConfig: nginxAppProtectMonitoringConfig, + env: env, + reportInterval: nginxAppProtectMonitoringConfig.ReportInterval, + reportCount: nginxAppProtectMonitoringConfig.ReportCount, }, nil } @@ -94,6 +94,15 @@ func (n *NAPMonitoring) Info() *core.Info { } func (n *NAPMonitoring) Init(pipeline core.MessagePipeInterface) { + commonDims := metrics.NewCommonDim(n.env.NewHostInfo("agentVersion", &n.cfg.Tags, n.cfg.ConfigDirs, false), n.cfg, "") + + m, err := manager.NewManager(n.nginxAppProtectMonitoringConfig, commonDims) + if err != nil { + log.Errorf("Could not initialize nginx-app-protect-monitoring: %v", err) + return + } + + n.monitorMgr = m log.Infof("%s initializing", napMonitoringPluginName) n.messagePipeline = pipeline ctx, cancel := context.WithCancel(n.messagePipeline.Context()) diff --git a/src/extensions/nap_monitoring_test.go b/src/extensions/nap_monitoring_test.go index 363c83ecff..4f35f6fd70 100644 --- a/src/extensions/nap_monitoring_test.go +++ b/src/extensions/nap_monitoring_test.go @@ -35,17 +35,6 @@ func TestNAPMonitoring(t *testing.T) { }, error: false, }, - { - name: "invalid Syslog IP address", - conf: manager.NginxAppProtectMonitoringConfig{ - CollectorBufferSize: 1, - ProcessorBufferSize: 1, - SyslogIP: "no_such_host", - SyslogPort: 1236, - }, - error: true, - errorContains: "lookup", - }, { // Current behaviour is logging a warning and then // defaulting to the default buffer size = 50000 if the passed parameter is invalid @@ -58,17 +47,6 @@ func TestNAPMonitoring(t *testing.T) { }, error: false, }, - { - name: "invalid Syslog port", - conf: manager.NginxAppProtectMonitoringConfig{ - CollectorBufferSize: 1, - ProcessorBufferSize: 1, - SyslogIP: "127.0.0.1", - SyslogPort: -4321, - }, - error: true, - errorContains: "invalid port", - }, } env := tutils.GetMockEnv() @@ -76,7 +54,6 @@ func TestNAPMonitoring(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { _, err := NewNAPMonitoring(env, &config.Config{}, test.conf) - if test.error { assert.Contains(t, err.Error(), test.errorContains) } else { diff --git a/src/extensions/nginx-app-protect/nap/nap.go b/src/extensions/nginx-app-protect/nap/nap.go index d1d37f80e1..49a486d10a 100644 --- a/src/extensions/nginx-app-protect/nap/nap.go +++ b/src/extensions/nginx-app-protect/nap/nap.go @@ -8,6 +8,7 @@ package nap import ( + "context" "fmt" "io/fs" "os" @@ -98,15 +99,15 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) // - NAP version changed // - Attack signature installed/version changed // - Threat campaign installed/version changed -func (nap *NginxAppProtect) Monitor(pollInterval time.Duration) chan NAPReportBundle { +func (nap *NginxAppProtect) Monitor(ctx context.Context, pollInterval time.Duration) chan NAPReportBundle { msgChannel := make(chan NAPReportBundle) - go nap.monitor(msgChannel, pollInterval) + go nap.monitor(ctx, msgChannel, pollInterval) return msgChannel } // monitor checks the system for any NAP related changes and communicates those changes with // a report message sent via the channel provided to it. -func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterval time.Duration) { +func (nap *NginxAppProtect) monitor(ctx context.Context, msgChannel chan NAPReportBundle, pollInterval time.Duration) { // Initial symlink sync mu.Lock() if nap.Release.VersioningDetails.NAPRelease != "" { @@ -118,7 +119,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva mu.Unlock() ticker := time.NewTicker(pollInterval) - + defer ticker.Stop() for { select { case <-ticker.C: @@ -162,6 +163,8 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva PreviousReport: previousReport, UpdatedReport: newNAPReport, } + case <-ctx.Done(): + return } } } diff --git a/src/extensions/nginx_app_protect.go b/src/extensions/nginx_app_protect.go index ee7f9e95d3..fccffa6a7b 100644 --- a/src/extensions/nginx_app_protect.go +++ b/src/extensions/nginx_app_protect.go @@ -130,7 +130,7 @@ func (n *NginxAppProtect) monitor() { ), ) - napUpdateChannel := n.nap.Monitor(n.reportInterval) + napUpdateChannel := n.nap.Monitor(n.ctx, n.reportInterval) defer close(napUpdateChannel) for { select { diff --git a/src/plugins/features_test.go b/src/plugins/features_test.go index 0bd19918eb..bc70addf1e 100644 --- a/src/plugins/features_test.go +++ b/src/plugins/features_test.go @@ -18,7 +18,6 @@ import ( "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" tutils "github.com/nginx/agent/v2/test/utils" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -86,6 +85,7 @@ func TestFeatures_Process(t *testing.T) { env := tutils.NewMockEnvironment() env.Mock.On("IsContainer").Return(true) + env.Mock.On("FileStat", "/usr/local/etc/nginx").Return(env.FileStat) env.On("NewHostInfo", "agentVersion", &[]string{"locally-tagged", "tagged-locally"}).Return(&proto.HostInfo{}) binary.On("GetNginxDetailsFromProcess", &core.Process{Name: "12345", IsMaster: true}).Return(detailsMap[processID]) @@ -121,6 +121,10 @@ func TestFeatures_Process(t *testing.T) { assert.GreaterOrEqual(t, len(processedMessages), 1) assert.Equal(t, core.EnableFeature, processedMessages[0].Topic()) assert.Equal(t, tc.pluginName, messagePipe.GetPlugins()[1].Info().Name()) + + for _, plugin := range messagePipe.GetPlugins() { + plugin.Close() + } } cancelCTX() diff --git a/src/plugins/file_watcher.go b/src/plugins/file_watcher.go index 74b3cfd2e6..9d3568c031 100644 --- a/src/plugins/file_watcher.go +++ b/src/plugins/file_watcher.go @@ -51,15 +51,9 @@ const ( ) func NewFileWatcher(config *config.Config, env core.Environment) *FileWatcher { - watcher, err := fsnotify.NewWatcher() - if err != nil { - log.Errorf("Error creating file watcher: %v", err) - } - fw := &FileWatcher{ config: config, watching: &sync.Map{}, - watcher: watcher, wg: sync.WaitGroup{}, env: env, enabled: true, @@ -71,6 +65,14 @@ func NewFileWatcher(config *config.Config, env core.Environment) *FileWatcher { func (fw *FileWatcher) Init(pipeline core.MessagePipeInterface) { log.Info("FileWatcher initializing") + watcher, err := fsnotify.NewWatcher() + if err != nil { + log.Errorf("Error creating file watcher: %v", err) + return + } + + fw.watcher = watcher + fw.messagePipeline = pipeline fw.ctx, fw.cancelFunction = context.WithCancel(fw.messagePipeline.Context()) for dir := range fw.config.AllowedDirectoriesMap { diff --git a/src/plugins/leak_test.go b/src/plugins/leak_test.go new file mode 100644 index 0000000000..374e99f47c --- /dev/null +++ b/src/plugins/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package plugins + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/plugins/nginx_counter.go b/src/plugins/nginx_counter.go index d33fec57e0..e4d3e1e53c 100644 --- a/src/plugins/nginx_counter.go +++ b/src/plugins/nginx_counter.go @@ -84,7 +84,7 @@ func (nc *NginxCounter) agentServer(serverAddress []string) { log.Warn("failed to start NGINX counter listener") } - err = core.EnableWritePermissionForSocket(serverAddress[1]) + err = core.EnableWritePermissionForSocket(nc.ctx, serverAddress[1]) if err != nil { log.Warn("unable to set correct write permissions for NGINX counter socket") } diff --git a/src/plugins/process_watcher_test.go b/src/plugins/process_watcher_test.go index 05b7d69a66..2fd31b21e7 100644 --- a/src/plugins/process_watcher_test.go +++ b/src/plugins/process_watcher_test.go @@ -11,6 +11,8 @@ import ( "context" "testing" + "github.com/stretchr/testify/mock" + "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" @@ -24,6 +26,7 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { seenMasterProcs map[int32]*core.Process seenWorkerProcs map[int32]*core.Process seenNginxDetails map[int32]*proto.NginxDetails + nginxDetails []*proto.NginxDetails nginxProcs []*core.Process expectedProcUpdates map[string]string expectedMasterPids []int32 @@ -34,6 +37,32 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { seenMasterProcs: map[int32]*core.Process{}, seenWorkerProcs: map[int32]*core.Process{}, seenNginxDetails: map[int32]*proto.NginxDetails{}, + nginxDetails: []*proto.NginxDetails{ + { + NginxId: "1", Version: "21", ConfPath: "/etc/yo", ProcessId: "1", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "2", Version: "21", ConfPath: "/etc/yo", ProcessId: "2", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "3", Version: "21", ConfPath: "/etc/yo", ProcessId: "3", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + }, nginxProcs: []*core.Process{ tutils.GetProcesses()[0], tutils.GetProcesses()[1], @@ -61,6 +90,24 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { 2: {ProcessId: "2"}, 3: {ProcessId: "3"}, }, + nginxDetails: []*proto.NginxDetails{ + { + NginxId: "4", Version: "21", ConfPath: "/etc/yo", ProcessId: "4", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "5", Version: "21", ConfPath: "/etc/yo", ProcessId: "5", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + }, nginxProcs: []*core.Process{ tutils.GetProcesses()[0], {Pid: 4, ParentPid: 1, Name: "worker-1", IsMaster: false}, @@ -94,6 +141,56 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { {Pid: 7, ParentPid: 6, Name: "worker-1", IsMaster: false}, {Pid: 8, ParentPid: 6, Name: "worker-2", IsMaster: false}, }, + nginxDetails: []*proto.NginxDetails{ + { + NginxId: "6", Version: "21", ConfPath: "/etc/yo", ProcessId: "6", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "7", Version: "21", ConfPath: "/etc/yo", ProcessId: "7", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "8", Version: "21", ConfPath: "/etc/yo", ProcessId: "8", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "1", Version: "21", ConfPath: "/etc/yo", ProcessId: "1", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "2", Version: "21", ConfPath: "/etc/yo", ProcessId: "2", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "3", Version: "21", ConfPath: "/etc/yo", ProcessId: "3", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + }, expectedProcUpdates: map[string]string{ "6": "nginx.master.created", "7": "nginx.worker.created", @@ -133,7 +230,11 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { env := tutils.NewMockEnvironment() - binary := core.NewNginxBinary(env, &config.Config{}) + binary := &tutils.MockNginxBinary{} + + for _, nginxDetail := range tt.nginxDetails { + binary.On("GetNginxDetailsFromProcess", mock.Anything).Return(nginxDetail).Once() + } pw := NewProcessWatcher(env, binary, tt.nginxProcs, &config.Config{}) pw.seenMasterProcs = tt.seenMasterProcs diff --git a/test/integration/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go b/test/integration/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go index f5fa9e3b0a..6c26373b02 100644 --- a/test/integration/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go +++ b/test/integration/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go @@ -41,7 +41,7 @@ func WaitUntil( expoBackoffWithContext := backoff.WithContext(exponentialBackoff, ctx) - err := backoff.Retry(backoff.Operation(operation), expoBackoffWithContext) + err := backoff.Retry(operation, expoBackoffWithContext) if err != nil { return err } diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/config/config.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/config/config.go index addc4604b4..dfee04b1bc 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/config/config.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/config/config.go @@ -429,12 +429,11 @@ func LoadPropertiesFromFile(cfg string) error { if err != nil { return fmt.Errorf("error attempting to open dynamic config (%s): %v", dynamicCfgPath, err) } - + defer dynCfg.Close() featuresAreSet, cleanDynCfgContent, err := removeFeatures(dynCfg) if err != nil { return fmt.Errorf("error updating dynamic config with features removed (%s): %v", dynamicCfgPath, err) } - dynCfg.Close() if featuresAreSet { err = os.WriteFile(dynamicCfgPath, cleanDynCfgContent, 0o640) diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go index 7ddfb52690..6dc2f802e0 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go @@ -408,7 +408,7 @@ func getContainerID(mountInfo string) (string, error) { if err != nil { return "", fmt.Errorf("could not read %s: %v", mountInfo, err) } - + defer mInfoFile.Close() fileScanner := bufio.NewScanner(mInfoFile) fileScanner.Split(bufio.ScanLines) @@ -416,7 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - err = mInfoFile.Close() if err != nil { return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) } diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go index fcc9901d7f..885b91ba3c 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -8,9 +8,12 @@ package core import ( + "context" "os" "sync" "time" + + "github.com/nginx/agent/sdk/v2/backoff" ) var chmodMutex sync.Mutex @@ -47,21 +50,19 @@ func FilesExists(filePaths []string) (bool, error) { // EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. // The function continuously attempts the operation until either it succeeds or the timeout period elapses. -func EnableWritePermissionForSocket(path string) error { - timeout := time.After(time.Second * 1) - var lastError error - for { - select { - case <-timeout: - return lastError - default: - chmodMutex.Lock() - lastError = os.Chmod(path, 0o660) - chmodMutex.Unlock() - if lastError == nil { - return nil - } - } - time.Sleep(time.Microsecond * 100) - } +func EnableWritePermissionForSocket(ctx context.Context, path string) error { + err := backoff.WaitUntil(ctx, backoff.BackoffSettings{ + InitialInterval: time.Microsecond * 100, + MaxInterval: time.Microsecond * 100, + MaxElapsedTime: time.Second * 1, + Jitter: backoff.BACKOFF_JITTER, + Multiplier: backoff.BACKOFF_MULTIPLIER, + }, func() error { + chmodMutex.Lock() + lastError := os.Chmod(path, 0o660) + chmodMutex.Unlock() + return lastError + }) + + return err } diff --git a/test/performance/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go b/test/performance/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go index f5fa9e3b0a..6c26373b02 100644 --- a/test/performance/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go +++ b/test/performance/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go @@ -41,7 +41,7 @@ func WaitUntil( expoBackoffWithContext := backoff.WithContext(exponentialBackoff, ctx) - err := backoff.Retry(backoff.Operation(operation), expoBackoffWithContext) + err := backoff.Retry(operation, expoBackoffWithContext) if err != nil { return err } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/config/config.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/config/config.go index addc4604b4..dfee04b1bc 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/config/config.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/config/config.go @@ -429,12 +429,11 @@ func LoadPropertiesFromFile(cfg string) error { if err != nil { return fmt.Errorf("error attempting to open dynamic config (%s): %v", dynamicCfgPath, err) } - + defer dynCfg.Close() featuresAreSet, cleanDynCfgContent, err := removeFeatures(dynCfg) if err != nil { return fmt.Errorf("error updating dynamic config with features removed (%s): %v", dynamicCfgPath, err) } - dynCfg.Close() if featuresAreSet { err = os.WriteFile(dynamicCfgPath, cleanDynCfgContent, 0o640) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go index 7ddfb52690..6dc2f802e0 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go @@ -408,7 +408,7 @@ func getContainerID(mountInfo string) (string, error) { if err != nil { return "", fmt.Errorf("could not read %s: %v", mountInfo, err) } - + defer mInfoFile.Close() fileScanner := bufio.NewScanner(mInfoFile) fileScanner.Split(bufio.ScanLines) @@ -416,7 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - err = mInfoFile.Close() if err != nil { return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go index fcc9901d7f..885b91ba3c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -8,9 +8,12 @@ package core import ( + "context" "os" "sync" "time" + + "github.com/nginx/agent/sdk/v2/backoff" ) var chmodMutex sync.Mutex @@ -47,21 +50,19 @@ func FilesExists(filePaths []string) (bool, error) { // EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. // The function continuously attempts the operation until either it succeeds or the timeout period elapses. -func EnableWritePermissionForSocket(path string) error { - timeout := time.After(time.Second * 1) - var lastError error - for { - select { - case <-timeout: - return lastError - default: - chmodMutex.Lock() - lastError = os.Chmod(path, 0o660) - chmodMutex.Unlock() - if lastError == nil { - return nil - } - } - time.Sleep(time.Microsecond * 100) - } +func EnableWritePermissionForSocket(ctx context.Context, path string) error { + err := backoff.WaitUntil(ctx, backoff.BackoffSettings{ + InitialInterval: time.Microsecond * 100, + MaxInterval: time.Microsecond * 100, + MaxElapsedTime: time.Second * 1, + Jitter: backoff.BACKOFF_JITTER, + Multiplier: backoff.BACKOFF_MULTIPLIER, + }, func() error { + chmodMutex.Lock() + lastError := os.Chmod(path, 0o660) + chmodMutex.Unlock() + return lastError + }) + + return err } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/advanced_metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/advanced_metrics.go index 33ad249be3..32b61fef2d 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/advanced_metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/advanced_metrics.go @@ -259,9 +259,9 @@ func (m *AdvancedMetrics) run() { } }() defer m.ctxCancel() - err := core.EnableWritePermissionForSocket(m.cfg.Address) + err := core.EnableWritePermissionForSocket(m.ctx, m.cfg.Address) if err != nil { - log.Error("App centric metric plugin failed to change socket permissions") + log.Errorf("App centric metric plugin failed to change socket permissions: %v", err) } commonDimensions := append(m.commonDims.ToDimensions(), &proto.Dimension{ Name: aggregationDurationDimension, diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nap_monitoring.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nap_monitoring.go index a59d3bfdfa..061a31d5cd 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nap_monitoring.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nap_monitoring.go @@ -11,12 +11,13 @@ import ( "context" "time" + "github.com/nginx/agent/v2/src/core/metrics" + agent_config "github.com/nginx/agent/sdk/v2/agent/config" "github.com/nginx/agent/sdk/v2/proto" models "github.com/nginx/agent/sdk/v2/proto/events" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" - "github.com/nginx/agent/v2/src/core/metrics" "github.com/nginx/agent/v2/src/core/payloads" "github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager" @@ -41,16 +42,18 @@ var nginxAppProtectMonitoringDefault = &manager.NginxAppProtectMonitoringConfig{ } type NAPMonitoring struct { - monitorMgr *manager.Manager - messagePipeline core.MessagePipeInterface - reportInterval time.Duration - reportCount int - ctx context.Context - ctxCancel context.CancelFunc + monitorMgr *manager.Manager + messagePipeline core.MessagePipeInterface + reportInterval time.Duration + reportCount int + ctx context.Context + ctxCancel context.CancelFunc + nginxAppProtectMonitoringConfig *manager.NginxAppProtectMonitoringConfig + env core.Environment + cfg *config.Config } func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectMonitoringConf interface{}) (*NAPMonitoring, error) { - commonDims := metrics.NewCommonDim(env.NewHostInfo("agentVersion", &cfg.Tags, cfg.ConfigDirs, false), cfg, "") nginxAppProtectMonitoringConfig := nginxAppProtectMonitoringDefault if nginxAppProtectMonitoringConf != nil { @@ -62,11 +65,6 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectM } } - m, err := manager.NewManager(nginxAppProtectMonitoringConfig, commonDims) - if err != nil { - return nil, err - } - if !(nginxAppProtectMonitoringConfig.ReportInterval > minReportIntervalDelimiter) { log.Warnf("NAP Monitoring report interval must be higher than %v. Defaulting to %v", minReportIntervalDelimiter, @@ -83,9 +81,11 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectM } return &NAPMonitoring{ - monitorMgr: m, - reportInterval: nginxAppProtectMonitoringConfig.ReportInterval, - reportCount: nginxAppProtectMonitoringConfig.ReportCount, + cfg: cfg, + nginxAppProtectMonitoringConfig: nginxAppProtectMonitoringConfig, + env: env, + reportInterval: nginxAppProtectMonitoringConfig.ReportInterval, + reportCount: nginxAppProtectMonitoringConfig.ReportCount, }, nil } @@ -94,6 +94,15 @@ func (n *NAPMonitoring) Info() *core.Info { } func (n *NAPMonitoring) Init(pipeline core.MessagePipeInterface) { + commonDims := metrics.NewCommonDim(n.env.NewHostInfo("agentVersion", &n.cfg.Tags, n.cfg.ConfigDirs, false), n.cfg, "") + + m, err := manager.NewManager(n.nginxAppProtectMonitoringConfig, commonDims) + if err != nil { + log.Errorf("Could not initialize nginx-app-protect-monitoring: %v", err) + return + } + + n.monitorMgr = m log.Infof("%s initializing", napMonitoringPluginName) n.messagePipeline = pipeline ctx, cancel := context.WithCancel(n.messagePipeline.Context()) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go index d1d37f80e1..49a486d10a 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go @@ -8,6 +8,7 @@ package nap import ( + "context" "fmt" "io/fs" "os" @@ -98,15 +99,15 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) // - NAP version changed // - Attack signature installed/version changed // - Threat campaign installed/version changed -func (nap *NginxAppProtect) Monitor(pollInterval time.Duration) chan NAPReportBundle { +func (nap *NginxAppProtect) Monitor(ctx context.Context, pollInterval time.Duration) chan NAPReportBundle { msgChannel := make(chan NAPReportBundle) - go nap.monitor(msgChannel, pollInterval) + go nap.monitor(ctx, msgChannel, pollInterval) return msgChannel } // monitor checks the system for any NAP related changes and communicates those changes with // a report message sent via the channel provided to it. -func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterval time.Duration) { +func (nap *NginxAppProtect) monitor(ctx context.Context, msgChannel chan NAPReportBundle, pollInterval time.Duration) { // Initial symlink sync mu.Lock() if nap.Release.VersioningDetails.NAPRelease != "" { @@ -118,7 +119,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva mu.Unlock() ticker := time.NewTicker(pollInterval) - + defer ticker.Stop() for { select { case <-ticker.C: @@ -162,6 +163,8 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva PreviousReport: previousReport, UpdatedReport: newNAPReport, } + case <-ctx.Done(): + return } } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go index ee7f9e95d3..fccffa6a7b 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go @@ -130,7 +130,7 @@ func (n *NginxAppProtect) monitor() { ), ) - napUpdateChannel := n.nap.Monitor(n.reportInterval) + napUpdateChannel := n.nap.Monitor(n.ctx, n.reportInterval) defer close(napUpdateChannel) for { select { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/file_watcher.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/file_watcher.go index 74b3cfd2e6..9d3568c031 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/file_watcher.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/file_watcher.go @@ -51,15 +51,9 @@ const ( ) func NewFileWatcher(config *config.Config, env core.Environment) *FileWatcher { - watcher, err := fsnotify.NewWatcher() - if err != nil { - log.Errorf("Error creating file watcher: %v", err) - } - fw := &FileWatcher{ config: config, watching: &sync.Map{}, - watcher: watcher, wg: sync.WaitGroup{}, env: env, enabled: true, @@ -71,6 +65,14 @@ func NewFileWatcher(config *config.Config, env core.Environment) *FileWatcher { func (fw *FileWatcher) Init(pipeline core.MessagePipeInterface) { log.Info("FileWatcher initializing") + watcher, err := fsnotify.NewWatcher() + if err != nil { + log.Errorf("Error creating file watcher: %v", err) + return + } + + fw.watcher = watcher + fw.messagePipeline = pipeline fw.ctx, fw.cancelFunction = context.WithCancel(fw.messagePipeline.Context()) for dir := range fw.config.AllowedDirectoriesMap { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go index d33fec57e0..e4d3e1e53c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go @@ -84,7 +84,7 @@ func (nc *NginxCounter) agentServer(serverAddress []string) { log.Warn("failed to start NGINX counter listener") } - err = core.EnableWritePermissionForSocket(serverAddress[1]) + err = core.EnableWritePermissionForSocket(nc.ctx, serverAddress[1]) if err != nil { log.Warn("unable to set correct write permissions for NGINX counter socket") } diff --git a/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go b/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go index f5fa9e3b0a..6c26373b02 100644 --- a/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go +++ b/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go @@ -41,7 +41,7 @@ func WaitUntil( expoBackoffWithContext := backoff.WithContext(exponentialBackoff, ctx) - err := backoff.Retry(backoff.Operation(operation), expoBackoffWithContext) + err := backoff.Retry(operation, expoBackoffWithContext) if err != nil { return err } From de57d5e6dac2b73207fd0ce86d522f02ae1b0778 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Thu, 22 Aug 2024 15:29:36 +0100 Subject: [PATCH 45/49] remove info logging --- src/plugins/metrics_throlling.go | 5 ----- .../nginx/agent/v2/src/plugins/metrics_throlling.go | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index c052539277..249ff15ef2 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -214,11 +214,6 @@ func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { Data: metrics.GenerateMetrics(*collection), } - log.Infof("%v report created with %d stats entities", report.Type, len(report.Data)) - for _, entity := range report.GetData() { - log.Infof("%v", entity) - } - reports = append(reports, report) r.metricsCollections[reportType] = &metrics.Collections{ diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index c052539277..249ff15ef2 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -214,11 +214,6 @@ func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { Data: metrics.GenerateMetrics(*collection), } - log.Infof("%v report created with %d stats entities", report.Type, len(report.Data)) - for _, entity := range report.GetData() { - log.Infof("%v", entity) - } - reports = append(reports, report) r.metricsCollections[reportType] = &metrics.Collections{ From 29f0a0962622d83c7c210b7aaa176af8475b6f2d Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Mon, 26 Aug 2024 16:45:46 +0100 Subject: [PATCH 46/49] code comments --- nginx-agent.conf | 13 +++++++++---- src/core/environment.go | 3 --- .../nginx/agent/v2/src/core/environment.go | 3 --- .../nginx/agent/v2/src/core/environment.go | 3 --- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/nginx-agent.conf b/nginx-agent.conf index 16afeb001e..47e21184a5 100644 --- a/nginx-agent.conf +++ b/nginx-agent.conf @@ -36,7 +36,12 @@ metrics: # path to aux file dirs can also be added config_dirs: "/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms" -api: - - host: 127.0.0.1 - port: 8038 + # The port at which NGINX Agent accepts remote connections + # The API address and port allow for remote management of NGINX and NGINX Agent + # + # ~~~ WARNING ~~~ + # Set API address to allow remote management + # host: 127.0.0.1 + # + # Set this value to a secure port number to prevent information leaks. + # port: 8038 \ No newline at end of file diff --git a/src/core/environment.go b/src/core/environment.go index 6dc2f802e0..5bb0355aa3 100644 --- a/src/core/environment.go +++ b/src/core/environment.go @@ -416,9 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - if err != nil { - return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) - } for _, line := range lines { splitLine := strings.Split(line, " ") diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go index 6dc2f802e0..5bb0355aa3 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go @@ -416,9 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - if err != nil { - return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) - } for _, line := range lines { splitLine := strings.Split(line, " ") diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go index 6dc2f802e0..5bb0355aa3 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go @@ -416,9 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - if err != nil { - return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) - } for _, line := range lines { splitLine := strings.Split(line, " ") From 628a25ea1e90488e7978dd3379bc7a774480b929 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 27 Aug 2024 11:47:55 +0100 Subject: [PATCH 47/49] updated config --- nginx-agent.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/nginx-agent.conf b/nginx-agent.conf index 47e21184a5..f2e1a04799 100644 --- a/nginx-agent.conf +++ b/nginx-agent.conf @@ -24,6 +24,7 @@ dataplane: poll_interval: 30s # report interval for data plane status - the maximum duration to wait before syncing dataplane information if no updates have being observed report_interval: 24h + metrics: # specify the size of a buffer to build before sending metrics bulk_size: 20 From e6c68f4ec09480b4e2238c82c795ea1b9df0506c Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 27 Aug 2024 14:01:12 +0100 Subject: [PATCH 48/49] code review comments --- nginx-agent.conf | 1 + src/plugins/metrics.go | 4 +--- .../vendor/github.com/nginx/agent/v2/src/plugins/metrics.go | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/nginx-agent.conf b/nginx-agent.conf index f2e1a04799..5a714bb5c7 100644 --- a/nginx-agent.conf +++ b/nginx-agent.conf @@ -37,6 +37,7 @@ metrics: # path to aux file dirs can also be added config_dirs: "/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms" + # api: # The port at which NGINX Agent accepts remote connections # The API address and port allow for remote management of NGINX and NGINX Agent # diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index 0ac475f5fa..17ebdd9086 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -229,8 +229,6 @@ func (m *Metrics) drainBuffer(ctx context.Context) { } func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { - // set a timeout for a millisecond less than the collection interval - ctx := context.Background() // locks the m.collectors to make sure it doesn't get deleted in the middle // of collection, as we will delete the old one if config changes. // maybe we can fine tune the lock later, but the collection has been very quick so far. @@ -238,7 +236,7 @@ func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { defer m.collectorsMutex.Unlock() start := time.Now() for _, s := range m.collectors { - go s.Collect(ctx, m.buf) + go s.Collect(m.ctx, m.buf) } log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index 0ac475f5fa..17ebdd9086 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -229,8 +229,6 @@ func (m *Metrics) drainBuffer(ctx context.Context) { } func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { - // set a timeout for a millisecond less than the collection interval - ctx := context.Background() // locks the m.collectors to make sure it doesn't get deleted in the middle // of collection, as we will delete the old one if config changes. // maybe we can fine tune the lock later, but the collection has been very quick so far. @@ -238,7 +236,7 @@ func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { defer m.collectorsMutex.Unlock() start := time.Now() for _, s := range m.collectors { - go s.Collect(ctx, m.buf) + go s.Collect(m.ctx, m.buf) } log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) From ca0ef5f125ce6d21486bc8674ddce716bcf2447d Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 27 Aug 2024 14:05:06 +0100 Subject: [PATCH 49/49] lint --- src/plugins/metrics.go | 2 +- .../vendor/github.com/nginx/agent/v2/src/plugins/metrics.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index 17ebdd9086..55238474c4 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -239,7 +239,7 @@ func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { go s.Collect(m.ctx, m.buf) } - log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) + log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), m.ctx.Err() != nil) return } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index 17ebdd9086..55238474c4 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -239,7 +239,7 @@ func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { go s.Collect(m.ctx, m.buf) } - log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) + log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), m.ctx.Err() != nil) return }