Repository navigation
feat(egress): add shared kernel drop telemetry core - #3094
Pangjiping merged 3 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65ea860dcf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| readCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 2*time.Second) | ||
| r.pollLocked(readCtx) |
There was a problem hiding this comment.
Read counters before finalizing lease-sensitive transactions
With counter or sample enabled during a table replacement, this synchronous read occurs after nftables.prepareStaticApplyLocked() or Fast Sandbox's writeRemainingLeasesFragment() has finalized the remaining DNS-lease timeouts. If the read delays submission past a lease's expiry, the wrapper still submits that lease with its old positive timeout, reintroducing an expired allow grant. The existing expiry checks cannot catch this because there is no re-planning after the read. Collect counters before lease planning, or revalidate and render the lease-sensitive batch after the wait, and add a regression covering expiry during counter collection.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 1d22240. Moved counter collection ahead of lease planning in both profiles, including sidecar replacement/removal and Fast Sandbox reset, first install, subject removal, and reload. The telemetry lock is held from the pre-planning read through submission, preventing periodic polling from delaying an already-planned transaction while preserving the successful-replacement baseline reset. Added counter/sample regressions for both profiles that expire a lease during counter collection and verify that expired elements are omitted and surviving timeouts use the post-read clock, plus a regression for polling exclusion during replacement.
01bb45c to
fb68d29
Compare
|
The original change (+2370) exceeded the 2000-line review limit in CONTRIBUTING.md, so I split it into three stacked parts. This PR now carries part 1 only: the shared drop-telemetry library, metrics and dependencies, with nothing wired into either profile.
Stacked together, the three parts are byte-identical to the previously reviewed head |
|
An additional review of Medium – drop metrics lost the shared attributes
Low – label values were not a closed set
Low –
Low – the privileged CI script lacked runner tests
Part 2 changes only to register the metrics and add the docs rows; part 3 changes only by the rebase. Apart from these fixes, the full stack is still identical to the previously reviewed |
Pangjiping
left a comment
There was a problem hiding this comment.
Two questions on the new drop-telemetry env vars, inline on config.go.
Refs #3085
Part 1 of 3 of kernel drop telemetry. Base:
mainat3ac0ff4f9; there is no preceding telemetry PR. This is the reduced scope of #3094.This adds the shared drop-telemetry package, definitions for drop metric instruments, dependency notices, and library-level tests. Drop instruments are not registered by runtime initialization in this part; an explicit RegisterDropMetrics API is exercised by library tests and wired only in part 2. It provides default-off script instrumentation, named-counter delta/reset accounting, NFLOG capability probing and a bounded receiver, and header-only TCP/UDP parsing. The environment parser remains a library API: this PR does not wire telemetry into either runtime profile, so setting the new variables does not enable telemetry, and enforcement behavior is unchanged. Sidecar integration, server allowlisting and usage docs follow in part 2; Fast Sandbox follows in part 3.
Configuration has three environment inputs:
OPENSANDBOX_EGRESS_DROP_TELEMETRY,OPENSANDBOX_EGRESS_DROP_LOG_RATE, andOPENSANDBOX_EGRESS_DROP_COUNTER_POLL. NFLOG group is fixed at 3085 per network namespace, and the per-rule burst is derived asclamp(2 × N, 1, 1000)from the rate count N; the default remains 40 and1/daygives 2. Direct Config overrides remain available to library fixtures.Library kernel tests use a minimal standalone ruleset and do not depend on either profile renderer. Privileged CI runs packet/count/drop and live-parent receiver-close checks in private network namespaces, with an explicit NFLOG-unavailable skip reason.
Validation: Go1.26.11 full gofmt has no output; vet/build and droptelemetry/telemetry unit and race tests pass, including nonempty shared-attribute environments, closed labels with bidirectional reason-set equality and a copied read-only accessor, transient-error recovery and idempotent replacement release. The unchanged 26-test hermetic runner suite passed in the prior follow-up; it was not rerun for this configuration-only change. Both Linux private-netns kernel tests pass with
-raceand no skip. This part is +1760/-4 across 20 files.Dependencies: go-nflog/v2 v2.3.0 → mdlayher/netlink → mdlayher/socket (MIT); original notices are copied into the image. Existing x/sys/x/net/x/sync selections are reused; go-cmp is test-only (BSD-3-Clause). No per-part binary-size measurement or container build was performed.
Accounting and samples are best effort. Shutdown orders the library Add before Close/Wait when a callback is observed; the one-second timeout fallback has no such happens-before guarantee, and deferred unbind may log a harmless error after Close. The implementation retains the reviewed behavior and limitations without a dependency upgrade.
Previously identified file-level overlap with still-open #3020:
.github/workflows/egress-test.ymlandcomponents/egress/scripts/test_ci_privileged_go_test.py. No enforcement-anchor logic is included.🤖 Generated with Claude Code