Skip to content

Revert "Revert "[WP] Fix isolation re-apply mechanism"" and fix the related test - #55631

Open
theop-dd wants to merge 5 commits into
mainfrom
revert-55598-revert-54056-theop-dd/fix-isolation-swap-map
Open

Revert "Revert "[WP] Fix isolation re-apply mechanism"" and fix the related test#55631
theop-dd wants to merge 5 commits into
mainfrom
revert-55598-revert-54056-theop-dd/fix-isolation-swap-map

Conversation

@theop-dd

@theop-dd theop-dd commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Reverts #55598 with the required fixes.

Fix a race condition in TestRawPacketRouterSelFlipOnRulesetReload

This race condition caused CI delays and intermittent test failures.

The isolation reapplication change moved the raw_packet_router_sel flip out of ApplyRuleSet. The flip now occurs later, in the eBPF event-reader goroutine, after the snapshot has been replayed.

However, reloadPolicies() returns as soon as a no-op event is queued. The test then immediately reads the selector and expects it to have already flipped.

Depending on the timing, this could result in either of the following:

  • The snapshot has not yet triggered the flip, causing the assertion to fail.
  • The test starts tearing down while the snapshot is still being replayed. StopReaders then holds the manager lock while handleEvent attempts to call GetMap, causing a deadlock. As a result, the test suite does not exit and the CI job eventually times out.

This issue only affected tests. In production, the selector is still flipped correctly, isolations remain on the active buffer during reloads, and the probe is not stopped while a snapshot is being replayed.

The fix ensures that snapshot replay completes before reloadPolicies() returns. It also moves the selector flip outside the event-reader callback, preventing teardown from deadlocking.

The underlying deadlock is related to ebpf-manager and was addressed for this use case in DataDog/ebpf-manager#288. This PR bumps the ebpf-manager version to include that fix.

Use separate eBPF collections for each raw-packet router buffer

This issue did not affect CI, but it also needed to be fixed. Each raw-packet router buffer now uses its own eBPF collection.

@dd-octo-sts dd-octo-sts Bot added the internal Identify a non-fork PR label Aug 31, 2026
@github-actions github-actions Bot added the short review PR is simple enough to be reviewed quickly label Aug 31, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review by Codex (OpenAI) - workflow run

Found one correctness issue.

Overall verdict: patch is incorrect because a failed filter installation can still activate an incomplete router buffer.

Comment on lines +850 to +854
if err := p.setupRawPacketProgs(progSpecs, probes.TCRawPacketDropActionKey, probes.RawPacketMaxTailCall, &p.rawPacketActionCollection, true); err != nil {
errs = multierror.Append(errs, err)
}
// all the filters are ready so we can flip
if err = p.flipRawPacketRouterBuffer(); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do not flip when setupRawPacketProgs fails. That function can fail after partially updating the inactive buffer; activating it could leave network-isolation filters missing or incomplete. Return the setup error and keep the current buffer active.

@theop-dd theop-dd added changelog/no-changelog No changelog entry needed qa/done QA done before merge and regressions are covered by tests labels Aug 31, 2026
@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 55.29% (-0.05%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2c618e3 | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor 14a1e606:

Results for datadog-agent_7.85.0~devel.git.15.2c618e3.pipeline.135976808-1_amd64.deb:

No change detected

Results for datadog-iot-agent_7.85.0~devel.git.15.2c618e3.pipeline.135976808-1_amd64.deb:

No change detected

@github-actions github-actions Bot added medium review PR review might take time and removed short review PR is simple enough to be reviewed quickly labels Aug 31, 2026
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 31, 2026

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: 861ea148-c355-4aee-9865-26f80eb956e6

Baseline: 14a1e60
Comparison: 2c618e3
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
dsd_uds_10mb_3k_timestamped_contexts_memory memory utilization +0.28 [+0.06, +0.50] 1 Logs
quality_gate_idle_all_features memory utilization +0.16 [+0.11, +0.21] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization +0.04 [+0.00, +0.08] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization -0.26 [-0.33, -0.19] 1 Logs bounds checks dashboard
quality_gate_security_mean_fs_load memory utilization -0.27 [-0.30, -0.23] 1 Logs bounds checks dashboard
quality_gate_private_action_runner memory utilization -0.27 [-0.40, -0.14] 1 Logs bounds checks dashboard
quality_gate_security_idle memory utilization -0.28 [-0.32, -0.24] 1 Logs bounds checks dashboard
dsd_uds_10mb_3k_timestamped_contexts_cpu % cpu utilization -0.45 [-0.69, -0.21] 1 Logs
quality_gate_logs % cpu utilization -0.55 [-1.43, +0.33] 1 Logs bounds checks dashboard
quality_gate_metrics_logs memory utilization -0.69 [-0.92, -0.46] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 4 ≤ 5 bounds checks dashboard
quality_gate_idle memory_usage 10/10 175.24MiB ≤ 179MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 750.69KiB ≤ 819.20KiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 3 ≤ 5 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 473.65MiB ≤ 537MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 1.13MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 18 ≤ 40 bounds checks dashboard
quality_gate_logs memory_usage 10/10 212.24MiB ≤ 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.15MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 364.21 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 16 ≤ 40 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 446.42MiB ≤ 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.94GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_private_action_runner memory_usage 10/10 71.95MiB ≤ 75MiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 31.54 ≤ 100 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 328.08MiB ≤ 355MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 64.64 ≤ 200 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 302.83MiB ≤ 335MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 25.19 ≤ 100 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 310.12MiB ≤ 345MiB bounds checks dashboard

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 total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_private_action_runner, 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_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.

@dd-octo-sts

dd-octo-sts Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 14a1e60
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +17.42 KiB (0.00% increase, -0.62% of buffer) 768.464 → 768.481 → 771.220
agent_deb_amd64_fips +12.79 KiB (0.00% increase, -0.42% of buffer) 715.052 → 715.064 → 718.020
agent_rpm_amd64 +17.42 KiB (0.00% increase, -0.62% of buffer) 768.448 → 768.465 → 771.190
agent_rpm_amd64_fips +12.79 KiB (0.00% increase, -0.42% of buffer) 715.036 → 715.048 → 718.020
agent_rpm_arm64 +12.91 KiB (0.00% increase, -0.32% of buffer) 740.392 → 740.405 → 744.370
agent_rpm_arm64_fips +16.91 KiB (0.00% increase, -0.38% of buffer) 691.525 → 691.542 → 695.880
agent_suse_amd64 +17.42 KiB (0.00% increase, -0.62% of buffer) 768.448 → 768.465 → 771.190
agent_suse_amd64_fips +12.79 KiB (0.00% increase, -0.42% of buffer) 715.036 → 715.048 → 718.020
agent_suse_arm64 +12.91 KiB (0.00% increase, -0.32% of buffer) 740.392 → 740.405 → 744.370
agent_suse_arm64_fips +16.91 KiB (0.00% increase, -0.38% of buffer) 691.525 → 691.542 → 695.880
docker_agent_amd64 +19.09 KiB (0.00% increase, -1.88% of buffer) 827.427 → 827.446 → 828.420
docker_agent_arm64 +14.58 KiB (0.00% increase, -0.35% of buffer) 824.427 → 824.442 → 828.440
docker_agent_jmx_amd64 +19.07 KiB (0.00% increase, -1.44% of buffer) 1018.340 → 1018.358 → 1019.630
docker_agent_jmx_arm64 +14.57 KiB (0.00% increase, -0.35% of buffer) 1004.120 → 1004.134 → 1008.130
docker_host_profiler_amd64 +3.35 KiB (0.00% increase, -0.03% of buffer) 307.574 → 307.578 → 319.480
docker_host_profiler_arm64 +3.36 KiB (0.00% increase, -0.03% of buffer) 318.791 → 318.795 → 330.690
17 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
agent_heroku_amd64 316.125 MiB
agent_msi 647.746 MiB
docker_cluster_agent_amd64 212.686 MiB
docker_cluster_agent_arm64 225.718 MiB
docker_cws_instrumentation_amd64 7.439 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_amd64 39.557 MiB
docker_dogstatsd_arm64 37.686 MiB
dogstatsd_deb_amd64 30.303 MiB
dogstatsd_deb_arm64 28.315 MiB
dogstatsd_rpm_amd64 30.303 MiB
dogstatsd_suse_amd64 30.303 MiB
iot_agent_deb_amd64 46.651 MiB
iot_agent_deb_arm64 43.280 MiB
iot_agent_deb_armhf 44.097 MiB
iot_agent_rpm_amd64 46.651 MiB
iot_agent_suse_amd64 46.650 MiB

@theop-dd
theop-dd marked this pull request as ready for review August 31, 2026 10:00
@theop-dd
theop-dd requested a review from a team as a code owner August 31, 2026 10:00

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review by Codex (OpenAI) - workflow run

Patch is incorrect. The test remains timing-dependent and does not reliably verify that snapshot replay and buffer flipping completed.

Comment thread pkg/security/tests/network_test.go Outdated
Comment on lines +271 to +272
// Give time so the snapshot ends and the flip is done
time.Sleep(1 * time.Second)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A fixed sleep preserves the race: slow CI can still read the selector before replay completes, while every run now incurs a one-second delay. More importantly, this does not establish the claimed teardown safety because reloadPolicies still returns before the callback finishes. Add an explicit completion signal and wait for it deterministically.

@theop-dd
theop-dd force-pushed the revert-55598-revert-54056-theop-dd/fix-isolation-swap-map branch 3 times, most recently from f2b57f4 to 13b8c0b Compare September 2, 2026 09:13
@theop-dd
theop-dd force-pushed the revert-55598-revert-54056-theop-dd/fix-isolation-swap-map branch 2 times, most recently from 3a36693 to 3d17b46 Compare September 4, 2026 11:58
@theop-dd
theop-dd force-pushed the revert-55598-revert-54056-theop-dd/fix-isolation-swap-map branch from 3d17b46 to 53d6258 Compare September 4, 2026 13:51
@theop-dd
theop-dd force-pushed the revert-55598-revert-54056-theop-dd/fix-isolation-swap-map branch from 53d6258 to 915f7b3 Compare September 7, 2026 07:30
@theop-dd
theop-dd force-pushed the revert-55598-revert-54056-theop-dd/fix-isolation-swap-map branch from 915f7b3 to b0387ee Compare September 7, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed component/system-probe internal Identify a non-fork PR medium review PR review might take time qa/done QA done before merge and regressions are covered by tests team/agent-security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants