-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libyang3 schema default value not honored ... randomly ... bug #2350
Comments
That is weird indeed and it would be great if I could reproduce it somehow. What could perhaps affect this is the forced ordering of nodes in newer libyang when they are always following the order in the YANG module. Some functions may create nodes "before" your pointer to the data tree, which may one not always expect and it can result in some "missing" nodes. But no idea whether this can really be an issue or how this is handled in the Python bindings. |
I don't see how this could be python-specific, since the bindings on these functions are pretty minimal. I've got to imagine its in the C libyang itself, that said, I can't say if maybe its in print_mem() not emitting the default values somehow or in the parsed data tree. Once I finish up the SONiC porting and get the other PRs accepted here in libyang we depend on I can probably spend some time to write up a test case for this in C (though I'll probably include the entire yang schema and json config in the test case unless I can fairly quickly come up with a reduced set that reproduces the issue). |
That would be great, no problem with including a YANG schema and a data file, even if large. |
I'm encountering a similar issue with the default values not being reported in a stack using these software (trying to upgrade from older versions): netopeer2-server-2.2.35 In my case, a netconf client perform a get but and is missing a default-value leaf when previous to the upgrade it was returned. See schema here, and notably the leaf maximum-number-of-transport-flows: What was sent before in an edit config:
Then what is fetched using a get rpc on the processing-elements module:
Note that in my example, using sysrepocfg to dump the content of the operational datastore with Returns nothing with new versions but was returning the default values before. I will try to have a repro step in a small and controlled environment to facilitate investigation as well ! |
On my end this is reproduceable using the attached yang model (I used the processing-element one but removed external dependencies) and this script (uses sysrepoctl to load it and get with defaults)
With previous stack running I have this result:
With new stack running :
|
Okay, thanks for the reproducer and files, based on which I have learned that you are talking about a |
Ok, thanks for the reply, then I will make adaptations on my end ! Note that @bradh352 case might not be the same, sorry If I hijacked this thread and his issue is still not addressed but it seemed similar. |
Yeah, my issue I'm pretty sure is different. Finishing up porting the last SONiC module to libyang3 (GOlang using |
While porting SONiC from libyang 1.0.73 to 3.7.8, I ran across a peculiar issue. Unless I'm evaluating it wrong, it looks like a bug in libyang's handling of default values but simply reordering the leaf nodes in the container magically fixes it. I've only found a single instance of this in all of SONiC's schema.
If I reorder the leaf nodes in the schema, then the default value shows up and works.
I have a commit here showing the schema reorder I made to make the tests pass:
sonic-net/sonic-buildimage@dd1dddb
The schema leafs impacted are:
both tests do an xpath query for
/sonic-device_metadata:sonic-device_metadata/DEVICE_METADATA/localhost/hostname
then load the child nodes into a dictionary, and validate the keys ofsonic-device_metadata:default_bgp_status
andsonic-device_metadata:docker_routing_config_mode
exist and are of the expected values.This is happening in libyang-python with code similar to this:
I'm not sure what the underlying cause is so I don't know how to submit a reduced test case.
The text was updated successfully, but these errors were encountered: