Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discovery: report containerID for containerised services #29719

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Yumasi
Copy link
Member

@Yumasi Yumasi commented Oct 2, 2024

What does this PR do?

This PR makes the Discovery agent check add container IDs to discovered services. It relies on the workload metadata store to get the container IDs.

Motivation

USMON-1204

Describe how to test/QA your changes

Possible Drawbacks / Trade-offs

Additional Notes

@pr-commenter
Copy link

pr-commenter bot commented Oct 2, 2024

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=46275972 --os-family=ubuntu

Note: This applies to commit eab643e

@Yumasi Yumasi force-pushed the guillaume.pagnoux/USMON-1176-discovery-containers-2 branch 2 times, most recently from a733785 to 126179c Compare October 7, 2024 11:05
Copy link

cit-pr-commenter bot commented Oct 7, 2024

Go Package Import Differences

Baseline: 839b8bb
Comparison: eab643e

binaryosarchchange
system-probelinuxamd64
+15, -0
+github.com/DataDog/datadog-agent/internal/third_party/kubernetes/pkg/kubelet/cri/remote/util
+github.com/DataDog/datadog-agent/pkg/process/util/containers
+github.com/DataDog/datadog-agent/pkg/util/containers/cri
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/containerd
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/cri
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/docker
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/ecsfargate
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/kubelet
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/provider
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/system
+github.com/DataDog/datadog-agent/pkg/util/trie
+github.com/containerd/cgroups/v3/cgroup2/stats
+k8s.io/cri-api/pkg/apis/runtime/v1
+k8s.io/cri-api/pkg/apis/runtime/v1alpha2
system-probelinuxarm64
+15, -0
+github.com/DataDog/datadog-agent/internal/third_party/kubernetes/pkg/kubelet/cri/remote/util
+github.com/DataDog/datadog-agent/pkg/process/util/containers
+github.com/DataDog/datadog-agent/pkg/util/containers/cri
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/containerd
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/cri
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/docker
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/ecsfargate
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/kubelet
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/provider
+github.com/DataDog/datadog-agent/pkg/util/containers/metrics/system
+github.com/DataDog/datadog-agent/pkg/util/trie
+github.com/containerd/cgroups/v3/cgroup2/stats
+k8s.io/cri-api/pkg/apis/runtime/v1
+k8s.io/cri-api/pkg/apis/runtime/v1alpha2

Copy link

cit-pr-commenter bot commented Oct 7, 2024

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 22282116-b77b-4014-aa26-a45a2eb36ab4

Baseline: 839b8bb
Comparison: eab643e

Regression Detector: ✅

Bounds Checks: ✅

Significant changes in experiment optimization goals

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

perf experiment goal Δ mean % Δ mean % CI trials links
pycheck_lots_of_tags % cpu utilization -5.28 [-8.81, -1.74] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
basic_py_check % cpu utilization +1.57 [-2.23, +5.36] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization +0.79 [+0.06, +1.53] 1 Logs
idle_all_features memory utilization +0.24 [+0.16, +0.32] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.01, +0.01] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.01 [-0.12, +0.09] 1 Logs
tcp_syslog_to_blackhole ingress throughput -0.03 [-0.08, +0.02] 1 Logs
otel_to_otel_logs ingress throughput -0.18 [-0.99, +0.63] 1 Logs
file_tree memory utilization -0.32 [-0.44, -0.21] 1 Logs
idle memory utilization -0.55 [-0.60, -0.51] 1 Logs
pycheck_lots_of_tags % cpu utilization -5.28 [-8.81, -1.74] 1 Logs

Bounds Checks Passed

perf experiment bounds_check_name replicates_passed links
idle memory_usage 10/10

Explanation

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

@Yumasi Yumasi force-pushed the guillaume.pagnoux/USMON-1176-discovery-containers-2 branch 3 times, most recently from ce8cf0d to ee4e280 Compare October 9, 2024 08:16
@Yumasi Yumasi force-pushed the guillaume.pagnoux/USMON-1176-discovery-containers-2 branch from ee4e280 to 57ebe91 Compare October 9, 2024 08:47
@Yumasi Yumasi changed the title discovery: add containerID field to SD structs discovery: report containerID for containerised services Oct 9, 2024
@Yumasi Yumasi marked this pull request as ready for review October 9, 2024 09:26
@Yumasi Yumasi requested review from a team as code owners October 9, 2024 09:26
Copy link
Contributor

@vitkyrka vitkyrka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be possible to test this in the E2E test (can be done in a separate PR)?

// validity.
// TODO: use/find a global constant for this delay, to keep in sync with
// the check delay if it were to change.
containers := li.containerProvider.GetPidToCid(1 * time.Minute)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know what impact this has on the CPU load?
Also, can we avoid calling this if there are no new services?

@@ -100,6 +110,12 @@ func (li *linuxImpl) DiscoverServices() (*discoveredServices, error) {
li.ignoreProcs[pid] = true
continue
}

if id, ok := containers[pid]; ok {
svc.service.ContainerID = id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only needs to be done when the service goes from potential -> alive in the loop which starts at line 80 right? If this is moved there and combined with the above suggestions to only call GetPidToCid when we need it it should reduce some unnecessary work with short-lived process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a new method for handling the potential->alive case, and moved the addition of the container id in it.

- Only get container ids if there are previous potential services
- Only add container id on confirmed new services
- Add test for propagation of container id values
- Revert unrelated formatting change made by auto-formatter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants