From 1110fd93b0e634b111b0113d964ee17320429010 Mon Sep 17 00:00:00 2001 From: Joachim Bartosik Date: Thu, 26 Dec 2024 16:48:28 +0000 Subject: [PATCH] Pod Node Affinity inv tidy --- comp/otelcol/ddflareextension/impl/go.mod | 2 +- comp/otelcol/ddflareextension/impl/go.sum | 4 +- comp/otelcol/logsagentpipeline/go.mod | 2 +- comp/otelcol/logsagentpipeline/go.sum | 4 +- .../logsagentpipelineimpl/go.mod | 2 +- .../logsagentpipelineimpl/go.sum | 4 +- .../exporter/datadogexporter/go.mod | 2 +- .../exporter/datadogexporter/go.sum | 4 +- .../exporter/serializerexporter/go.mod | 2 +- .../exporter/serializerexporter/go.sum | 4 +- go.sum | 2 - .../orchestrator/transformers/k8s/pod.go | 63 +++++ .../orchestrator/transformers/k8s/pod_test.go | 236 ++++++++++++++++++ pkg/logs/pipeline/go.mod | 2 +- pkg/logs/pipeline/go.sum | 4 +- pkg/logs/processor/go.mod | 2 +- pkg/logs/processor/go.sum | 4 +- pkg/process/util/api/go.mod | 2 +- pkg/process/util/api/go.sum | 4 +- pkg/serializer/go.mod | 2 +- pkg/serializer/go.sum | 4 +- test/fakeintake/go.mod | 2 +- test/fakeintake/go.sum | 4 +- test/new-e2e/go.mod | 2 +- test/new-e2e/go.sum | 4 +- test/otel/go.mod | 2 +- test/otel/go.sum | 4 +- 27 files changed, 335 insertions(+), 38 deletions(-) diff --git a/comp/otelcol/ddflareextension/impl/go.mod b/comp/otelcol/ddflareextension/impl/go.mod index 2c7558943396fc..3b28fb93fd6262 100644 --- a/comp/otelcol/ddflareextension/impl/go.mod +++ b/comp/otelcol/ddflareextension/impl/go.mod @@ -182,7 +182,7 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/Code-Hex/go-generics-cache v1.5.1 // indirect - github.com/DataDog/agent-payload/v5 v5.0.138 // indirect + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee // indirect github.com/DataDog/datadog-agent/comp/core/config v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/flare/builder v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.59.0 // indirect diff --git a/comp/otelcol/ddflareextension/impl/go.sum b/comp/otelcol/ddflareextension/impl/go.sum index f1d97d93368db5..ce4b1c3c165aaa 100644 --- a/comp/otelcol/ddflareextension/impl/go.sum +++ b/comp/otelcol/ddflareextension/impl/go.sum @@ -59,8 +59,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Code-Hex/go-generics-cache v1.5.1 h1:6vhZGc5M7Y/YD8cIUcY8kcuQLB4cHR7U+0KMqAA0KcU= github.com/Code-Hex/go-generics-cache v1.5.1/go.mod h1:qxcC9kRVrct9rHeiYpFWSoW1vxyillCVzX13KZG8dl4= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/datadog-agent/comp/core/log v0.56.2 h1:qvBT+FfjKGqimyEvmsNHCZKbTfBJAdUZSVy2IZQ8HS4= github.com/DataDog/datadog-agent/comp/core/log v0.56.2/go.mod h1:ivJ/RMZjTNkoPPNDX+v/nnBwABLCiMv1vQA5tk/HCR4= github.com/DataDog/datadog-api-client-go/v2 v2.33.0 h1:OI6kDnJeQmkjfGzxmP0XUQUxMD4tp6oAPXnnJ4VpgUM= diff --git a/comp/otelcol/logsagentpipeline/go.mod b/comp/otelcol/logsagentpipeline/go.mod index 53814bc1fe4d78..a79f4e5035b712 100644 --- a/comp/otelcol/logsagentpipeline/go.mod +++ b/comp/otelcol/logsagentpipeline/go.mod @@ -63,7 +63,7 @@ replace ( require github.com/DataDog/datadog-agent/pkg/logs/pipeline v0.56.0-rc.3 require ( - github.com/DataDog/agent-payload/v5 v5.0.138 // indirect + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee // indirect github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect diff --git a/comp/otelcol/logsagentpipeline/go.sum b/comp/otelcol/logsagentpipeline/go.sum index c49694b4b2b0c2..d53c50f55c90bb 100644 --- a/comp/otelcol/logsagentpipeline/go.sum +++ b/comp/otelcol/logsagentpipeline/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 h1:RoH7VLzTnxHEugRPIgnGlxwDFszFGI7b3WZZUtWuPRM= github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42/go.mod h1:TX7CTOQ3LbQjfAi4SwqUoR5gY1zfUk7VRBDTuArjaDc= github.com/DataDog/viper v1.14.0 h1:dIjTe/uJiah+QFqFZ+MXeqgmUvWhg37l37ZxFWxr3is= diff --git a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod index cf11616c244d43..b74bc5f69772be 100644 --- a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod +++ b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod @@ -89,7 +89,7 @@ require ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 // indirect + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee // indirect github.com/DataDog/datadog-agent/comp/core/flare/builder v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect diff --git a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.sum b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.sum index c49694b4b2b0c2..d53c50f55c90bb 100644 --- a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.sum +++ b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 h1:RoH7VLzTnxHEugRPIgnGlxwDFszFGI7b3WZZUtWuPRM= github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42/go.mod h1:TX7CTOQ3LbQjfAi4SwqUoR5gY1zfUk7VRBDTuArjaDc= github.com/DataDog/viper v1.14.0 h1:dIjTe/uJiah+QFqFZ+MXeqgmUvWhg37l37ZxFWxr3is= diff --git a/comp/otelcol/otlp/components/exporter/datadogexporter/go.mod b/comp/otelcol/otlp/components/exporter/datadogexporter/go.mod index 64b151661f2ba2..ee62349aa5fcc3 100644 --- a/comp/otelcol/otlp/components/exporter/datadogexporter/go.mod +++ b/comp/otelcol/otlp/components/exporter/datadogexporter/go.mod @@ -131,7 +131,7 @@ require ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 // indirect + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee // indirect github.com/DataDog/datadog-agent/comp/core/config v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/builder v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.57.1 // indirect diff --git a/comp/otelcol/otlp/components/exporter/datadogexporter/go.sum b/comp/otelcol/otlp/components/exporter/datadogexporter/go.sum index b9ba20ea9106e5..0b1e9af1cc3d7e 100644 --- a/comp/otelcol/otlp/components/exporter/datadogexporter/go.sum +++ b/comp/otelcol/otlp/components/exporter/datadogexporter/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/datadog-api-client-go/v2 v2.33.0 h1:OI6kDnJeQmkjfGzxmP0XUQUxMD4tp6oAPXnnJ4VpgUM= github.com/DataDog/datadog-api-client-go/v2 v2.33.0/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U= github.com/DataDog/datadog-go/v5 v5.6.0 h1:2oCLxjF/4htd55piM75baflj/KoE6VYS7alEUqFvRDw= diff --git a/comp/otelcol/otlp/components/exporter/serializerexporter/go.mod b/comp/otelcol/otlp/components/exporter/serializerexporter/go.mod index 6c43de30392936..82541f7404004c 100644 --- a/comp/otelcol/otlp/components/exporter/serializerexporter/go.mod +++ b/comp/otelcol/otlp/components/exporter/serializerexporter/go.mod @@ -90,7 +90,7 @@ require ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 // indirect + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee // indirect github.com/DataDog/datadog-agent/comp/core/config v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/builder v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.57.1 // indirect diff --git a/comp/otelcol/otlp/components/exporter/serializerexporter/go.sum b/comp/otelcol/otlp/components/exporter/serializerexporter/go.sum index 60d9ae93227345..150b6c714a5b09 100644 --- a/comp/otelcol/otlp/components/exporter/serializerexporter/go.sum +++ b/comp/otelcol/otlp/components/exporter/serializerexporter/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49 h1:EbzDX8HPk5uE2FsJYxD74QmMw0/3CqSKhEr6teh0ncQ= github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49/go.mod h1:SvsjzyJlSg0rKsqYgdcFxeEVflx3ZNAyFfkUHP0TxXg= github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.22.0 h1:cXcKVEU1D0HlguR7GunnvuI70TghkarCa9DApqzMY94= diff --git a/go.sum b/go.sum index 00da79b909fe23..98381279ff2125 100644 --- a/go.sum +++ b/go.sum @@ -149,8 +149,6 @@ github.com/CycloneDX/cyclonedx-go v0.9.1 h1:yffaWOZsv77oTJa/SdVZYdgAgFioCeycBUKk github.com/CycloneDX/cyclonedx-go v0.9.1/go.mod h1:NE/EWvzELOFlG6+ljX/QeMlVt9VKcTwu8u0ccsACEsw= github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/appsec-internal-go v1.9.0 h1:cGOneFsg0JTRzWl5U2+og5dbtyW3N8XaYwc5nXe39Vw= diff --git a/pkg/collector/corechecks/cluster/orchestrator/transformers/k8s/pod.go b/pkg/collector/corechecks/cluster/orchestrator/transformers/k8s/pod.go index d7713226d44978..013a110b28c524 100644 --- a/pkg/collector/corechecks/cluster/orchestrator/transformers/k8s/pod.go +++ b/pkg/collector/corechecks/cluster/orchestrator/transformers/k8s/pod.go @@ -74,9 +74,72 @@ func ExtractPod(p *corev1.Pod) *model.Pod { } } + if p.Spec.Affinity != nil && p.Spec.Affinity.NodeAffinity != nil { + podModel.NodeAffinity = &model.NodeAffinity{ + RequiredDuringSchedulingIgnoredDuringExecution: convertNodeSelector(p.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution), + PreferredDuringSchedulingIgnoredDuringExecution: convertPreferredSchedulingTerm(p.Spec.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution), + } + } + return &podModel } +func convertNodeSelector(ns *corev1.NodeSelector) *model.NodeSelector { + if ns == nil { + return nil + } + return &model.NodeSelector{ + NodeSelectorTerms: convertNodeSelectorTerms(ns.NodeSelectorTerms), + } +} + +func convertPreferredSchedulingTerm(terms []corev1.PreferredSchedulingTerm) []*model.PreferredSchedulingTerm { + if len(terms) == 0 { + return nil + } + var preferredTerms []*model.PreferredSchedulingTerm + for _, term := range terms { + preferredTerms = append(preferredTerms, &model.PreferredSchedulingTerm{ + Preference: convertNodeSelectorTerm(term.Preference), + Weight: term.Weight, + }) + } + return preferredTerms +} + +func convertNodeSelectorTerms(terms []corev1.NodeSelectorTerm) []*model.NodeSelectorTerm { + if len(terms) == 0 { + return nil + } + var nodeSelectorTerms []*model.NodeSelectorTerm + for _, term := range terms { + nodeSelectorTerms = append(nodeSelectorTerms, convertNodeSelectorTerm(term)) + } + return nodeSelectorTerms +} + +func convertNodeSelectorTerm(term corev1.NodeSelectorTerm) *model.NodeSelectorTerm { + return &model.NodeSelectorTerm{ + MatchExpressions: convertNodeSelectorRequirements(term.MatchExpressions), + MatchFields: convertNodeSelectorRequirements(term.MatchFields), + } +} + +func convertNodeSelectorRequirements(requirements []corev1.NodeSelectorRequirement) []*model.LabelSelectorRequirement { + if len(requirements) == 0 { + return nil + } + var nodeSelectorRequirements []*model.LabelSelectorRequirement + for _, req := range requirements { + nodeSelectorRequirements = append(nodeSelectorRequirements, &model.LabelSelectorRequirement{ + Key: req.Key, + Operator: string(req.Operator), + Values: req.Values, + }) + } + return nodeSelectorRequirements +} + // ExtractPodTemplateResourceRequirements extracts resource requirements of containers and initContainers into model.ResourceRequirements func ExtractPodTemplateResourceRequirements(template corev1.PodTemplateSpec) []*model.ResourceRequirements { return extractPodResourceRequirements(template.Spec.Containers, template.Spec.InitContainers) diff --git a/pkg/collector/corechecks/cluster/orchestrator/transformers/k8s/pod_test.go b/pkg/collector/corechecks/cluster/orchestrator/transformers/k8s/pod_test.go index 29ffbf77af410c..f5d48219b3a8c9 100644 --- a/pkg/collector/corechecks/cluster/orchestrator/transformers/k8s/pod_test.go +++ b/pkg/collector/corechecks/cluster/orchestrator/transformers/k8s/pod_test.go @@ -9,6 +9,7 @@ package k8s import ( "fmt" + "reflect" "testing" "time" @@ -966,3 +967,238 @@ func TestMapToTags(t *testing.T) { assert.ElementsMatch(t, []string{"foo:bar", "node-role.kubernetes.io/nodeless"}, tags) assert.Len(t, tags, 2) } + +func TestConvertNodeSelector(t *testing.T) { + tests := []struct { + name string + input *v1.NodeSelector + want *model.NodeSelector + }{ + { + name: "nil input", + input: nil, + want: nil, + }, + { + name: "empty NodeSelector", + input: &v1.NodeSelector{ + NodeSelectorTerms: []v1.NodeSelectorTerm{}, + }, + want: &model.NodeSelector{NodeSelectorTerms: nil}, + }, + { + name: "with MatchExpressions and MatchFields", + input: &v1.NodeSelector{ + NodeSelectorTerms: []v1.NodeSelectorTerm{ + { + MatchExpressions: []v1.NodeSelectorRequirement{ + {Key: "key1", Operator: v1.NodeSelectorOpIn, Values: []string{"v1", "v2"}}, + }, + MatchFields: []v1.NodeSelectorRequirement{ + {Key: "field1", Operator: v1.NodeSelectorOpNotIn, Values: []string{"v3"}}, + }, + }, + }, + }, + want: &model.NodeSelector{ + NodeSelectorTerms: []*model.NodeSelectorTerm{ + { + MatchExpressions: []*model.LabelSelectorRequirement{ + {Key: "key1", Operator: "In", Values: []string{"v1", "v2"}}, + }, + MatchFields: []*model.LabelSelectorRequirement{ + {Key: "field1", Operator: "NotIn", Values: []string{"v3"}}, + }, + }, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := convertNodeSelector(tt.input) + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("convertNodeSelector() = %#v, want %#v", got, tt.want) + } + }) + } +} + +func TestConvertPreferredSchedulingTerm(t *testing.T) { + tests := []struct { + name string + input []v1.PreferredSchedulingTerm + want []*model.PreferredSchedulingTerm + }{ + { + name: "empty terms", + input: []v1.PreferredSchedulingTerm{}, + want: nil, + }, + { + name: "single preferred scheduling term", + input: []v1.PreferredSchedulingTerm{ + { + Preference: v1.NodeSelectorTerm{ + MatchExpressions: []v1.NodeSelectorRequirement{ + {Key: "k", Operator: v1.NodeSelectorOpExists}, + }, + }, + Weight: 10, + }, + }, + want: []*model.PreferredSchedulingTerm{ + { + Preference: &model.NodeSelectorTerm{ + MatchExpressions: []*model.LabelSelectorRequirement{ + {Key: "k", Operator: "Exists", Values: nil}, + }, + MatchFields: nil, + }, + Weight: 10, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := convertPreferredSchedulingTerm(tt.input) + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("convertPreferredSchedulingTerm() = %#v, want %#v", got, tt.want) + } + }) + } +} + +func TestConvertNodeSelectorTerms(t *testing.T) { + tests := []struct { + name string + input []v1.NodeSelectorTerm + want []*model.NodeSelectorTerm + }{ + { + name: "empty terms", + input: []v1.NodeSelectorTerm{}, + want: nil, + }, + { + name: "multiple NodeSelectorTerms", + input: []v1.NodeSelectorTerm{ + { + MatchExpressions: []v1.NodeSelectorRequirement{ + {Key: "k1", Operator: v1.NodeSelectorOpIn, Values: []string{"v1"}}, + }, + }, + { + MatchExpressions: []v1.NodeSelectorRequirement{ + {Key: "k2", Operator: v1.NodeSelectorOpNotIn, Values: []string{"v2"}}, + }, + }, + }, + want: []*model.NodeSelectorTerm{ + { + MatchExpressions: []*model.LabelSelectorRequirement{ + {Key: "k1", Operator: "In", Values: []string{"v1"}}, + }, + MatchFields: nil, + }, + { + MatchExpressions: []*model.LabelSelectorRequirement{ + {Key: "k2", Operator: "NotIn", Values: []string{"v2"}}, + }, + MatchFields: nil, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := convertNodeSelectorTerms(tt.input) + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("convertNodeSelectorTerms() = %#v, want %#v", got, tt.want) + } + }) + } +} + +func TestConvertNodeSelectorTerm(t *testing.T) { + tests := []struct { + name string + input v1.NodeSelectorTerm + want *model.NodeSelectorTerm + }{ + { + name: "empty term", + input: v1.NodeSelectorTerm{}, + want: &model.NodeSelectorTerm{ + MatchExpressions: nil, + MatchFields: nil, + }, + }, + { + name: "with match expressions and fields", + input: v1.NodeSelectorTerm{ + MatchExpressions: []v1.NodeSelectorRequirement{ + {Key: "k1", Operator: v1.NodeSelectorOpExists}, + }, + MatchFields: []v1.NodeSelectorRequirement{ + {Key: "f1", Operator: v1.NodeSelectorOpDoesNotExist}, + }, + }, + want: &model.NodeSelectorTerm{ + MatchExpressions: []*model.LabelSelectorRequirement{ + {Key: "k1", Operator: "Exists"}, + }, + MatchFields: []*model.LabelSelectorRequirement{ + {Key: "f1", Operator: "DoesNotExist"}, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := convertNodeSelectorTerm(tt.input) + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("convertNodeSelectorTerm() = %#v, want %#v", got, tt.want) + } + }) + } +} + +func TestConvertNodeSelectorRequirements(t *testing.T) { + tests := []struct { + name string + input []v1.NodeSelectorRequirement + want []*model.LabelSelectorRequirement + }{ + { + name: "no requirements", + input: []v1.NodeSelectorRequirement{}, + want: nil, + }, + { + name: "with multiple requirements", + input: []v1.NodeSelectorRequirement{ + {Key: "k1", Operator: v1.NodeSelectorOpIn, Values: []string{"v1", "v2"}}, + {Key: "k2", Operator: v1.NodeSelectorOpNotIn, Values: []string{"v3"}}, + }, + want: []*model.LabelSelectorRequirement{ + {Key: "k1", Operator: "In", Values: []string{"v1", "v2"}}, + {Key: "k2", Operator: "NotIn", Values: []string{"v3"}}, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := convertNodeSelectorRequirements(tt.input) + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("convertNodeSelectorRequirements() = %#v, want %#v", got, tt.want) + } + }) + } +} diff --git a/pkg/logs/pipeline/go.mod b/pkg/logs/pipeline/go.mod index 648683ddc4ee4f..db0e0d09f17bda 100644 --- a/pkg/logs/pipeline/go.mod +++ b/pkg/logs/pipeline/go.mod @@ -79,7 +79,7 @@ require ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 // indirect + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee // indirect github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect diff --git a/pkg/logs/pipeline/go.sum b/pkg/logs/pipeline/go.sum index c49694b4b2b0c2..d53c50f55c90bb 100644 --- a/pkg/logs/pipeline/go.sum +++ b/pkg/logs/pipeline/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 h1:RoH7VLzTnxHEugRPIgnGlxwDFszFGI7b3WZZUtWuPRM= github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42/go.mod h1:TX7CTOQ3LbQjfAi4SwqUoR5gY1zfUk7VRBDTuArjaDc= github.com/DataDog/viper v1.14.0 h1:dIjTe/uJiah+QFqFZ+MXeqgmUvWhg37l37ZxFWxr3is= diff --git a/pkg/logs/processor/go.mod b/pkg/logs/processor/go.mod index 7ed5454c761a52..e030d0dcdb5c2f 100644 --- a/pkg/logs/processor/go.mod +++ b/pkg/logs/processor/go.mod @@ -48,7 +48,7 @@ replace ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 diff --git a/pkg/logs/processor/go.sum b/pkg/logs/processor/go.sum index 0ce56a71d02730..23b2714708352f 100644 --- a/pkg/logs/processor/go.sum +++ b/pkg/logs/processor/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 h1:RoH7VLzTnxHEugRPIgnGlxwDFszFGI7b3WZZUtWuPRM= github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42/go.mod h1:TX7CTOQ3LbQjfAi4SwqUoR5gY1zfUk7VRBDTuArjaDc= github.com/DataDog/viper v1.14.0 h1:dIjTe/uJiah+QFqFZ+MXeqgmUvWhg37l37ZxFWxr3is= diff --git a/pkg/process/util/api/go.mod b/pkg/process/util/api/go.mod index f76e70cb9ee0f6..4928ab68ab9b48 100644 --- a/pkg/process/util/api/go.mod +++ b/pkg/process/util/api/go.mod @@ -11,7 +11,7 @@ replace ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 github.com/gogo/protobuf v1.3.2 github.com/stretchr/testify v1.10.0 diff --git a/pkg/process/util/api/go.sum b/pkg/process/util/api/go.sum index 7343a1cf6d04ec..9fb72d80eab00b 100644 --- a/pkg/process/util/api/go.sum +++ b/pkg/process/util/api/go.sum @@ -1,5 +1,5 @@ -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49 h1:EbzDX8HPk5uE2FsJYxD74QmMw0/3CqSKhEr6teh0ncQ= github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49/go.mod h1:SvsjzyJlSg0rKsqYgdcFxeEVflx3ZNAyFfkUHP0TxXg= github.com/DataDog/zstd v1.5.6 h1:LbEglqepa/ipmmQJUDnSsfvA8e8IStVcGaFWDuxvGOY= diff --git a/pkg/serializer/go.mod b/pkg/serializer/go.mod index b4e6926e84ff34..daf0588ab82313 100644 --- a/pkg/serializer/go.mod +++ b/pkg/serializer/go.mod @@ -63,7 +63,7 @@ replace ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee github.com/DataDog/datadog-agent/comp/core/config v0.57.1 github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorinterface v0.56.0-rc.3 diff --git a/pkg/serializer/go.sum b/pkg/serializer/go.sum index 83ba9e3da98d3d..92cbcda6a025cd 100644 --- a/pkg/serializer/go.sum +++ b/pkg/serializer/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49 h1:EbzDX8HPk5uE2FsJYxD74QmMw0/3CqSKhEr6teh0ncQ= github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49/go.mod h1:SvsjzyJlSg0rKsqYgdcFxeEVflx3ZNAyFfkUHP0TxXg= github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.22.0 h1:cXcKVEU1D0HlguR7GunnvuI70TghkarCa9DApqzMY94= diff --git a/test/fakeintake/go.mod b/test/fakeintake/go.mod index eeb575694baa4d..9dd60b8e7b7e6d 100644 --- a/test/fakeintake/go.mod +++ b/test/fakeintake/go.mod @@ -9,7 +9,7 @@ replace ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee github.com/DataDog/datadog-agent/comp/netflow/payload v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/proto v0.56.0-rc.3 github.com/DataDog/zstd v1.5.6 diff --git a/test/fakeintake/go.sum b/test/fakeintake/go.sum index c9e0f74e8772b1..cca01235d9eb91 100644 --- a/test/fakeintake/go.sum +++ b/test/fakeintake/go.sum @@ -1,5 +1,5 @@ -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49 h1:EbzDX8HPk5uE2FsJYxD74QmMw0/3CqSKhEr6teh0ncQ= github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49/go.mod h1:SvsjzyJlSg0rKsqYgdcFxeEVflx3ZNAyFfkUHP0TxXg= github.com/DataDog/zstd v1.5.6 h1:LbEglqepa/ipmmQJUDnSsfvA8e8IStVcGaFWDuxvGOY= diff --git a/test/new-e2e/go.mod b/test/new-e2e/go.mod index a23fccb9754f05..dcc366b9d5647b 100644 --- a/test/new-e2e/go.mod +++ b/test/new-e2e/go.mod @@ -43,7 +43,7 @@ replace ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee github.com/DataDog/datadog-agent/comp/otelcol/ddflareextension/def v0.56.2 github.com/DataDog/datadog-agent/pkg/util/optional v0.59.1 github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 diff --git a/test/new-e2e/go.sum b/test/new-e2e/go.sum index 7884b1456c213d..34fe9759466586 100644 --- a/test/new-e2e/go.sum +++ b/test/new-e2e/go.sum @@ -7,8 +7,8 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg6 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/datadog-api-client-go v1.16.0 h1:5jOZv1m98criCvYTa3qpW8Hzv301nbZX3K9yJtwGyWY= github.com/DataDog/datadog-api-client-go v1.16.0/go.mod h1:PgrP2ABuJWL3Auw2iEkemAJ/r72ghG4DQQmb5sgnKW4= github.com/DataDog/datadog-api-client-go/v2 v2.33.0 h1:OI6kDnJeQmkjfGzxmP0XUQUxMD4tp6oAPXnnJ4VpgUM= diff --git a/test/otel/go.mod b/test/otel/go.mod index c2f9bb806a7d05..ed553aae4a9a4e 100644 --- a/test/otel/go.mod +++ b/test/otel/go.mod @@ -126,7 +126,7 @@ require ( ) require ( - github.com/DataDog/agent-payload/v5 v5.0.138 // indirect + github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee // indirect github.com/DataDog/datadog-agent/comp/core/flare/builder v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect diff --git a/test/otel/go.sum b/test/otel/go.sum index 57882146bd2db0..dccd4f1e6c63df 100644 --- a/test/otel/go.sum +++ b/test/otel/go.sum @@ -1,7 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/agent-payload/v5 v5.0.138 h1:Wg7hmWuoLC/o0X3zZ+uGcfRHPyaytljudgSY9O59zjc= -github.com/DataDog/agent-payload/v5 v5.0.138/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee h1:Ci761ya0XdCdt6MWNzFSBDykVcBgOTwoqPYNjtUC9Yg= +github.com/DataDog/agent-payload/v5 v5.0.139-0.20241227121136-afacfe086aee/go.mod h1:lxh9lb5xYrBXjblpIWYUi4deJqVbkIfkjwesi5nskDc= github.com/DataDog/datadog-api-client-go/v2 v2.33.0 h1:OI6kDnJeQmkjfGzxmP0XUQUxMD4tp6oAPXnnJ4VpgUM= github.com/DataDog/datadog-api-client-go/v2 v2.33.0/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U= github.com/DataDog/datadog-go/v5 v5.6.0 h1:2oCLxjF/4htd55piM75baflj/KoE6VYS7alEUqFvRDw=