Repository navigation
Conversation
2274d73 to
cc489c1
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Active critical and moderate findings leave authentication, startup failure handling, multi-actor cache coverage, and cache-clearing behavior unresolved.
5 open issues
Reject empty access tokens to prevent unauthenticated controller access · New Reject empty configured tokens in the authorization guard · New Propagate controller startup failures instead of silently disabling the API · New Include all validation actors in controller cache operations · New Discard pending packets when clearing peer cache entries · New
What changed in this PR
Adds an optional HTTPS controller API for inspecting and clearing the YANG-Push validation cache, with bearer-token authentication, TLS configuration, and OpenTelemetry metrics.
Changes:
- Adds serializable cache snapshots and actor commands for retrieving or clearing cache entries.
- Introduces authenticated GET and DELETE endpoints for all-peer and peer-specific cache operations.
- Adds controller configuration, lifecycle integration, metrics, and required dependencies.
| File | Description |
|---|---|
| crates/yang-push/src/validation/state.rs | Defines serializable validation-cache snapshot types. |
| crates/yang-push/src/validation/processing.rs | Exposes peer-cache gauge recording for cache operations. |
| crates/yang-push/src/validation/mod.rs | Re-exports validation-cache snapshot types. |
| crates/yang-push/src/validation/actor.rs | Adds actor commands and handle methods to inspect and clear cache data. |
| crates/collector/src/lib.rs | Integrates the optional controller with UDP-Notif collection startup and shutdown. |
| crates/collector/src/controller.rs | Implements HTTPS routes, authorization, error handling, and request metrics. |
| crates/collector/src/config.rs | Adds optional controller, TLS, and token configuration. |
| crates/collector/Cargo.toml | Adds dependencies required by the controller and authentication. |
| Cargo.toml | Declares workspace versions for the new dependencies. |
| Cargo.lock | Records the resolved versions and checksums for the dependency graph. |
Review effort: Lite
b9be538 to
f57c278
Compare
mxyns
left a comment
There was a problem hiding this comment.
could be nice if you could add a .md doc explaining the architecture of the admin controllers to understand directly what's happening
seems like you were preparing to support multiple handles, not sure if it is out of scope for this PR and will be part of a future PR?
sorry for being annoying but it's easier for me to read when you have some newlines in between ifs, before function returns, in between enum variant definitions when there is derive macros, etc.
some of this is inherited from previous code (type hint, ValidationActorError, etc.) though and not on you 🙂
i don't know why cargo fmt doesn't have code breathability options 🙁
f57c278 to
eefa260
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Active moderate and critical findings remain around mismatched routes and configuration, incomplete multi-actor cache exposure, and a data-loss race when clearing peer state.
4 open issues
5 resolved since last review
Reject empty configured tokens in the authorization guard Reject empty access tokens to prevent unauthenticated controller access Discard pending packets when clearing peer cache entries Include all validation actors in controller cache operations Propagate controller startup failures instead of silently disabling the API
Review effort: Lite
eefa260 to
102f6c4
Compare
|
We tested in lab the |
2b24fef to
3628f8b
Compare
mxyns
left a comment
There was a problem hiding this comment.
apart from the /health endpoint all is good for me. i'll accept after this is resolved 🙂
3628f8b to
d28684a
Compare
74e527b to
04a50e1
Compare
mxyns
left a comment
There was a problem hiding this comment.
Sorry I lied (not on purpose)
This one is the actual last one
riccardo-negri
left a comment
There was a problem hiding this comment.
Nice design overall, cool use of axum middleware
|
(Just edited the PR description) |
rodonile
left a comment
There was a problem hiding this comment.
Even though we for now only have specific yang-push commands, might still be worth to already clean up the structure a bit, e.g.
crates/collector/src/
admin_api/
mod.rs serve(), router(), middleware, AdminApiState, AdminApiError,..
yang_push.rs ValidationActors extractor, handlers, per-actor response types
then in the future we can just add other modules
And even some registry module with actor identification (see comment for lib)
| Some(ValidationActorCommand::GetYangPushCache(peer_ip, resp_tx)) => { | ||
| if resp_tx.is_closed() { | ||
| warn!("Skipping YANG-Push cache request, requester left"); | ||
| continue; | ||
| } | ||
| None => { | ||
| let msg = "YANG-Push validation actor terminated due to command channel closing"; | ||
| warn!(msg); | ||
| Ok(msg.to_string()) | ||
|
|
||
| debug!("Received request to get YANG-Push cache"); | ||
|
|
||
| let snapshot = self.validator.cache_snapshot(peer_ip).map_err(Into::into); | ||
| if resp_tx.send(snapshot).is_err() { | ||
| warn!("Failed to send YANG-Push cache snapshot to requester"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Some(ValidationActorCommand::ClearYangPushCache(peer_ip, resp_tx)) => { | ||
| if resp_tx.is_closed() { | ||
| warn!("Skipping YANG-Push cache clear request, requester left"); | ||
| continue; | ||
| } | ||
|
|
||
| debug!("Received request to clear YANG-Push cache"); | ||
|
|
||
| let clear_result = self.validator.clear_cache(peer_ip).map_err(Into::into); | ||
| if resp_tx.send(clear_result).is_err() { | ||
| warn!("Failed to send cleared YANG-Push cache peers to requester"); | ||
| } | ||
| } |
There was a problem hiding this comment.
General remark here for biased tokio select. Commands here block messages on the fast path. We need to pay attention that they should not take to much time. E.g. when lots of routers with lots of subscriptions are in the cache this might be problematic.
There was a problem hiding this comment.
I agree we should keep that in mind. Do you have an estimate of how many peers and subscriptions we expect there to be in the cache in prod? It could be interesting to do some measurements with nl6 to see how long it takes with more peers.
There was a problem hiding this comment.
we have 20-30 subscriptions per router on avg I would say. What will matter is the number of peers that we will able to handle per shard (i.e. by one single actor), I would say 1-2k peers per shard would be probably a good initial start to have an idea. Easier for you to do a benchmark would probably be artificially populating YangPushCacheSnapshot and then checking how much time snapshot_all takes.
There was a problem hiding this comment.
I’ve tested it quickly locally by artificially populating the peer cache. For 2k peers with 30 subscriptions each, it took around 45 ms to create the snapshot in the actor.
|
|
||
| if validation_handles.len() > 1 { | ||
| warn!( | ||
| count = validation_handles.len(), | ||
| "Multiple validation handles exist; only the first is exposed through the Admin API" | ||
| ); | ||
| } | ||
|
|
||
| udp_notif_handles | ||
| .validation | ||
| .set(validation_handles.first().cloned()) | ||
| .map_err(|_| anyhow::anyhow!("Admin API validation handle was already initialized"))?; | ||
|
|
There was a problem hiding this comment.
Already today nothing prevents someone to configure multiple groups or endpoints (even though we don't do it), and every time we would randomly get one of those handles (since those are hashmaps). With sharding then (assuming we implement it the same way as we did for flow), each endpoint would get n validation actors, and this api would only query one.
It might already make sense to flood instead of sending to one and to register handles with id, e.g.
pub struct ActorId { pub group: String, pub endpoint: String, pub shard: Option<usize>}then when we flood the request we would know who answered.
Ok for me if you want to tackle in a next PR where more commands are being added.
There was a problem hiding this comment.
I’ve split the admin API into mod.rs and yang_push.rs. I would prefer to add multi-actor handling (actor IDs, the extractor, and per-actor responses) in a later PR when I add flow template commands. Or what do you think?
04a50e1 to
c86b095
Compare
c86b095 to
d39bbf8
Compare


Adds an optional HTTPS admin API to inspect and clear the YANG-Push validation cache.
It configures:
Requests must inclued an Authorization: Bearer header. The listen address, TLS cert/key
and token are set in the configs under admin_api. The token must be non-empty.
For authenticated requests to the YANG-Push cache endpoints, the API reports the following metrics: