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

feat(ssi): add namespace support for labels/expressions #33796

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

betterengineering
Copy link
Member

What does this PR do?

This commit adds the ability to use a namespace selector to match against namespaces defined in the targets list. For example, this config will match a pod in a namespace with tracing: yes and env: prod:

    - name: "Enabled Prod Namespaces"
        namespaceSelector:
          matchLabels:
            tracing: "yes"
          matchExpressions:
            - key: "env"
              operator: "In"
              values:
                - "prod"
        ddTraceVersions:
          python: "default" 

This PR maintains the ability to use matchNames as a convenience method. For example, this config would match the billing-service namespace:

      - name: "Billing Service"
        namespaceSelector:
          matchNames:
          - "billing-service"
        ddTraceVersions:
          python: "default"       

Motivation

This change is adding the full support for namespaces defined in Kubernetes SSI | Workload Selection 🎯. It was not added to the change in feat(ssi): add target based filtering as it required a bit more effort to get correct.

Describe how you validated your changes

This change is validated with the addition of unit tests at the moment. We will be adding more tests for this feature before launch.

Possible Drawbacks / Trade-offs

Additional Notes

One thing to note, this config/filter is not yet active or exposed. It's simply modifying a struct with unit tests that's not wired in anywhere. We're working hard to get this feature ready for the next agent release milestone and will include release notes, additional testing, etc before that happens.

This commit adds the ability to use a namespace selector to match
against namespaces defined in the targets list.
@betterengineering betterengineering added changelog/no-changelog qa/done QA done before merge and regressions are covered by tests labels Feb 6, 2025
@betterengineering betterengineering requested review from a team as code owners February 6, 2025 17:50
@github-actions github-actions bot added the medium review PR review might take time label Feb 6, 2025
// Get the namespace metadata. At the time of writing, this method will only return an error if the namespace
// does not exist, in which case we return false for this selector.
id := util.GenerateKubeMetadataEntityID("", "namespaces", "", namespace)
meta, _ := t.wmeta.GetKubernetesMetadata(id)
Copy link
Member Author

Choose a reason for hiding this comment

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

@davidor is this the best way to do this? How does this store work? Is it safe to assume the namespace will be there by the time we get a mutating webhook?

@agent-platform-auto-pr
Copy link
Contributor

Uncompressed package size comparison

Comparison with ancestor 3d3ac19974a60cdd73d270207fce061a35190abe

Diff per package
package diff status size ancestor threshold
datadog-agent-arm64-deb 0.00MB 861.55MB 861.54MB 0.50MB
datadog-agent-aarch64-rpm 0.00MB 871.27MB 871.27MB 0.50MB
datadog-agent-amd64-deb 0.00MB 873.67MB 873.67MB 0.50MB
datadog-agent-x86_64-rpm 0.00MB 883.41MB 883.41MB 0.50MB
datadog-agent-x86_64-suse 0.00MB 883.41MB 883.41MB 0.50MB
datadog-dogstatsd-amd64-deb 0.00MB 59.10MB 59.10MB 0.50MB
datadog-dogstatsd-x86_64-rpm 0.00MB 59.18MB 59.18MB 0.50MB
datadog-dogstatsd-x86_64-suse 0.00MB 59.18MB 59.18MB 0.50MB
datadog-dogstatsd-arm64-deb 0.00MB 56.57MB 56.57MB 0.50MB
datadog-heroku-agent-amd64-deb 0.00MB 446.05MB 446.05MB 0.50MB
datadog-iot-agent-amd64-deb 0.00MB 86.48MB 86.48MB 0.50MB
datadog-iot-agent-x86_64-rpm 0.00MB 86.55MB 86.55MB 0.50MB
datadog-iot-agent-x86_64-suse 0.00MB 86.55MB 86.55MB 0.50MB
datadog-iot-agent-arm64-deb 0.00MB 82.74MB 82.74MB 0.50MB
datadog-iot-agent-aarch64-rpm 0.00MB 82.81MB 82.81MB 0.50MB

Decision

✅ Passed

@agent-platform-auto-pr
Copy link
Contributor

[Fast Unit Tests Report]

On pipeline 55157309 (CI Visibility). The following jobs did not run any unit tests:

Jobs:
  • tests_flavor_dogstatsd_deb-x64
  • tests_flavor_heroku_deb-x64
  • tests_flavor_iot_deb-x64

If you modified Go files and expected unit tests to run in these jobs, please double check the job logs. If you think tests should have been executed reach out to #agent-devx-help

@agent-platform-auto-pr
Copy link
Contributor

Static quality checks ✅

Please find below the results from static quality gates

Info

Result Quality gate On disk size On disk size limit On wire size On wire size limit
static_quality_gate_agent_deb_amd64 844.99MiB 858.45MiB 203.61MiB 214.3MiB
static_quality_gate_docker_agent_amd64 929.33MiB 942.69MiB 310.73MiB 321.56MiB

@agent-platform-auto-pr
Copy link
Contributor

Test changes on VM

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

inv aws.create-vm --pipeline-id=55157309 --os-family=ubuntu

Note: This applies to commit 8ef8b1f

Copy link

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 9ac7b087-d58f-4961-8ad2-acc37648135b

Baseline: 3d3ac19
Comparison: 8ef8b1f
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
file_to_blackhole_1000ms_latency egress throughput +0.53 [-0.26, +1.32] 1 Logs
tcp_syslog_to_blackhole ingress throughput +0.41 [+0.33, +0.50] 1 Logs
file_to_blackhole_100ms_latency egress throughput +0.06 [-0.65, +0.77] 1 Logs
file_to_blackhole_0ms_latency_http2 egress throughput +0.05 [-0.87, +0.96] 1 Logs
file_to_blackhole_300ms_latency egress throughput -0.00 [-0.64, +0.64] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.00 [-0.30, +0.30] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput -0.01 [-0.03, +0.01] 1 Logs
file_to_blackhole_0ms_latency_http1 egress throughput -0.01 [-0.96, +0.93] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.03 [-0.90, +0.83] 1 Logs
file_to_blackhole_1000ms_latency_linear_load egress throughput -0.04 [-0.50, +0.42] 1 Logs
file_to_blackhole_500ms_latency egress throughput -0.19 [-0.98, +0.60] 1 Logs
quality_gate_idle_all_features memory utilization -0.25 [-0.31, -0.18] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization -0.51 [-0.55, -0.48] 1 Logs bounds checks dashboard
file_tree memory utilization -0.63 [-0.70, -0.57] 1 Logs
quality_gate_logs % cpu utilization -1.00 [-4.01, +2.02] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization -1.63 [-2.49, -0.78] 1 Logs

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
file_to_blackhole_0ms_latency lost_bytes 10/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_0ms_latency_http1 lost_bytes 10/10
file_to_blackhole_0ms_latency_http1 memory_usage 10/10
file_to_blackhole_0ms_latency_http2 lost_bytes 10/10
file_to_blackhole_0ms_latency_http2 memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency_linear_load memory_usage 10/10
file_to_blackhole_100ms_latency lost_bytes 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_300ms_latency lost_bytes 10/10
file_to_blackhole_300ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency lost_bytes 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle intake_connections 10/10 bounds checks dashboard
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 bounds checks dashboard
quality_gate_logs intake_connections 10/10
quality_gate_logs lost_bytes 10/10
quality_gate_logs memory_usage 10/10

Explanation

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

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".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog medium review PR review might take time qa/done QA done before merge and regressions are covered by tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant