Skip to content

Commit 630879c

Browse files
authored
Merge branch 'main' into mrafi/remove-update-install-source
2 parents 89e3b88 + e786e6c commit 630879c

155 files changed

Lines changed: 3862 additions & 892 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
/MODULE.bazel* @DataDog/agent-build
3030
# Temporary during Bazel migration
3131
/**/BUILD.bazel @DataDog/agent-build
32+
# This should really be to a team that does not exist yet. It would cover supply chain in general.
33+
# For now, agent-build are the experts in that.
34+
/third_party/ @DataDog/agent-build
3235

3336
/CHANGELOG.rst @DataDog/agent-delivery
3437
/CHANGELOG-DCA.rst @DataDog/container-integrations @DataDog/container-platform
@@ -379,6 +382,7 @@
379382
/comp/snmpscan @DataDog/ndm-core
380383
/comp/softwareinventory @DataDog/windows-products
381384
/comp/syntheticstestscheduler @DataDog/synthetics-executing
385+
/comp/workloadselection @DataDog/injection-platform
382386
# END COMPONENTS
383387

384388
# Additional notification to @iglendd about Agent Telemetry changes for optional approval and governance acknowledgement

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ devenv/packer_cache
172172
test_output.json
173173
module_test_output.json
174174
e2e_test_output.json
175+
e2e_test_output.json.*.part
176+
junit-out-AgentFlavor.base-*.xml
175177

176178
# doxygen doc & error log
177179
rtloader/doc

Dockerfiles/agent/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ RUN --mount=from=artifacts,target=/artifacts \
161161
&& rm -rf usr etc/init lib \
162162
go/ \
163163
opt/datadog-agent/embedded/bin/installer \
164+
opt/datadog-agent/embedded/bin/dd-compile-policy \
164165
opt/datadog-agent/sources \
165166
opt/datadog-agent/embedded/share/doc \
166167
opt/datadog-agent/embedded/share/man \

cmd/agent/subcommands/run/command.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
agenttelemetryfx "github.com/DataDog/datadog-agent/comp/core/agenttelemetry/fx"
3535
"github.com/DataDog/datadog-agent/comp/core/autodiscovery/providers/datastreams"
3636
ssistatusfx "github.com/DataDog/datadog-agent/comp/updater/ssistatus/fx"
37+
workloadselectionfx "github.com/DataDog/datadog-agent/comp/workloadselection/fx"
3738

3839
haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx"
3940
snmpscanfx "github.com/DataDog/datadog-agent/comp/snmpscan/fx"
@@ -534,6 +535,7 @@ func getSharedFxOption() fx.Option {
534535
diagnosefx.Module(),
535536
ipcfx.ModuleReadWrite(),
536537
ssistatusfx.Module(),
538+
workloadselectionfx.Module(),
537539
workloadfilterfx.Module(),
538540
connectivitycheckerfx.Module(),
539541
configstreamfx.Module(),

comp/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,3 +806,9 @@ versions, installation dates, and other relevant details for inventory tracking.
806806

807807
Package syntheticstestscheduler defines a synthetics scheduler component to run
808808
network tests based on remote config.
809+
810+
### [comp/workloadselection](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/workloadselection)
811+
812+
*Datadog Team*: injection-platform
813+
814+
Package workloadselection listens to Remote Config to receive & apply workload selection configuration

comp/api/api/apiimpl/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020

2121
func startServer(listener net.Listener, srv *http.Server, name string) {
2222
// Use a stack depth of 4 on top of the default one to get a relevant filename in the stdlib
23-
logWriter, _ := pkglogsetup.NewLogWriter(5, log.ErrorLvl)
23+
logWriter, _ := pkglogsetup.NewTLSHandshakeErrorWriter(5, log.ErrorLvl)
2424

2525
srv.ErrorLog = stdLog.New(logWriter, fmt.Sprintf("Error from the Agent HTTP server '%s': ", name), 0) // log errors to seelog
2626

comp/core/config/setup.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ func setupConfig(config pkgconfigmodel.BuildableConfig, secretComp secrets.Compo
8888

8989
return nil
9090
}
91+
92+
// GetInstallPath returns the install path for the agent
93+
func GetInstallPath() string {
94+
return pkgconfigsetup.InstallPath
95+
}

comp/core/workloadfilter/catalog/common.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ package catalog
99
// This file contains filter programs that can be shared across different entity types.
1010

1111
import (
12+
log "github.com/DataDog/datadog-agent/comp/core/log/def"
1213
"github.com/DataDog/datadog-agent/comp/core/workloadfilter/program"
14+
"github.com/DataDog/datadog-agent/pkg/util/containers"
1315
)
1416

1517
// AutodiscoveryAnnotations creates a CEL program for autodiscovery annotations.
@@ -35,3 +37,49 @@ func AutodiscoveryLogsAnnotations() program.FilterProgram {
3537
ExcludePrefix: "logs_",
3638
}
3739
}
40+
41+
// LegacyContainerGlobalProgram creates a legacy filter program for global containerized filtering
42+
func LegacyContainerGlobalProgram(cfg *FilterConfig, logger log.Component) program.FilterProgram {
43+
return createLegacyContainerProgram("LegacyContainerGlobalProgram", cfg.ContainerInclude, cfg.ContainerExclude, logger)
44+
}
45+
46+
// LegacyContainerMetricsProgram creates a legacy filter program for containerized metrics filtering
47+
func LegacyContainerMetricsProgram(cfg *FilterConfig, logger log.Component) program.FilterProgram {
48+
return createLegacyContainerProgram("LegacyContainerMetricsProgram", cfg.ContainerIncludeMetrics, cfg.ContainerExcludeMetrics, logger)
49+
}
50+
51+
// LegacyContainerLogsProgram creates a legacy filter program for containerized logs filtering
52+
func LegacyContainerLogsProgram(cfg *FilterConfig, logger log.Component) program.FilterProgram {
53+
return createLegacyContainerProgram("LegacyContainerLogsProgram", cfg.ContainerIncludeLogs, cfg.ContainerExcludeLogs, logger)
54+
}
55+
56+
// LegacyContainerACExcludeProgram creates a legacy filter program for containerized AC exclusion filtering
57+
func LegacyContainerACExcludeProgram(cfg *FilterConfig, logger log.Component) program.FilterProgram {
58+
return createLegacyContainerProgram("LegacyContainerACExcludeProgram", nil, cfg.ACExclude, logger)
59+
}
60+
61+
// LegacyContainerACIncludeProgram creates a legacy filter program for containerized AC inclusion filtering
62+
func LegacyContainerACIncludeProgram(cfg *FilterConfig, logger log.Component) program.FilterProgram {
63+
return createLegacyContainerProgram("LegacyContainerACIncludeProgram", cfg.ACInclude, nil, logger)
64+
}
65+
66+
// LegacyContainerSBOMProgram creates a legacy filter program for containerized SBOM filtering
67+
func LegacyContainerSBOMProgram(cfg *FilterConfig, logger log.Component) program.FilterProgram {
68+
return createLegacyContainerProgram("LegacyContainerSBOMProgram", cfg.SBOMContainerInclude, cfg.SBOMContainerExclude, logger)
69+
}
70+
71+
func createLegacyContainerProgram(programName string, include, exclude []string, logger log.Component) program.FilterProgram {
72+
var initErrors []error
73+
74+
filter, err := containers.NewFilter(containers.GlobalFilter, include, exclude)
75+
if err != nil {
76+
initErrors = append(initErrors, err)
77+
logger.Warnf("Failed to create filter '%s': %v", programName, err)
78+
}
79+
80+
return program.LegacyFilterProgram{
81+
Name: programName,
82+
Filter: filter,
83+
InitializationErrors: initErrors,
84+
}
85+
}

comp/core/workloadfilter/catalog/container.go

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -7,92 +7,15 @@
77
package catalog
88

99
import (
10-
"regexp"
11-
"strings"
12-
1310
log "github.com/DataDog/datadog-agent/comp/core/log/def"
1411
workloadfilter "github.com/DataDog/datadog-agent/comp/core/workloadfilter/def"
1512
"github.com/DataDog/datadog-agent/comp/core/workloadfilter/program"
1613
"github.com/DataDog/datadog-agent/pkg/util/containers"
1714
)
1815

19-
// LegacyContainerMetricsProgram creates a program for filtering container metrics
20-
func LegacyContainerMetricsProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
21-
programName := "LegacyContainerMetricsProgram"
22-
include := filterConfig.ContainerIncludeMetrics
23-
exclude := filterConfig.ContainerExcludeMetrics
24-
return createFromOldFilters(programName, include, exclude, workloadfilter.ContainerType, logger)
25-
}
26-
27-
// LegacyContainerLogsProgram creates a program for filtering container logs
28-
func LegacyContainerLogsProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
29-
programName := "LegacyContainerLogsProgram"
30-
include := filterConfig.ContainerIncludeLogs
31-
exclude := filterConfig.ContainerExcludeLogs
32-
return createFromOldFilters(programName, include, exclude, workloadfilter.ContainerType, logger)
33-
}
34-
35-
// LegacyContainerACExcludeProgram creates a program for excluding containers via legacy `AC` filters
36-
func LegacyContainerACExcludeProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
37-
programName := "LegacyContainerACExcludeProgram"
38-
exclude := filterConfig.ACExclude
39-
return createFromOldFilters(programName, nil, exclude, workloadfilter.ContainerType, logger)
40-
}
41-
42-
// LegacyContainerACIncludeProgram creates a program for including containers via legacy `AC` filters
43-
func LegacyContainerACIncludeProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
44-
programName := "LegacyContainerACIncludeProgram"
45-
include := filterConfig.ACInclude
46-
return createFromOldFilters(programName, include, nil, workloadfilter.ContainerType, logger)
47-
}
48-
49-
// LegacyContainerGlobalProgram creates a program for filtering container globally
50-
func LegacyContainerGlobalProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
51-
programName := "LegacyContainerGlobalProgram"
52-
include := filterConfig.ContainerInclude
53-
exclude := filterConfig.ContainerExclude
54-
return createFromOldFilters(programName, include, exclude, workloadfilter.ContainerType, logger)
55-
}
56-
57-
// LegacyContainerSBOMProgram creates a program for filtering container SBOMs
58-
func LegacyContainerSBOMProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
59-
programName := "LegacyContainerSBOMProgram"
60-
include := filterConfig.SBOMContainerInclude
61-
exclude := filterConfig.SBOMContainerExclude
62-
return createFromOldFilters(programName, include, exclude, workloadfilter.ContainerType, logger)
63-
}
64-
6516
// ContainerPausedProgram creates a program for filtering paused containers
6617
func ContainerPausedProgram(_ *FilterConfig, logger log.Component) program.FilterProgram {
67-
programName := "ContainerPausedProgram"
68-
var initErrors []error
69-
70-
exclude := containers.GetPauseContainerExcludeList()
71-
72-
excludeRegex := make([]*regexp.Regexp, 0, len(exclude))
73-
for _, pattern := range exclude {
74-
pattern = strings.TrimPrefix(pattern, "image:")
75-
regex, err := regexp.Compile(pattern)
76-
if err != nil {
77-
initErrors = append(initErrors, err)
78-
logger.Warnf("Error compiling regex pattern for %s: %v", programName, err)
79-
continue
80-
}
81-
excludeRegex = append(excludeRegex, regex)
82-
}
83-
84-
return &program.RegexProgram{
85-
Name: programName,
86-
ExcludeRegex: excludeRegex,
87-
ExtractField: func(entity workloadfilter.Filterable) string {
88-
container, ok := entity.(*workloadfilter.Container)
89-
if !ok {
90-
return ""
91-
}
92-
return container.GetImage()
93-
},
94-
InitializationErrors: initErrors,
95-
}
18+
return createLegacyContainerProgram("ContainerPausedProgram", nil, containers.GetPauseContainerExcludeList(), logger)
9619
}
9720

9821
// ContainerCELMetricsProgram creates a program for filtering container metrics via CEL rules

comp/core/workloadfilter/catalog/kube_endpoints.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,6 @@ import (
1212
"github.com/DataDog/datadog-agent/comp/core/workloadfilter/program"
1313
)
1414

15-
// LegacyEndpointsMetricsProgram creates a program for filtering endpoints metrics
16-
func LegacyEndpointsMetricsProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
17-
programName := "LegacyEndpointsMetricsProgram"
18-
include := filterConfig.ContainerIncludeMetrics
19-
exclude := filterConfig.ContainerExcludeMetrics
20-
return createFromOldFilters(programName, include, exclude, workloadfilter.EndpointType, logger)
21-
}
22-
23-
// LegacyEndpointsGlobalProgram creates a program for filtering endpoints globally
24-
func LegacyEndpointsGlobalProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
25-
programName := "LegacyEndpointsGlobalProgram"
26-
includeList := filterConfig.GetLegacyContainerInclude()
27-
excludeList := filterConfig.GetLegacyContainerExclude()
28-
return createFromOldFilters(programName, includeList, excludeList, workloadfilter.EndpointType, logger)
29-
}
30-
3115
// EndpointCELMetricsProgram creates a program for filtering endpoints metrics via CEL rules
3216
func EndpointCELMetricsProgram(filterConfig *FilterConfig, logger log.Component) program.FilterProgram {
3317
programName := "EndpointCELMetricsProgram"

0 commit comments

Comments
 (0)