feat(discovery): add lock-free EndpointSlice ready-endpoint store #9952
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 378 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.355
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9952"
general
weight: 0.35
claude[bot]
Description
Problem
SMG's Gateway API mode needs lock-free resolution of ready Kubernetes
Serviceendpoints fromdiscovery.k8s.io/v1EndpointSliceobjects — covering both standard selector-backed Services and selector-less / controller-managedEndpointSlices carrying IPv4, IPv6, or FQDN addresses.Solution
Add an isolated
endpoint_slicemodule behind the existingkubernetesfeature insmg-service-discoveryproviding pure slice resolution and a lock-freeArcSwap-backedEndpointSliceStoredriven bykube::runtime::watcher.Changes
crates/service_discovery/src/endpoint_slice.rs:-
SERVICE_NAME_LABEL(kubernetes.io/service-name),ServiceKey,EndpointAddress(Ip(IpAddr)/Fqdn(String)with bracketed IPv6Display),ResolvedEndpoint(authority(),url(scheme)),EndpointSnapshot-
service_key_ofandresolve_endpoint_slice: parses IPv4, IPv6, and FQDN slices; filters TCP ports (skipping port 0 and non-TCP); skips unready (conditions.ready == Some(false)) and terminating (conditions.terminating == Some(true)) endpoints-
EndpointSliceStore: lock-freeArcSwap<EndpointSnapshot>reads (snapshot(),endpoints(ns, name),endpoints_for_port(ns, name, port_name)); incrementalapply/delete, fullreplace_all, and atomic watchInit/InitApply/InitDonerelist handling-
watch_endpoint_slices: backoff-resilientkube::runtime::watcherdrivercrates/service_discovery/tests/unit/endpoint_slice/tests.rscovering IPv4, IPv6, FQDN, unready/terminating filtering, invalid ports/addresses, multi-slice merging and deduplication, slice reassignment/deletion, port lookup, relist atomicity, and watch stream error recovery#[cfg(feature = "kubernetes")] pub mod endpoint_slice;+ re-exports incrates/service_discovery/src/lib.rsand gated existing workspacearc-swap = "1.9.1"behind thekubernetesfeature incrates/service_discovery/Cargo.toml(Cargo.lock+1 dep line, 0 new crates)Refs: #8616
Test Plan
cargo +nightly fmt --all -- --check: passed (exit 0)python3 scripts/check_unit_test_layout.py&./scripts/branch-name-check.sh: passed (exit 0)cargo clippy -p smg-service-discovery --all-targets -- -D warningsandcargo clippy -p smg-service-discovery --all-targets --all-features -- -D warnings: passed (0 errors, 0 crate warnings)cargo test -p smg-service-discovery --all-features:230 passed; 0 failed(including allendpoint_slice::tests::*cases)cargo check -p smg: passed (exit 0)Release note
none (internal
smg-service-discoveryprimitive behind thekubernetesfeature for upcoming Gateway API Service backend resolution)<details>
<summary>Checklist</summary>
cargo +nightly fmtpassescargo clippy --all-targets --all-features -- -D warningspasses</details>