Repository navigation
On-change subscriptions over NETCONF and RESTCONF, RESTCONF event streams - #1814
Open
mattiaswal wants to merge 10 commits into
Open
mattiaswal wants to merge 10 commits into
mattiaswal wants to merge 10 commits into
Conversation
mattiaswal
marked this pull request as ready for review
November 21, 2026 22:00
mattiaswal
force-pushed
the
restconf-streams
branch
3 times, most recently
from
November 22, 2026 10:35
641affe to
8765fb7
Compare
rousette refuses establish-subscription without a Forward header and nginx had no location for /streams/. The 120 s read timeout is two of rousette's 55 s keep-alives. A stream is one request to the rate limit, so cap open streams per address instead. Signed-off-by: Mattias Walström <lazzer@gmail.com>
The 150 s without events is longer than both the default and the configured nginx read timeout. Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Mattias Walström <lazzer@gmail.com>
statd pushes a key when it changes, and wants it without the values computed per request, so counters do not show up as changes. Signed-off-by: Mattias Walström <lazzer@gmail.com>
An on-change subscription never fired for data from yangerd, sysrepo only compares what is written to the datastore. Pushing from statd's main loop deadlocks for 5 s with any client GET of the same module, which holds the module lock while it waits for that loop, hence a daemon of its own, statd-push. Signed-off-by: Mattias Walström <lazzer@gmail.com>
The resource of a link-down alarm is the path of the interface, which sysrepo could not put in a change notification, so a subscriber of the alarm list heard nothing once such an alarm was in the list. Signed-off-by: Mattias Walström <lazzer@gmail.com>
NETCONF delivers notifications on the session that subscribed, so each subscription gets a session of its own. netopeer2 resolves the module names in an XPath filter as XML prefixes, hence the declarations. Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Mattias Walström <lazzer@gmail.com>
make test-spec rewrote them on every run, they were checked in without the cleanup it does. Signed-off-by: Mattias Walström <lazzer@gmail.com>
mattiaswal
force-pushed
the
restconf-streams
branch
from
November 22, 2026 11:01
8765fb7 to
2eb517e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A RESTCONF client can now subscribe to notifications and read them as a stream of server-sent events, and on-change subscriptions to the operational datastore report changes to interfaces, their addresses, LLDP neighbors and the alarm list. On-change works over NETCONF as well.
Event streams (nginx)
rousette refuses
establish-subscriptionwithout aForwardheader, and nginx had no location for/streams/. Both are added. A stream is a single request to the rate limit, so open streams are capped at 16 per client address instead. The read timeout is 120 s, two of rousette's 55 s keep-alives.On-change (yangerd, statd-push, sysrepo)
Operational data is served by statd answering each GET from yangerd. That gives sysrepo nothing to compare, so an on-change subscription never fired. For the keys listed in
src/statd/push.c, the data is now also written to the operational datastore when yangerd reports a change, and sysrepo sends the difference to the subscribers. A GET is still answered by statd as before.Why a daemon of its own, statd-push
The write cannot run in statd's event loop:
sr_apply_changes()is synchronous, and it needs the lock of the module it writes.sr_apply_changes(). Each side waits for the other until one of them times out, 5 s.sr_apply_changes(). The operational write path passes 0, which is the fixedSR_MOD_LOCK_TIMEOUTof 5 s, so a short try and a retry from a timer does not avoid the stall.statd already writes the mDNS neighbors from its loop this way and retries when the datastore is busy.
ietf-interfacesis read far more often thaninfix-services, and a stalled GET or a late event on each collision is not acceptable there.So the write needs a second execution context.
statd-pushis a small libev daemon with its own sysrepo connection, started by Finit with the same condition as statd. It follows a yangerdwatchand writes each changed key. When a write times out it opens a new watch, on which yangerd sends every key again.Tests
services/restconf/streams: subscribe without aForwardheader, keep a silent stream open for 150 s, then receive anetconf-config-change.misc/on_change: runs on either transport, on a veth pair so that disabling one end takes the carrier from the other. The link going down and up is reported within a second. The link-down alarm is reported within 15 s, after its 10 s hold-off, and cleared within two.subscribe()on both transports. NETCONF uses a session per subscription.The last commit is unrelated: two Wi-Fi topology images that
make test-specrewrote on every run.Checklist
Tick relevant boxes, this PR is-a or has-a: