From 765a3e79b16eac2344aaa22db0b3a341796919cf Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Thu, 20 Feb 2025 15:23:16 +0700 Subject: [PATCH 1/7] try to upgrade to 20241010143419 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 736089d38..1c23c2677 100644 --- a/go.mod +++ b/go.mod @@ -154,6 +154,6 @@ require ( k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) diff --git a/go.sum b/go.sum index 6696e1563..59e8b35a6 100644 --- a/go.sum +++ b/go.sum @@ -604,8 +604,8 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= From 13cbe7e6dc6338be46744b48408f159408737bd2 Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Thu, 20 Feb 2025 15:30:58 +0700 Subject: [PATCH 2/7] Revert "try to upgrade to 20241010143419" This reverts commit c0d81182ee4769bae0dd3ba40cc8d36c768c4f07. --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1c23c2677..736089d38 100644 --- a/go.mod +++ b/go.mod @@ -154,6 +154,6 @@ require ( k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect - sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) diff --git a/go.sum b/go.sum index 59e8b35a6..6696e1563 100644 --- a/go.sum +++ b/go.sum @@ -604,8 +604,8 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= -sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= From 6945f7f5c0d206b47c879af97dec4a651d7618da Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Thu, 20 Feb 2025 15:32:25 +0700 Subject: [PATCH 3/7] k8s.io/client-go v0.29.14 --- go.mod | 8 ++++---- go.sum | 20 ++++++++------------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 736089d38..7fc525f4c 100644 --- a/go.mod +++ b/go.mod @@ -51,9 +51,9 @@ require ( google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.29.0 - k8s.io/apimachinery v0.29.0 - k8s.io/client-go v0.29.0 + k8s.io/api v0.29.14 + k8s.io/apimachinery v0.29.14 + k8s.io/client-go v0.29.14 sigs.k8s.io/yaml v1.3.0 ) @@ -81,7 +81,7 @@ require ( github.com/go-openapi/swag v0.22.3 // indirect github.com/godbus/dbus/v5 v5.0.4 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect diff --git a/go.sum b/go.sum index 6696e1563..7bf421c7d 100644 --- a/go.sum +++ b/go.sum @@ -117,15 +117,13 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -565,8 +563,6 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002 h1:V7Da7qt0MkY3noVANIMVBk28nOnijADeOR3i5Hcvpj4= google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -592,12 +588,12 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.29.0 h1:NiCdQMY1QOp1H8lfRyeEf8eOwV6+0xA6XEE44ohDX2A= -k8s.io/api v0.29.0/go.mod h1:sdVmXoz2Bo/cb77Pxi71IPTSErEW32xa4aXwKH7gfBA= -k8s.io/apimachinery v0.29.0 h1:+ACVktwyicPz0oc6MTMLwa2Pw3ouLAfAon1wPLtG48o= -k8s.io/apimachinery v0.29.0/go.mod h1:eVBxQ/cwiJxH58eK/jd/vAk4mrxmVlnpBH5J2GbMeis= -k8s.io/client-go v0.29.0 h1:KmlDtFcrdUzOYrBhXHgKw5ycWzc3ryPX5mQe0SkG3y8= -k8s.io/client-go v0.29.0/go.mod h1:yLkXH4HKMAywcrD82KMSmfYg2DlE8mepPR4JGSo5n38= +k8s.io/api v0.29.14 h1:JWFh5ufowH3Y6tCgEzY3URVJHb27f0tEDEej0nCjWDw= +k8s.io/api v0.29.14/go.mod h1:IV8YqKxMm8JGLBLlHM13Npn5lCITH10XYipWEW+YEOQ= +k8s.io/apimachinery v0.29.14 h1:IDhwnGNCp836SLOwW1SoEfFNV77wxIklhxeAHX9vmSo= +k8s.io/apimachinery v0.29.14/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= +k8s.io/client-go v0.29.14 h1:OSnzZ9DClaFRgl3zMAY2kGZhNjdGJkEb+RDz+MW2h6k= +k8s.io/client-go v0.29.14/go.mod h1:XtZt5n5UxKfPJ+sCoTPcEavWgZbLFFxMnAFFRQGK1RY= k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= From 87fa89c8ce86c19fc8136473f6de26e5c0bedcc7 Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Thu, 20 Feb 2025 17:25:58 +0700 Subject: [PATCH 4/7] meta about deleted pods expires too --- plugin/input/k8s/meta/gatherer.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugin/input/k8s/meta/gatherer.go b/plugin/input/k8s/meta/gatherer.go index 3eee80b37..e9a47b1ea 100644 --- a/plugin/input/k8s/meta/gatherer.go +++ b/plugin/input/k8s/meta/gatherer.go @@ -234,11 +234,6 @@ func getExpiredItems(out []*MetaItem) []*MetaItem { // find pods which aren't in k8s pod list for some time and add them to the expiration list for ns, podNames := range MetaData { for pod, containerIDs := range podNames { - isDeleted := deletedPodsCache.Contains(pod) - if isDeleted { - // information about deleted pods will never change again - continue - } for cid, podData := range containerIDs { if now.Sub(podData.updateTime) > MetaExpireDuration { out = append(out, &MetaItem{ From d4855816a30db012c4e69fca895324ae674b08eb Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Mon, 24 Feb 2025 17:52:15 +0700 Subject: [PATCH 5/7] metric for metric on len k8s meta --- plugin/input/k8s/k8s.go | 11 +++++++++++ plugin/input/k8s/k8s_test.go | 1 - plugin/input/k8s/meta/gatherer.go | 5 +++++ plugin/input/k8s/pipeline_test.go | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugin/input/k8s/k8s.go b/plugin/input/k8s/k8s.go index a9675a20e..7d7805691 100644 --- a/plugin/input/k8s/k8s.go +++ b/plugin/input/k8s/k8s.go @@ -6,9 +6,11 @@ import ( "github.com/ozontech/file.d/cfg" "github.com/ozontech/file.d/decoder" "github.com/ozontech/file.d/fd" + "github.com/ozontech/file.d/metric" "github.com/ozontech/file.d/pipeline" "github.com/ozontech/file.d/plugin/input/file" "github.com/ozontech/file.d/plugin/input/k8s/meta" + "github.com/prometheus/client_golang/prometheus" "go.uber.org/atomic" "go.uber.org/zap" @@ -50,6 +52,9 @@ type Plugin struct { params *pipeline.InputPluginParams fp *file.Plugin + + // plugin metrics + metaPodsCount prometheus.Gauge } type Config struct { @@ -154,6 +159,8 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.InputPluginPa p.params = params p.config = config.(*Config) + p.registerMetrics(params.MetricCtl) + startCounter := startCounter.Inc() if startCounter == 1 { @@ -192,6 +199,10 @@ func setBuiltInMeta(metaConfig cfg.MetaTemplates) { metaConfig["k8s_container_id"] = "{{ .container_id }}" } +func (p *Plugin) registerMetrics(ctl *metric.Ctl) { + p.metaPodsCount = ctl.RegisterGauge("meta_pods_count", "") +} + /*{ meta-params **`pod_name`** - string diff --git a/plugin/input/k8s/k8s_test.go b/plugin/input/k8s/k8s_test.go index ef19ffcea..27aaee4ca 100644 --- a/plugin/input/k8s/k8s_test.go +++ b/plugin/input/k8s/k8s_test.go @@ -216,7 +216,6 @@ func TestK8SJoin(t *testing.T) { func TestCleanUp(t *testing.T) { p, _, _ := test.NewPipelineMock(test.NewActionPluginStaticInfo(MultilineActionFactory, config(), pipeline.MatchModeAnd, nil, false)) - meta.EnableGatherer(logger.Instance) meta.PutMeta(getPodInfo(&meta.MetaItem{ diff --git a/plugin/input/k8s/meta/gatherer.go b/plugin/input/k8s/meta/gatherer.go index e9a47b1ea..c3a00ac31 100644 --- a/plugin/input/k8s/meta/gatherer.go +++ b/plugin/input/k8s/meta/gatherer.go @@ -2,6 +2,7 @@ package meta import ( "context" + "fmt" "os" "path/filepath" "strings" @@ -265,6 +266,10 @@ func cleanUpItems(items []*MetaItem) { delete(MetaData, item.Namespace) } } + + if len(items) > 0 { + fmt.Println(len(items)) + } } func GetPodMeta(ns Namespace, pod PodName, cid ContainerID) (bool, *podMeta) { diff --git a/plugin/input/k8s/pipeline_test.go b/plugin/input/k8s/pipeline_test.go index 994312f3d..97ef8f4e5 100644 --- a/plugin/input/k8s/pipeline_test.go +++ b/plugin/input/k8s/pipeline_test.go @@ -41,6 +41,7 @@ func TestPipeline(t *testing.T) { k8sContainerID = strings.Clone(e.Root.Dig("k8s_container_id").AsString()) wg.Done() }) + p.Start() item := &meta.MetaItem{ Namespace: "sre", @@ -51,7 +52,6 @@ func TestPipeline(t *testing.T) { meta.PutMeta(getPodInfo(item, true)) filename := getLogFilename(dir, item) - p.Start() file, err := os.Create(filename) if err != nil { logger.Fatalf("Error creating file: %s", err.Error()) From d23df2c3865a07987fab17822e7515779449b204 Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Tue, 25 Feb 2025 15:53:16 +0700 Subject: [PATCH 6/7] Revert "metric for metric on len k8s meta" This reverts commit 2cd40c274088c569acabf3ba0150376eb3081dc5. --- plugin/input/k8s/k8s.go | 11 ----------- plugin/input/k8s/k8s_test.go | 1 + plugin/input/k8s/meta/gatherer.go | 5 ----- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/plugin/input/k8s/k8s.go b/plugin/input/k8s/k8s.go index 7d7805691..a9675a20e 100644 --- a/plugin/input/k8s/k8s.go +++ b/plugin/input/k8s/k8s.go @@ -6,11 +6,9 @@ import ( "github.com/ozontech/file.d/cfg" "github.com/ozontech/file.d/decoder" "github.com/ozontech/file.d/fd" - "github.com/ozontech/file.d/metric" "github.com/ozontech/file.d/pipeline" "github.com/ozontech/file.d/plugin/input/file" "github.com/ozontech/file.d/plugin/input/k8s/meta" - "github.com/prometheus/client_golang/prometheus" "go.uber.org/atomic" "go.uber.org/zap" @@ -52,9 +50,6 @@ type Plugin struct { params *pipeline.InputPluginParams fp *file.Plugin - - // plugin metrics - metaPodsCount prometheus.Gauge } type Config struct { @@ -159,8 +154,6 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.InputPluginPa p.params = params p.config = config.(*Config) - p.registerMetrics(params.MetricCtl) - startCounter := startCounter.Inc() if startCounter == 1 { @@ -199,10 +192,6 @@ func setBuiltInMeta(metaConfig cfg.MetaTemplates) { metaConfig["k8s_container_id"] = "{{ .container_id }}" } -func (p *Plugin) registerMetrics(ctl *metric.Ctl) { - p.metaPodsCount = ctl.RegisterGauge("meta_pods_count", "") -} - /*{ meta-params **`pod_name`** - string diff --git a/plugin/input/k8s/k8s_test.go b/plugin/input/k8s/k8s_test.go index 27aaee4ca..ef19ffcea 100644 --- a/plugin/input/k8s/k8s_test.go +++ b/plugin/input/k8s/k8s_test.go @@ -216,6 +216,7 @@ func TestK8SJoin(t *testing.T) { func TestCleanUp(t *testing.T) { p, _, _ := test.NewPipelineMock(test.NewActionPluginStaticInfo(MultilineActionFactory, config(), pipeline.MatchModeAnd, nil, false)) + meta.EnableGatherer(logger.Instance) meta.PutMeta(getPodInfo(&meta.MetaItem{ diff --git a/plugin/input/k8s/meta/gatherer.go b/plugin/input/k8s/meta/gatherer.go index c3a00ac31..e9a47b1ea 100644 --- a/plugin/input/k8s/meta/gatherer.go +++ b/plugin/input/k8s/meta/gatherer.go @@ -2,7 +2,6 @@ package meta import ( "context" - "fmt" "os" "path/filepath" "strings" @@ -266,10 +265,6 @@ func cleanUpItems(items []*MetaItem) { delete(MetaData, item.Namespace) } } - - if len(items) > 0 { - fmt.Println(len(items)) - } } func GetPodMeta(ns Namespace, pod PodName, cid ContainerID) (bool, *podMeta) { From ec3c409362b4561261fccb2f4b566b030b378ea7 Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Tue, 25 Feb 2025 18:46:33 +0700 Subject: [PATCH 7/7] deletedPodsCounter --- plugin/input/k8s/meta/gatherer.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugin/input/k8s/meta/gatherer.go b/plugin/input/k8s/meta/gatherer.go index e9a47b1ea..72e04ec1c 100644 --- a/plugin/input/k8s/meta/gatherer.go +++ b/plugin/input/k8s/meta/gatherer.go @@ -70,6 +70,7 @@ var ( DisableMetaUpdates = false metaAddedCounter atomic.Int64 expiredItemsCounter atomic.Int64 + deletedPodsCounter atomic.Int64 CriType = "docker" NodeLabels = make(map[string]string) @@ -163,6 +164,7 @@ func initInformer() { pod := obj.(*corev1.Pod) PutMeta(pod) deletedPodsCache.Add(PodName(pod.Name), true) + deletedPodsCounter.Inc() }, }, cache.Indexers{}) controller = c @@ -189,11 +191,19 @@ func removeExpired() { cleanUpItems(expiredItems) if MaintenanceInterval > time.Second { - localLogger.Infof("k8s meta stat for last %d seconds: total=%d, updated=%d, expired=%d", MaintenanceInterval/time.Second, getTotalItems(), metaAddedCounter.Load(), expiredItemsCounter.Load()) + localLogger.Infof( + "k8s meta stat for last %d seconds: total=%d, updated=%d, expired=%d, deleted=%d", + MaintenanceInterval/time.Second, + getTotalItems(), + metaAddedCounter.Load(), + expiredItemsCounter.Load(), + deletedPodsCounter.Load(), + ) } metaAddedCounter.Swap(0) expiredItemsCounter.Swap(0) + deletedPodsCounter.Swap(0) } func maintenance() {