[YANGTOOLS-821] LeafRefContext fails to process augmentations Created: 20/Oct/17  Updated: 10/Apr/22  Resolved: 24/Jul/18

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: 1.1.2, 2.0.5
Fix Version/s: 2.0.9, 2.0.6.1

Type: Bug Priority: Medium
Reporter: Jan Srnicek Assignee: Marek Gradzki
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

LeafRefContext.validateNodeData() looks like it cant process augmentation nodes,
or at least when Augmentation Node enters it, it fails on

java.lang.UnsupportedOperationException: Augmentation node has no QName
at org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier$AugmentationIdentifier.getNodeType(YangInstanceIdentifier.java:651) ~[yang-data-api-1.1.2-Carbon.jar:na]
at org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedNode.getNodeType(AbstractImmutableNormalizedNode.java:27) ~[yang-data-impl-1.1.2-Carbon.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validateNodeData(LeafRefValidatation.java:251) ~[yang-data-impl-1.1.2-Carbon.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validateNodeData(LeafRefValidatation.java:241) ~[yang-data-impl-1.1.2-Carbon.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validateNodeData(LeafRefValidatation.java:270) ~[yang-data-impl-1.1.2-Carbon.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validateNodeData(LeafRefValidatation.java:241) ~[yang-data-impl-1.1.2-Carbon.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validateNode(LeafRefValidatation.java:95) ~[yang-data-impl-1.1.2-Carbon.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validate0(LeafRefValidatation.java:73) ~[yang-data-impl-1.1.2-Carbon.jar:na]
at org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation.validate(LeafRefValidatation.java:59) ~[yang-data-impl-1.1.2-Carbon.jar:na]

From looking at the method, support for augmentations is missing, in that case it falls back to MapNode logic and fails with exception above

Appears in 1.1.2-Carbon



 Comments   
Comment by Robert Varga [ 26/Dec/17 ]

We need the models and data used to reproduce this issue.

Comment by Marek Gradzki [ 29/Jun/18 ]

Here is example of config that fails to validate:

<bgp xmlns="http://openconfig.net/yang/bgp">
    <peer-groups>
        <peer-group>
            <peer-group-name>application-peers</peer-group-name>
        </peer-group>
    </peer-groups>
    <neighbors>
        <neighbor>
            <neighbor-address>10.25.1.9</neighbor-address>
            <config>
                <peer-group>application-peers</peer-group>
            </config>
        </neighbor>
    </neighbors>
</bgp>

Where peer-group is defined in openconfig-bgp@2015-10-09.yang as:

  // add peer-group pointer only for the neighbor list
  augment /bgp/neighbors/neighbor/config {
    description
      "Augmentation to allow association of a neighbor with a
      peer-group";
    uses bgp-neighbor-peer-group_config;
  }

  grouping bgp-neighbor-peer-group_config {
    [...]
    leaf peer-group {
      type leafref {
        // we are at /bgp/neighbors/neighbor/
        path "/bgp/peer-groups/peer-group/peer-group-name";
        //TODO: require-instance should be added when it's
        //supported in YANG 1.1
        //require-instance true;
      }
      description
        "The peer-group with which this neighbor is associated";
    }
  }
Comment by Marek Gradzki [ 29/Jun/18 ]

Failing unit test (honeycomb):

https://gerrit.fd.io/r/#/c/13292/

Comment by Marek Gradzki [ 29/Jun/18 ]

More complex example, based on ODL BGP Oxygen User Guide, uses openconfig-network-instance:protocol augmentation defined in bgp-openconfig-extensions@2017-12-07 for configuration of neighbors:

<bgp xmlns="http://openconfig.net/yang/bgp">
    <peer-groups>
        <peer-group>
            <peer-group-name>application-peers</peer-group-name>
        </peer-group>
    </peer-groups>
</bgp>
<network-instances xmlns="http://openconfig.net/yang/network-instance">
    <network-instance>
        <name>global-bgp</name>
        <config>
            <name>global-bgp</name>
        </config>
        <protocols>
            <protocol>
                <identifier xmlns:x="http://openconfig.net/yang/policy-types">x:BGP</identifier>
                <name>hc-bgp-instance</name>
                <config>
                    <name>hc-bgp-instance</name>
                    <identifier xmlns:x="http://openconfig.net/yang/policy-types">x:BGP</identifier>
                </config>
                <bgp xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
                    <neighbors>
                        <neighbor>
                            <neighbor-address>10.25.1.9</neighbor-address>
                            <config>
                                <peer-group>application-peers</peer-group>
                            </config>
                        </neighbor>
                    </neighbors>
                </bgp>
            </protocol>
        </protocols>
    </network-instance>
</network-instances>

LeafRefValidatation.validate fails to validate the config with the same exception as in the issue description.

Comment by Marek Gradzki [ 23/Jul/18 ]

Fix:
https://git.opendaylight.org/gerrit/#/c/74338/

Tests are using XmlParserStream (much easier to test + compatibility with XML parser is something we are interested in),
so they could not be placed in yang-data-impl (would introduce circular dependency).

Robert, is there a better place for them than yang-data-codec-xml?

Comment by Robert Varga [ 23/Jul/18 ]

Couple of nitpicks in review, otherwise it looks good.

The test suite is just fine as it is – we can move it down a notch when we refactor yang-data-impl.

Generated at Wed Feb 07 20:54:24 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.