[YANGTOOLS-892] LeafRefValidatation can't find target node afi-safi-name (bgp-openconfig-extensions@2017-12-07) Created: 02/Aug/18 Updated: 10/Sep/18 Resolved: 10/Sep/18 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | 2.0.9 |
| Fix Version/s: | 2.1.0, 2.0.11, 2.0.6.3 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Marek Gradzki | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
LeafRefValidation.validate fails for:
{
"network-instances": {
"network-instance": [
{
"name": "global-bgp",
"config": {
"name": "global-bgp"
},
"protocols": {
"protocol": [
{
"identifier": "openconfig-policy-types:BGP",
"name": "hc-bgp-instance",
"config": {
"identifier": "openconfig-policy-types:BGP",
"name": "hc-bgp-instance"
},
"bgp-openconfig-extensions:bgp": {
"neighbors": {
"neighbor": [
{
"neighbor-address": "10.25.1.9",
"config": {
"peer-group": "application-peers"
},
"afi-safis": {
"afi-safi": [
{
"afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST",
"config" : {
"afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
},
"receive": true,
"send-max": 0
}
]
}
},
{
"neighbor-address": "10.25.1.10",
"config": {
"peer-group": "application-peers"
},
"afi-safis": {
"afi-safi": [
{
"afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST",
"config" : {
"afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
},
"receive": true,
"send-max": 0
}
]
}
},
{
"neighbor-address": "127.0.0.2",
"config": {
"peer-type": "INTERNAL"
},
"timers": {
"config": {
"connect-retry": 10,
"hold-time": 90
}
},
"transport": {
"config": {
"remote-port": 17900,
"passive-mode": false
}
},
"afi-safis": {
"afi-safi": [
{
"afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST",
"config" : {
"afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
},
"receive": true,
"send-max": 0
}
]
}
},
{
"neighbor-address": "127.0.0.3",
"config": {
"peer-type": "EXTERNAL"
},
"timers": {
"config": {
"connect-retry": 10,
"hold-time": 90
}
},
"transport": {
"config": {
"remote-port": 17900,
"passive-mode": false
}
},
"afi-safis": {
"afi-safi": [
{
"afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST",
"config" : {
"afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
},
"receive": true,
"send-max": 0
}
]
}
}
]
}
}
}
]
}
}
]
}
}
With following error:
[...]
org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException:
Invalid leafref value [(http://openconfig.net/yang/bgp-types?revision=2015-10-09)IPV4-UNICAST] allowed values [] of LEAFREF node: (urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=2017-12-07)afi-safi-name leafRef target path: Absolute path:/(http://openconfig.net/yang/network-instance?revision=Optional[2015-10-18])network-instances/(http://openconfig.net/yang/network-instance?revision=Optional[2015-10-18])network-instance/(http://openconfig.net/yang/network-instance?revision=Optional[2015-10-18])protocols/(http://openconfig.net/yang/network-instance?revision=Optional[2015-10-18])protocol/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])bgp/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])neighbors/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])neighbor/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safis/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safi/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])config/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=Optional[2017-12-07])afi-safi-name
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validate0(LeafRefValidatation.java:86) ~[yang-data-impl-2.0.5.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validate(LeafRefValidatation.java:60) ~[yang-data-impl-2.0.5.jar:na]
at io.fd.honeycomb.data.impl.ModifiableDataTreeManager$ConfigSnapshot.commit(ModifiableDataTreeManager.java:112) ~[data-impl-1.18.10-SNAPSHOT.jar:na]
[...]
|
| Comments |
| Comment by Marek Gradzki [ 14/Aug/18 ] |
|
Failing test case: https://git.opendaylight.org/gerrit/#/c/75190/ Log: |
| Comment by Robert Varga [ 05/Sep/18 ] |
|
After single-stepping the unit test, it is clearly yet another of the "forgot about augmentations" case. Note that we are crossing namespaces between: (urn:opendaylight:params:xml:ns:yang:test:network:instance?revision=Optional[2018-08-14])protocol and (urn:opendaylight:params:xml:ns:yang:bgp:test:extensions?revision=Optional[2018-08-14])bgp Hence in YangInstanceIdentifier format we should be seeing an AugmentationIdentifier, we are blindly using a NodeIdentifier based on the QName from the LeafRefPath. Given that the AugmentationIdentifier is missing, we fail to find bgp as a direct child of the protocol map entry (it is present inside an Augmentation) – and thus valid values are not properly populated.
|
| Comment by Robert Varga [ 05/Sep/18 ] |
|
Overall it looks like the entire LeafRefValidation class should be revisited with the knowledge of existence of DataSchemaContext{Node,Tree}. Given that we are already creating LeafRefPath with a Module present, we should be able to express LeafRefPath in terms of PathArguments rather than custom-coded QNameWithPredicates. |
| Comment by Robert Varga [ 10/Sep/18 ] |
|
DataSchemaContextNode uses SchemaPath order, which does not match the XPath order, hence it is not an option (in its current shape & form). After code refactoring we can piggy-back on the code considering choices, which makes it a simple change. |