comp/core/workloadmeta: forget the SBOMs of removed images #57709
[P2] Replace wall-clock polling with deterministic synchronization. assert.Eventually waits on a real ticker for background cleanup, making this new test timing-dependent and potentially adding ten seconds on failure. Use testing/synctest with a suitable fake, or explicitly signal cleanup completion, and assert the resulting store state once the work has finished.
AI review by Codex (OpenAI) - workflow run
The patch is incorrect: the new cleanup test introduces wall-clock polling, contrary to the repository’s testing requirements. Static review found no other actionable regressions; tests were not run.
🎯 Code Coverage (<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-agent/pull-requests/57709'>details</a>)<br>• <strong><span title="Percentage of modified executable lines covered by tests in this PR">Patch Coverage</span></strong>: 69.39%<br>• <strong><span title="Percentage of all executable lines covered by tests in the entire codebase">Overall Coverage</span></strong>: 58.90% <span title="Change in overall coverage compared to the base branch">(+0.00%)</span><br>
<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: 56a5874 | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
</sub>
Files inventory check summary
File checks results against ancestor 7f663ee2:
Results for datadog-agent_7.86.0~devel.git.525.56a5874.pipeline.145173011-1_amd64.deb:
No change detected
Results for datadog-iot-agent_7.86.0~devel.git.525.56a5874.pipeline.145173011-1_amd64.deb:
No change detected
Static quality checks
✅ Please find below the results from static quality gates
Comparison made with ancestor 7f663ee22d542c8d312698275d461520b9c9087d
📊 Static Quality Gates Dashboard
🔗 SQG Job
<details open>
<summary>Successful checks</summary>
Info
||Quality gate|Change|Size (prev → curr → max)|
|--|--|--|--|
|✅|agent_deb_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|748.626 → 748.630 → 760.600|
|✅|agent_deb_amd64_fips|+8.0 KiB (0.00% increase, -0.06% of buffer)|681.266 → 681.274 → 693.640|
|✅|agent_rpm_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|748.610 → 748.613 → 760.580|
|✅|agent_rpm_amd64_fips|+8.0 KiB (0.00% increase, -0.06% of buffer)|681.250 → 681.258 → 693.620|
|✅|agent_rpm_arm64|+4.0 KiB (0.00% increase, -0.03% of buffer)|719.068 → 719.072 → 731.150|
|✅|agent_rpm_arm64_fips|+4.0 KiB (0.00% increase, -0.03% of buffer)|657.296 → 657.300 → 669.800|
|✅|agent_suse_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|748.610 → 748.613 → 760.580|
|✅|agent_suse_amd64_fips|+8.0 KiB (0.00% increase, -0.06% of buffer)|681.250 → 681.258 → 693.620|
|✅|agent_suse_arm64|+4.0 KiB (0.00% increase, -0.03% of buffer)|719.068 → 719.072 → 731.150|
|✅|agent_suse_arm64_fips|+4.0 KiB (0.00% increase, -0.03% of buffer)|657.296 → 657.300 → 669.800|
|✅|docker_agent_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|804.737 → 804.741 → 816.790|
|✅|docker_agent_arm64|+4.0 KiB (0.00% increase, -0.03% of buffer)|799.877 → 799.881 → 812.020|
|✅|docker_agent_jmx_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|995.607 → 995.611 → 1007.660|
|✅|docker_agent_jmx_arm64|+4.0 KiB (0.00% increase, -0.03% of buffer)|979.527 → 979.531 → 991.670|
</details>
<details>
<summary>19 successful checks with minimal change (< 2 KiB)</summary>
||Quality gate|Current Size|
|--|--|--|
|✅|agent_heroku_amd64|311.489 MiB|
|✅|agent_msi|650.633 MiB|
|✅|docker_cws_instrumentation_amd64|7.447 MiB|
|✅|docker_cws_instrumentation_arm64|6.877 MiB|
|✅|docker_dogstatsd_amd64|40.074 MiB|
|✅|docker_dogstatsd_arm64|38.136 MiB|
|✅|docker_host_profiler_amd64|309.011 MiB|
|✅|docker_host_profiler_arm64|320.078 MiB|
|✅|dogstatsd_deb_amd64|30.817 MiB|
|✅|dogstatsd_deb_arm64|28.763 MiB|
|✅|dogstatsd_rpm_amd64|30.817 MiB|
|✅|dogstatsd_suse_amd64|30.817 MiB|
|✅|iot_agent_deb_amd64|47.570 MiB|
|✅|iot_agent_deb_arm64|44.017 MiB|
|✅|iot_agent_deb_armhf|44.830 MiB|
|✅|iot_agent_rpm_amd64|47.571 MiB|
|✅|iot_agent_suse_amd64|47.569 MiB|
|✅|docker_cluster_agent_amd64|211.746 MiB|
|✅|docker_cluster_agent_arm64|224.672 MiB|
</details>
Regression Detector
Regression Detector Results
Metrics dashboard
Target profiles
Job ID: 65432957-cd1c-4fe0-8839-876bbbe26834
Baseline: 49f90fcecbc54618f1e4a5ce050d2b419e4d46cc
Comparison: 56a5874a89986f048de7137c68fdd22feff3456d
[Diff](49f90fcecbc54618f1e4a5ce050d2b419e4d46cc...56a5874a89986f048de7137c68fdd22feff3456d)
Optimization Goals: ✅ No significant changes detected
<details>
<summary><h2>
Fine details of change detection per experiment
</h2></summary>
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|------|---------------------------------------------|--------------------|----------|----------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ➖ | quality_gate_logs | % cpu utilization | +0.63 | [-0.25, +1.51] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_private_action_runner | memory utilization | +0.56 | [+0.44, +0.69] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_mean_fs_load | memory utilization | +0.28 | [+0.25, +0.32] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_idle | memory utilization | +0.20 | [+0.17, +0.24] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_cpu | % cpu utilization | +0.19 | [-0.07, +0.44] | 1 | Logs |
| ➖ | quality_gate_security_no_fs_load | memory utilization | -0.01 | [-0.07, +0.05] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_memory | memory utilization | -0.06 | [-0.28, +0.15] | 1 | Logs |
| ➖ | quality_gate_idle_all_features | memory utilization | -0.18 | [-0.26, -0.11] | 1 | Logs bounds checks dashboard |
| ➖ | python_openmetrics | % cpu utilization | -0.18 | [-0.86, +0.49] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_client_drop_detector_cpu | % cpu utilization | -0.19 | [-0.73, +0.35] | 1 | Logs |
| ➖ | quality_gate_idle | memory utilization | -0.27 | [-0.31, -0.23] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_metrics_logs | memory utilization | -0.32 | [-0.54, -0.10] | 1 | Logs bounds checks dashboard |
</details>
<details>
<summary><h2>
Bounds Checks: ✅ Passed
</h2></summary>
| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|------|------------------------------------|-----------------------|-------------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ✅ | python_openmetrics | checks_execution_time | 10/10 | 70.82 ≤ 100 | bounds checks dashboard |
| ✅ | python_openmetrics | cpu_usage | 10/10 | 1336.33 ≤ 1500 | bounds checks dashboard |
| ✅ | python_openmetrics | memory_usage | 10/10 | 4.31GiB ≤ 4.75GiB | bounds checks dashboard |
| ✅ | quality_gate_idle | intake_connections | 10/10 | 4 ≤ 5 | bounds checks dashboard |
| ✅ | quality_gate_idle | memory_usage | 10/10 | 176.19MiB ≤ 181MiB | bounds checks dashboard |
| ✅ | quality_gate_idle | total_bytes_received | 10/10 | 760.91KiB ≤ 819.20KiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | intake_connections | 10/10 | 2 ≤ 5 | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | memory_usage | 10/10 | 475.75MiB ≤ 542MiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | total_bytes_received | 10/10 | 1.14MiB ≤ 1.25MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | intake_connections | 10/10 | 18 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 221.85MiB ≤ 228MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_logs | total_bytes_received | 10/10 | 263.89MiB ≤ 292MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 353.55 ≤ 2000 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | intake_connections | 10/10 | 20 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | memory_usage | 10/10 | 408.33MiB ≤ 455MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | total_bytes_received | 10/10 | 0.95GiB ≤ 1.04GiB | bounds checks dashboard |
| ✅ | quality_gate_private_action_runner | memory_usage | 10/10 | 74.09MiB ≤ 77MiB | bounds checks dashboard |
| ✅ | quality_gate_security_idle | cpu_usage | 10/10 | 27.84 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_idle | memory_usage | 10/10 | 322.05MiB ≤ 357MiB | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | cpu_usage | 10/10 | 39.55 ≤ 200 | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | memory_usage | 10/10 | 307.14MiB ≤ 337MiB | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | cpu_usage | 10/10 | 21.51 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | memory_usage | 10/10 | 317.46MiB ≤ 348MiB | bounds checks dashboard |
</details>
<details>
<summary><h2>
Explanation
</h2></summary>
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".
</details>
CI Pass/Fail Decision
✅ Passed. All Quality Gates passed.
Done in 378e44f8783. The test subscribes to the unset events of the collector's source and waits for the one of the image, which the cleanup sends, then checks the store. It passes in 0.02 s. The 10 s timer only bounds a failure.
[P2] Order cleanup with image removal and subsequent updates
This unconditional unset runs asynchronously after acknowledging the runtime deletion. If the same image ID is pulled again and the remote stream publishes a fresh enriched SBOM before this goroutine queues its cleanup, the delayed unset deletes that fresh SBOM. The runtime image remains, but its new runtime usage is lost until another report arrives. Apply cleanup atomically with the runtime unset, or use generation-aware ordering so a deletion cannot remove a later update; add a regression test that interleaves removal, re-creation, and enrichment.
AI review by Codex (OpenAI) - workflow run
patch is incorrect: the asynchronous cleanup can delete a newly published SBOM when an image is removed and quickly re-created. The added test covers only deletion without concurrent updates.
The cleanup is queued as soon as the store delivers the runtime unset, within milliseconds. A fresh enriched SBOM takes a new pull, a Trivy scan reaching Success and a merged report, seconds to minutes later, so it lands after the cleanup. A report that merges inside that window lands on the entity of the removed image and goes with it, and the next report of a container of the pulled image merges again. I would keep the ordering as it is.
Approved these changes.
Approved these changes.
/merge
<!-- "FeedbackWorkflowId":"ed2a8a1e-36ad-4a0e-a89e-9b34816445c8_36" -->
View all feedbacks in Devflow UI.
2026-10-19 13:28:37 UTC :information_source: Start processing command /merge
Use /merge -c to cancel this operation!
---2026-10-19 13:28:42 UTC :information_source: MergeQueue: pull request added to the queue
The expected merge time in main is approximately 2h (p90).
Use /merge -c to cancel this operation!
---
<div align="right">
:hourglass_flowing_sand: Building merge commit 0886b70d14 in pipeline 1081367623011917264...
</div>
frank-spano
0intro
The remote SBOM collector publishes the image SBOMs it enriches with
runtime usage under its own source, and CRI-O publishes the SBOMs of its
images under the trivy source. When the runtime removed an image, both
entities stayed for the life of the core agent. A pull of the same image
then brought the old enriched SBOM back before any container ran, and
its status kept containerd, docker and CRI-O from scanning the image
again. The entities also piled up with image churn.
Unset the image entity of the remote SBOM collector once the runtime
source unsets the image, and in CRI-O unset the trivy entity with the
runtime one.