Skip to content

Commit

Permalink
Merge branch 'main' into adelhajhassan/exclude_syncing_pods_in_clc_ta…
Browse files Browse the repository at this point in the history
…gger
  • Loading branch information
adel121 authored Oct 9, 2024
2 parents 4e4a50a + 81e640e commit c0cea6a
Show file tree
Hide file tree
Showing 64 changed files with 2,067 additions and 587 deletions.
43 changes: 42 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,48 @@
# Files containing job contents are owned by teams in charge of the jobs + agent-devx-infra or agent-delivery
# Files that only describe structure (eg. includes, rules) are owned by agent-devx-infra

/.gitlab/ @DataDog/agent-devx-infra
/.gitlab/.ci-linters.yml @DataDog/agent-devx-infra
/.gitlab/.pre/* @DataDog/agent-devx-infra
/.gitlab/check_deploy/* @DataDog/agent-delivery
/.gitlab/check_merge/* @DataDog/agent-devx-infra
/.gitlab/deploy*/* @DataDog/agent-delivery
/.gitlab/deps_fetch/* @DataDog/agent-devx-infra
/.gitlab/e2e/* @DataDog/agent-devx-infra @DataDog/agent-devx-loops
/.gitlab/e2e_install_packages/* @DataDog/agent-delivery
/.gitlab/e2e_pre_test/* @DataDog/agent-devx-infra @DataDog/agent-devx-loops
/.gitlab/junit_upload/* @DataDog/agent-devx-infra
/.gitlab/kernel_matrix_testing/* @DataDog/agent-devx-infra @DataDog/ebpf-platform
/.gitlab/lint/* @DataDog/agent-devx-infra
/.gitlab/maintenance_jobs/* @DataDog/agent-devx-infra @DataDog/agent-devx-loops
/.gitlab/notify/* @DataDog/agent-devx-infra
/.gitlab/pkg_metrics/* @DataDog/agent-devx-infra
/.gitlab/post_rc_build/* @DataDog/agent-devx-infra
/.gitlab/setup/* @DataDog/agent-devx-infra
/.gitlab/trigger_release/* @DataDog/agent-devx-infra

/.gitlab/binary_build/cws_instrumentation.yml @DataDog/agent-devx-infra @DataDog/agent-security
/.gitlab/binary_build/include.yml @DataDog/agent-devx-infra
/.gitlab/binary_build/linux.yml @DataDog/agent-devx-infra @DataDog/agent-delivery
/.gitlab/functional_test/include.yml @DataDog/agent-devx-infra
/.gitlab/functional_test_cleanup/functional_test_cleanup.yml @DataDog/agent-devx-infra @DataDog/agent-security
/.gitlab/install_script_testing/install_script_testing.yml @DataDog/agent-delivery
/.gitlab/integration_test/dogstatsd.yml @DataDog/agent-devx-infra @DataDog/agent-metrics-logs
/.gitlab/integration_test/include.yml @DataDog/agent-devx-infra
/.gitlab/integration_test/linux.yml @DataDog/agent-devx-infra
/.gitlab/integration_test/otel.yml @DataDog/agent-devx-infra @DataDog/opentelemetry
/.gitlab/internal_image_deploy/internal_image_deploy.yml @DataDog/agent-delivery
/.gitlab/internal_kubernetes_deploy/include.yml @DataDog/agent-devx-infra
/.gitlab/internal_kubernetes_deploy/internal_kubernetes_deploy.yml @DataDog/agent-delivery
/.gitlab/internal_kubernetes_deploy/rc_kubernetes_deploy.yml @DataDog/agent-delivery
/.gitlab/package_deps_build/package_deps_build.yml @DataDog/agent-devx-infra @DataDog/ebpf-platform
/.gitlab/powershell_script_signing/powershell_script_signing.yml @DataDog/agent-delivery @DataDog/windows-agent
/.gitlab/source_test/golang_deps_diff.yml @DataDog/agent-devx-infra @DataDog/agent-devx-loops
/.gitlab/source_test/include.yml @DataDog/agent-devx-infra
/.gitlab/source_test/linux.yml @DataDog/agent-devx-infra @DataDog/agent-devx-loops
/.gitlab/source_test/macos.yml @DataDog/agent-devx-infra @DataDog/agent-devx-loops
/.gitlab/source_test/notify.yml @DataDog/agent-devx-infra @DataDog/agent-devx-loops
/.gitlab/source_test/slack.yml @DataDog/agent-devx-infra @DataDog/agent-devx-loops
/.gitlab/source_test/tooling_unit_tests.yml @DataDog/agent-devx-infra @DataDog/agent-devx-loops

/.gitlab/binary_build/cluster_agent_cloudfoundry.yml @DataDog/platform-integrations @DataDog/agent-delivery
/.gitlab/binary_build/cluster_agent.yml @DataDog/container-integrations @DataDog/agent-delivery
Expand Down
17 changes: 11 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1157,12 +1157,17 @@ workflow:
COVERAGE_CACHE_FLAG: "--pull-coverage-cache"

.on_gitlab_changes:
- !reference [.except_mergequeue]
- changes:
paths:
- .gitlab-ci.yml
- .gitlab/**/*
compare_to: main # TODO: use a variable, when this is supported https://gitlab.com/gitlab-org/gitlab/-/issues/369916
changes:
paths:
- .gitlab-ci.yml
- .gitlab/**/*
- .gitlab/**/.*
compare_to: main # TODO: use a variable, when this is supported https://gitlab.com/gitlab-org/gitlab/-/issues/369916

.on_gitlab_changes_or_mergequeue_or_main:
- !reference [.on_gitlab_changes]
- !reference [.on_mergequeue]
- !reference [.on_main]

.on_invoke_tasks_changes:
- <<: *if_main_branch
Expand Down
20 changes: 14 additions & 6 deletions .gitlab/.pre/gitlab_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ test_gitlab_configuration:
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
tags: ["arch:amd64"]
rules:
- !reference [.except_mergequeue]
- !reference [.on_gitlab_changes]
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_FULL_API_TOKEN) || exit $?; export GITLAB_TOKEN
Expand All @@ -16,6 +17,7 @@ test_gitlab_compare_to:
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
tags: ["arch:amd64"]
rules:
- !reference [.except_mergequeue]
- !reference [.on_gitlab_changes]
script:
- GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_FULL_API_TOKEN) || exit $?; export GITLAB_TOKEN
Expand Down Expand Up @@ -58,11 +60,17 @@ lint_gitlab_ci:
needs: [compute_gitlab_ci_config]
rules:
- !reference [.compute_gitlab_ci_config_rules]
- !reference [.on_gitlab_changes_or_mergequeue_or_main]
script:
- inv -e linter.gitlab-ci-jobs-needs-rules --config-file artifacts/after.gitlab-ci.yml
- inv -e linter.gitlab-ci-jobs-owners --config-file artifacts/after.gitlab-ci.yml

lint_gitlab_ci_jobs_codeowners:
stage: .pre
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_arm64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
tags: ["arch:arm64"]
needs: []
rules:
- !reference [.on_gitlab_changes]
- changes:
paths:
- .gitlab/.ci-linters.yml
compare_to: main # TODO: use a variable, when this is supported https://gitlab.com/gitlab-org/gitlab/-/issues/369916
script:
- inv -e linter.gitlab-ci-jobs-needs-rules --diff-file artifacts/diff.gitlab-ci.yml
- inv -e linter.gitlab-ci-jobs-owners --diff-file artifacts/diff.gitlab-ci.yml
- inv -e linter.gitlab-ci-jobs-codeowners
1 change: 1 addition & 0 deletions .gitlab/JOBOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ skip-ci-check @DataDog/agent-devx-infra
slack_teams_channels_check @DataDog/agent-devx-infra
lint* @DataDog/agent-devx-infra
notify* @DataDog/agent-devx-infra
create_release_qa_cards @DataDog/agent-devx-infra

# Deps build
build_clang_* @DataDog/ebpf-platform
Expand Down
8 changes: 5 additions & 3 deletions .gitlab/deps_fetch/deps_fetch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
POLICY: pull
retry: 2

# HACK: If you change the behavior of this job, change the `cache:key:prefix` value to invalidate the cache
go_deps:
extends: .cache
variables:
Expand All @@ -48,15 +49,16 @@ go_deps:
paths:
- $CI_PROJECT_DIR/modcache.tar.xz
cache:
# The `cache:key:files` only accepts up to two path ([docs](https://docs.gitlab.com/ee/ci/yaml/#cachekeyfiles)).
# The `cache:key:files` only accepts up to two paths ([docs](https://docs.gitlab.com/ee/ci/yaml/#cachekeyfiles)).
# Ideally, we should also include the https://github.com/DataDog/datadog-agent/blob/main/.custom-gcl.yml file to
# avoid issues if a plugin is added in one PR and enabled in another. However, we decided to accept this limitation
# because the probability for this to happen is very low and go mod files are modified frequently so the risk of
# failing a job because of a network issue when building the custom binary is very low, but still exists.
# We should also include the file this job is defined in to invalicate the cache when this job is modified.
- key:
files:
- \**/go.mod
- .gitlab/deps_fetch/deps_fetch.yml
- go.mod
- ./**/go.mod
prefix: "go_deps_modcache"
paths:
- modcache.tar.xz
Expand Down
7 changes: 6 additions & 1 deletion cmd/cws-instrumentation/subcommands/tracecmd/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ func Command() []*cobra.Command {

return nil
}
return ptracer.Wrap(args, os.Environ(), params.ProbeAddr, opts)
exitCode, err := ptracer.Wrap(args, os.Environ(), params.ProbeAddr, opts)
if err != nil {
return err
}
os.Exit(exitCode)
return err // fake return
},
}

Expand Down
32 changes: 16 additions & 16 deletions comp/core/flare/flare.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ func newFlare(deps dependencies) provides {
diagnoseDeps: diagnoseDeps,
}

// Adding legacy and internal providers. Registering then as Provider through FX create cycle dependencies.
//
// Do not extend this list, this is legacy behavior that should be remove at some point. To add data to a flare
// use the flare provider system: https://datadoghq.dev/datadog-agent/components/shared_features/flares/
f.providers = append(
f.providers,
func(fb types.FlareBuilder) error {
return pkgFlare.CompleteFlare(fb, f.diagnoseDeps)
},
f.collectLogsFiles,
f.collectConfigFiles,
)

return provides{
Comp: f,
Endpoint: api.NewAgentEndpointProvider(f.createAndReturnFlarePath, "/flare", "POST"),
Expand Down Expand Up @@ -175,30 +188,17 @@ func (f *flare) Create(pdata ProfileData, ipcError error) (string, error) {
fb.AddFileWithoutScrubbing(filepath.Join("profiles", name), data) //nolint:errcheck
}

// Adding legacy and internal providers. Registering then as Provider through FX create cycle dependencies.
//
// Do not extend this list, this is legacy behavior that should be remove at some point. To add data to a flare
// use the flare provider system: https://datadoghq.dev/datadog-agent/components/shared_features/flares/
providers := append(
f.providers,
func(fb types.FlareBuilder) error {
return pkgFlare.CompleteFlare(fb, f.diagnoseDeps)
},
f.collectLogsFiles,
f.collectConfigFiles,
)

f.runProviders(fb, providers)
f.runProviders(fb)

return fb.Save()
}

func (f *flare) runProviders(fb types.FlareBuilder, providers []types.FlareCallback) {
func (f *flare) runProviders(fb types.FlareBuilder) {
flareStepTimeout := f.config.GetDuration("flare_provider_timeout") * time.Second
timer := time.NewTimer(flareStepTimeout)
defer timer.Stop()

for _, p := range providers {
for _, p := range f.providers {
providerName := runtime.FuncForPC(reflect.ValueOf(p).Pointer()).Name()
f.log.Infof("Running flare provider %s", providerName)
_ = fb.Logf("Running flare provider %s", providerName)
Expand Down
49 changes: 30 additions & 19 deletions comp/core/flare/flare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ func TestFlareCreation(t *testing.T) {
),
)

assert.Len(t, f.Comp.(*flare).providers, 1)
assert.NotNil(t, f.Comp.(*flare).providers[0])
assert.GreaterOrEqual(t, len(f.Comp.(*flare).providers), 1)
assert.NotContains(t, f.Comp.(*flare).providers, nil)
}

func TestRunProviders(t *testing.T) {
var firstRan atomic.Bool
var secondRan atomic.Bool
var secondDone atomic.Bool

deps := fxutil.Test[dependencies](
t,
fx.Provide(func() log.Component { return logmock.New(t) }),
Expand All @@ -79,29 +83,36 @@ func TestRunProviders(t *testing.T) {
func() types.FlareCallback { return nil },
fx.ResultTags(`group:"flare"`),
)),
fx.Provide(fx.Annotate(
func() types.FlareCallback {
return func(_ types.FlareBuilder) error {
firstRan.Store(true)
return nil
}
},
fx.ResultTags(`group:"flare"`),
)),
fx.Provide(fx.Annotate(
func() types.FlareCallback {
return func(_ types.FlareBuilder) error {
secondRan.Store(true)
time.Sleep(10 * time.Second)
secondDone.Store(true)
return nil
}
},
fx.ResultTags(`group:"flare"`),
)),
)
deps.Config.Set("flare_provider_timeout", 1, model.SourceAgentRuntime)
f := newFlare(deps)

var firstRan atomic.Bool
var secondRan atomic.Bool
var secondDone atomic.Bool
providers := []types.FlareCallback{
func(_ types.FlareBuilder) error {
firstRan.Store(true)
return nil
},
func(_ types.FlareBuilder) error {
secondRan.Store(true)
time.Sleep(10 * time.Second)
secondRan.Store(true)
return nil
},
}

fb, err := helpers.NewFlareBuilder(false)
require.NoError(t, err)
f.Comp.(*flare).runProviders(fb, providers)

flare := f.Comp.(*flare)
flare.runProviders(fb)

require.True(t, firstRan.Load())
require.True(t, secondRan.Load())
require.False(t, secondDone.Load())
Expand Down
4 changes: 3 additions & 1 deletion comp/core/status/statusimpl/common_header_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type headerProvider struct {
name string
textTemplatesFunctions textTemplate.FuncMap
htmlTemplatesFunctions htmlTemplate.FuncMap
config config.Component
}

func (h *headerProvider) Index() int {
Expand Down Expand Up @@ -72,6 +73,7 @@ func (h *headerProvider) HTML(_ bool, buffer io.Writer) error {
func (h *headerProvider) data() map[string]interface{} {
data := maps.Clone(h.constdata)
data["time_nano"] = nowFunc().UnixNano()
data["config"] = populateConfig(h.config)
return data
}

Expand All @@ -88,13 +90,13 @@ func newCommonHeaderProvider(params status.Params, config config.Component) stat
pythonVersion := params.PythonVersionGetFunc()
data["python_version"] = strings.Split(pythonVersion, " ")[0]
data["build_arch"] = runtime.GOARCH
data["config"] = populateConfig(config)

return &headerProvider{
constdata: data,
name: fmt.Sprintf("%s (v%s)", flavor.GetHumanReadableFlavor(), data["version"]),
textTemplatesFunctions: status.TextFmap(),
htmlTemplatesFunctions: status.HTMLFmap(),
config: config,
}
}

Expand Down
29 changes: 29 additions & 0 deletions comp/core/status/statusimpl/common_header_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"go.uber.org/fx"

"github.com/DataDog/datadog-agent/comp/core/config"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/pkg/config/model"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
"github.com/DataDog/datadog-agent/pkg/version"
Expand Down Expand Up @@ -129,6 +131,33 @@ func TestCommonHeaderProviderTime(t *testing.T) {
assert.EqualValues(t, int64(2000000000), data["time_nano"])
}

func assertLogLevel(t *testing.T, provider status.HeaderProvider, expected string) {
t.Helper()

data := map[string]interface{}{}
err := provider.JSON(false, data)
require.NoError(t, err)

require.Contains(t, data, "config")
require.Contains(t, data["config"], "log_level")

cfg, ok := data["config"].(map[string]string)
require.True(t, ok)

require.EqualValues(t, expected, cfg["log_level"])
}

func TestCommonHeaderProviderConfig(t *testing.T) {
config := config.NewMock(t)
provider := newCommonHeaderProvider(agentParams, config)

config.Set("log_level", "info", model.SourceAgentRuntime)
assertLogLevel(t, provider, "info")

config.Set("log_level", "warn", model.SourceAgentRuntime)
assertLogLevel(t, provider, "warn")
}

func TestCommonHeaderProviderTextWithFipsInformation(t *testing.T) {
nowFunc = func() time.Time { return time.Unix(1515151515, 0) }
startTimeProvider = time.Unix(1515151515, 0)
Expand Down
2 changes: 1 addition & 1 deletion comp/core/status/statusimpl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ require (
github.com/DataDog/datadog-agent/comp/core/log/def v0.0.0-00010101000000-000000000000
github.com/DataDog/datadog-agent/comp/core/log/mock v0.0.0-00010101000000-000000000000
github.com/DataDog/datadog-agent/comp/core/status v0.56.0-rc.3
github.com/DataDog/datadog-agent/pkg/config/model v0.56.0-rc.3
github.com/DataDog/datadog-agent/pkg/config/setup v0.56.0-rc.3
github.com/DataDog/datadog-agent/pkg/util/flavor v0.56.0-rc.3
github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3
Expand All @@ -63,7 +64,6 @@ require (
github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.56.0-rc.3 // indirect
github.com/DataDog/datadog-agent/pkg/config/env v0.56.0-rc.3 // indirect
github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect
github.com/DataDog/datadog-agent/pkg/config/model v0.56.0-rc.3 // indirect
github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect
github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect
github.com/DataDog/datadog-agent/pkg/util/executable v0.56.0-rc.3 // indirect
Expand Down
Loading

0 comments on commit c0cea6a

Please sign in to comment.