feat(yang-push): migrate to yang-rs-5 / libyang 5.4.9, revamp OTEL metrics, refresh example YANG modules - #23
feat(yang-push): migrate to yang-rs-5 / libyang 5.4.9, revamp OTEL metrics, refresh example YANG modules#23rodonile wants to merge 5 commits into
Conversation
837c2f7 to
f79f6e9
Compare
There was a problem hiding this comment.
Pull request overview
This PR upgrades the YANG-Push validation and example consumer code to yang5 (libyang 5.4.9), revamps OpenTelemetry metrics emitted by the validation actor, and refreshes bundled example YANG modules / YANG library XML to work under stricter ANYDATA_STRICT validation.
Changes:
- Migrated
yang-pushvalidation actor andkafka-yang-consumerexample fromyang4→yang5, enablingANYDATA_STRICTwhere applicable. - Overhauled validation actor OTEL metrics: renamed/consolidated instruments and added new gauges (pending, cached peers/subscriptions).
- Updated bundled example YANG library XML and modules; added/expanded validation actor tests (including schema-fetch in-flight buffering behavior).
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/yang-push/src/validation/mod.rs | Main migration to yang5, new strict validation behavior, buffering corner-case handling, and OTEL metrics redesign + tests. |
| crates/yang-push/src/lib.rs | Removes now-obsolete OTEL constants used by the previous metrics scheme. |
| crates/yang-push/Cargo.toml | Switches dependency from yang4 to yang5. |
| crates/collector/examples/kafka-yang-consumer.rs | Migrates example validator to yang5 and enables ANYDATA_STRICT. |
| crates/collector/Cargo.toml | Switches dependency from yang4 to yang5. |
| Cargo.toml | Replaces workspace yang4 dependency with yang5. |
| Cargo.lock | Updates lockfile for yang5 / libyang5-sys and related dependency graph changes. |
| assets/yang/ietf-telemetry-message/yang-lib-full.xml | Refreshes example YANG library to include required modules/structure for stricter validation. |
| assets/yang/ietf-telemetry-message/modules/ietf-yp-observation@2026-05-11.yang | Adds observation-time augmentation module used by updated examples. |
| assets/yang/ietf-telemetry-message/modules/ietf-yang-push-revision@2025-12-07.yang | Updates example revision/version augmentation module definitions. |
| assets/yang/ietf-telemetry-message/modules/ietf-system-capabilities@2022-02-17.yang | Formatting/whitespace adjustments in bundled module copy. |
| assets/yang/ietf-telemetry-message/modules/ietf-distributed-notif@2026-04-13.yang | Adds distributed notification augmentation module used by updated examples. |
| assets/yang/ietf-interfaces/yang-lib.xml | Refreshes example YANG library for interface payload validation under strict parsing. |
| assets/yang/ietf-interfaces/modules/ietf-yp-observation@2026-05-11.yang | Adds observation-time augmentation module for interfaces example set. |
| assets/yang/ietf-interfaces/modules/ietf-yang-push-revision@2025-12-07.yang | Updates example revision/version augmentation module definitions for interfaces set. |
| assets/yang/ietf-interfaces/modules/ietf-system-capabilities@2022-02-17.yang | Formatting/whitespace adjustments in bundled module copy. |
| assets/yang/ietf-interfaces/modules/ietf-interfaces@2018-02-20.yang | Updates bundled ietf-interfaces module copy (NMDA-era model + legacy deprecations). |
| assets/yang/ietf-interfaces/modules/ietf-distributed-notif@2026-04-13.yang | Adds distributed notification augmentation module for interfaces example set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- 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
…op it 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.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Suppressed comments (10)
assets/yang/ietf-telemetry-message/yang-lib-full.xml:52
- This
<namespace>value is split across lines, which introduces leading whitespace/newlines into the element text. That makes the namespace URI technically different (and potentially invalid), and may break YANG library parsing / module resolution.
<namespace>
urn:ietf:params:xml:ns:yang:ietf-notification-capabilities</namespace>
assets/yang/ietf-telemetry-message/yang-lib-full.xml:142
- This
<namespace>value is split across lines, which introduces leading whitespace/newlines into the element text. That makes the namespace URI technically different (and potentially invalid), and may break YANG library parsing / module resolution.
<namespace>
urn:ietf:params:xml:ns:yang:ietf-subscribed-notif-receivers</namespace>
assets/yang/ietf-interfaces/yang-lib.xml:60
- This
<namespace>value is split across lines, which introduces leading whitespace/newlines into the element text. That makes the namespace URI technically different (and potentially invalid), and may break YANG library parsing / module resolution.
<namespace>
urn:ietf:params:xml:ns:yang:ietf-subscribed-notifications</namespace>
assets/yang/ietf-interfaces/yang-lib.xml:117
- This
<namespace>value is split across lines, which introduces leading whitespace/newlines into the element text. That makes the namespace URI technically different (and potentially invalid), and may break YANG library parsing / module resolution.
<namespace>
urn:ietf:params:xml:ns:yang:ietf-subscribed-notif-receivers</namespace>
assets/yang/ietf-telemetry-message/modules/ietf-yang-push-revision@2025-12-07.yang:154
- This line ends with a tab character. Trailing tabs/whitespace can cause noisy diffs and may trip formatting/lint tooling for YANG sources; please remove it.
assets/yang/ietf-interfaces/modules/ietf-yang-push-revision@2025-12-07.yang:154 - This line ends with a tab character. Trailing tabs/whitespace can cause noisy diffs and may trip formatting/lint tooling for YANG sources; please remove it.
assets/yang/ietf-telemetry-message/yang-lib-full.xml:85 - This
<namespace>value is split across lines, which introduces leading whitespace/newlines into the element text. That makes the namespace URI technically different (and potentially invalid), and may break YANG library parsing / module resolution.
<namespace>
urn:ietf:params:xml:ns:yang:ietf-subscribed-notifications</namespace>
crates/yang-push/src/validation/mod.rs:186
- The doc comment for
schema_fetch_pendingsays it is set only forLookupBySubscriptionInfo, but the implementation also sets it forLookupBySubscriptionIdlookups. This makes the state-machine explanation inaccurate for readers and future maintainers.
/// `schema_fetch_pending` is set to `true` when a `LookupBySubscriptionInfo`
/// request is sent and cleared to `false` when the cache actor responds,
/// regardless of whether a schema was found. While it is `true`, duplicate
/// SubscriptionStarted packets are buffered rather than forwarded unvalidated.
assets/yang/ietf-telemetry-message/modules/ietf-yp-observation@2026-05-11.yang:33
- The NETCONF WG URL in the contact block is missing a slash (
http:/tools...). This is a typo and results in an invalid URL.
"WG Web: <http:/tools.ietf.org/wg/netconf/>
assets/yang/ietf-interfaces/modules/ietf-yp-observation@2026-05-11.yang:33
- The NETCONF WG URL in the contact block is missing a slash (
http:/tools...). This is a typo and results in an invalid URL.
"WG Web: <http:/tools.ietf.org/wg/netconf/>
- 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
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 19 changed files in this pull request and generated no new comments.
Suppressed comments (3)
crates/yang-push/src/validation/mod.rs:99
- Module docs say unvalidated packets have
content_id = None, butSubscriptionInfo::content_id()is always aContentId(uses "EMPTY" for placeholders). The optional value that indicates validation iscached_content_idin the actor output tuple, so the docs should reference that to avoid misleading downstream consumers.
//! - **Schema unavailable**: Forwards unvalidated
//! - `content_id` is `None`; downstream can detect and handle unvalidated
//! packets
assets/yang/ietf-telemetry-message/modules/ietf-yp-observation@2026-05-11.yang:33
- The contact URL is malformed (
http:/...missing a slash), which breaks the WG link in generated docs and makes the module text inaccurate.
"WG Web: <http:/tools.ietf.org/wg/netconf/>
assets/yang/ietf-interfaces/modules/ietf-yp-observation@2026-05-11.yang:33
- The contact URL is malformed (
http:/...missing a slash), which breaks the WG link in generated docs and makes the module text inaccurate.
"WG Web: <http:/tools.ietf.org/wg/netconf/>
Summary
This PR contains the following commits:
feat(yang-push): update validation actor to yang-rs-5 (libyang 5.4.9)— upgrading the YANG-Push validation actor to theyang5crate (libyang 5.4.9) and refreshing example YANG modules/libraries.feat(yang-push): improve OTEL metrics for validation actor— overhauling the validation actor's OpenTelemetry metrics.feat(collector): migrate kafka-yang-consumer example to yang-rs-5— migrating thekafka-yang-consumerexample fromyang4toyang5.Changes
yang4 → yang5 migration
yang4dependency withyang5(libyang 5.4.9) in the validation actor and thekafka-yang-consumerexample in the collector crate - adjusted all code to the updated API and enforcingANYDATA_STRICTvalidationyang-lib.xmlfiles in assets. They were incomplete and relying on deprecated yang-modules and now with full anydata_strict validation tests were failingschema_fetch_pendingtracking onCachedSubscriptionto detect duplicateSubscriptionStarted/SubscriptionModifiedpackets arriving while a schema lookup is still in-flight, buffering them instead of forwarding unvalidatedOTEL metrics overhaul
droppedcounter tagged by areasonattribute (decode_error,buffer_full_subscription,buffer_full_peer,validation_failed,incomplete_subscription_started,no_subscription_id,send_error).cache_lookupscounter tagged by abyattribute (subscription_info,subscription_id).reasontag to theskippedcounter, distinguishing why validation was skipped:no_library,context_failed, andno_subscription_info.decode_messageto avoid double counting of decoded messagespendinggauge tracking packets pending in the queue awaiting reprocessing