Skip to content

feat(yang-push): separate transport session info from subscription identity - #29

Draft
rodonile wants to merge 7 commits into
network-analytics:mainfrom
rodonile:sub-info-refactor
Draft

feat(yang-push): separate transport session info from subscription identity#29
rodonile wants to merge 7 commits into
network-analytics:mainfrom
rodonile:sub-info-refactor

Conversation

@rodonile

@rodonile rodonile commented Aug 6, 2026

Copy link
Copy Markdown
Member

This PR depends on #23

Summary

SubscriptionInfo used to carry both subscription identity/content fields
(target, models, content_id, etc.) and transport fields
(collector, interface, peer). This PR extracts the transport fields
into a new SessionInfo struct, leaving SubscriptionInfo with only
peer_ip for identitification purposes.

Why

SubscriptionInfo was keyed on the full peer SocketAddr (incl. ephemeral
source port), so a device reconnecting with a new port was treated as a
different subscription. Keying on peer_ip fixes this; SessionInfo keeps
transport details available where still needed (logging/enrichment).

Changes

  • Add SessionInfo to udp-notif-service; UdpNotifRequest wraps it
    (keeps backward-compatible getters).
  • SubscriptionInfo drops collector/interface/port, keeps peer_ip.
  • Thread SessionInfo through CacheLookupCommand, YangLibraryFetcher,
    validation and enrichment actors.
  • Replace validation→enrichment tuples with ValidatedNotification /
    EnrichedNotification structs.
  • With SessionInfo now reaching the enrichment actor, TelemetryMessageMetadata's
    collection-address/collection-port (the collector's own address/port) are
    populated for the first time — previously always None.
  • Add diagnostic logging around module resolution in
    fetch_from_device_by_id.
  • Update subscriptions-info.json fixtures and all tests/call-sites.

@rodonile
rodonile requested review from riccardo-negri and ustorbeck and removed request for riccardo-negri and ustorbeck August 6, 2026 07:22
@rodonile
rodonile marked this pull request as draft August 6, 2026 08:17
@rodonile
rodonile force-pushed the sub-info-refactor branch 2 times, most recently from 3c3a787 to 3e4b508 Compare August 6, 2026 09:57
rodonile and others added 7 commits August 6, 2026 13:55
- Bump yang-rs dependency to yang-rs-5 (libyang 5.4.9) and update
  Cargo.lock/Cargo.toml accordingly
- Refactor validation actor internals for the new yang-rs API
- Update example YANG modules (ietf-interfaces, ietf-yang-push-revision,
  ietf-system-capabilities) and add ietf-distributed-notif,
  ietf-yp-observation
- Regenerate yang-lib.xml / yang-lib-full.xml to match updated modules
- Add counters/gauges for received, decoded, dropped, cache lookups,
  buffered/buffer drained, yang context load status, validated, skipped,
  sent, pending, cached peers/subscriptions
- Record metrics at the relevant points in the validation pipeline
Ensure a CachedSubscription entry exists and schema_fetch_pending is set
before sending a cache lookup request, for both LookupBySubscriptionInfo
and LookupBySubscriptionId. Previously the flag was only set after
buffer_packet ran, which can return early (and skip entry creation)
when the per-subscription/per-peer buffer is full. That left
process_cache_response unable to find the subscription later, and let
duplicate packets keep re-triggering lookups to the cache actor.

Also:
- Log the send error on the LookupBySubscriptionId path the same way
  as LookupBySubscriptionInfo, instead of silently discarding it.
- Add CachedSubscription::new() to remove the duplicated struct literal
  across the four construction sites.
- Note a TODO: CachedPeerSubscriptions entries are never evicted by
  TTL/idleness, only replaced when SubscriptionStarted info changes.
- Collapse the wrapped <namespace> values back onto one line in
  yang-lib.xml and yang-lib-full.xml (ietf-notification-capabilities,
  ietf-subscribed-notifications, ietf-subscribed-notif-receivers, and
  ietf-yang-push-telemetry-message) to be on the safe side with yang
  libraries implementations
- Update the schema_fetch_pending doc comment in validation/mod.rs
Replace the DROP_REASON_*, SKIP_REASON_*, and CACHE_LOOKUP_BY_* string
constants with DropReason, SkipReason, and CacheLookupBy enums deriving
Display, VariantNames, and IntoStaticStr. Counter descriptions are now
generated from VariantNames instead of a hand-maintained list, and
KeyValue tags use IntoStaticStr's zero-allocation &'static str
conversion, avoiding per-packet String allocations on this hot path.
Also merges the duplicate "reason" key into one REASON_KEY constant.
Split the (collector, interface, peer) tuple into two concepts:
SessionInfo (transport context: collector, interface, full peer
SocketAddr) and SubscriptionInfo (subscription identity, now keyed
only on peer_ip). This fixes a latent cache-key bug where a device
reconnecting with a new ephemeral source port was treated as a
different subscription.

Thread SessionInfo alongside SubscriptionInfo through the cache actor,
YangLibraryFetcher trait, and validation/enrichment actors. Replace
the validation->enrichment tuples with named structs
ValidatedNotification/EnrichedNotification. Add diagnostic logging
around YANG module resolution in fetch_from_device_by_id.
@rodonile
rodonile force-pushed the sub-info-refactor branch from 3e4b508 to 7174e65 Compare August 6, 2026 12:05
@rodonile rodonile self-assigned this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants