[YANGTOOLS-956] Augment of mandatory leaf not allowed from within submodule Created: 14/Feb/19  Updated: 24/Oct/19  Resolved: 24/Oct/19

Status: Resolved
Project: yangtools
Component/s: parser
Affects Version/s: 2.0.10
Fix Version/s: 4.0.3, 3.0.7, 2.1.14

Type: Bug Priority: Medium
Reporter: Peter Verthez Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive augmentfailing.zip     Zip Archive augmentok.zip    
Issue Links:
Relates
relates to YANGTOOLS-784 Defer statement initialization in Inf... Resolved

 Description   

We are currently using version 2.0.11 of the YANG parser.

There is a problem with augments of mandatory data. When we parse the model in the attached augmentfailing.zip, the yang parser prints the following warning, and that specific augment is not added:

2019-02-14 12:47:52,504 WARN [com.nokia.netconf.yang.converter.ExportUtilsTest.main()] augment.AbstractAugmentStatementSupport$1 (AbstractAugmentStatementSupport.java:126) - Failed to add augmentation /home/verthezp/tmp/AugBug/sub-module-1.yang:14:4 defined at /home/verthezp/tmp/AugBug/sub-module-2.yang:22:2
org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: An augment cannot add node 'dummyleaf' because it is mandatory and in module different than target [at /home/verthezp/tmp/AugBug/sub-module-2.yang:16:4]

 

If we look at the RFC, this is in reference to the following section in https://tools.ietf.org/html/rfc7950#section-7.17 :


If the augmentation adds mandatory nodes (see Section 3) that
represent configuration to a target node in another module, the
augmentation MUST be made conditional with a "when" statement. Care
must be taken when defining the "when" expression so that clients
that do not know about the augmenting module do not break.


But the augment in sub-module-2.yang is not adding mandatory nodes to a target node in another module: mm:first-augment is belonging to the same module. So the warning of ODL seems to be wrong.

The model in the attachment augmentok.zip is succeeding, so the problem may be that the augment in sub-module-2.yang in augmentfailing.zip is targeting '/am:another-container/mm:first-augment', where the first part of the path is indeed in another module. But only the last part of the path determines the target node according to us.



 Comments   
Comment by Robert Varga [ 14/Feb/19 ]

Rules in https://tools.ietf.org/html/rfc7950#section-7.6.5 apply, in this case bullet 1 because mm:first-augment is not a presence container: the augmentation is adding a mandatory node and it is not directly guarded by a when statement. The augmentation introducing 'mm:first-augment' is guarded, though, and this should probably cascade. This feels like another aspect of YANGTOOLS-859.

 

Comment by Robert Varga [ 14/Feb/19 ]

verthezpw would you mind talking to netmod@ietf about perhaps clarifying section 7.17?

Comment by Peter Verthez [ 15/Feb/19 ]

OK, we'll let BBF (Broadband Forum) do this discussion, since this came ultimately from a model that they are standardizing (but working texts are not made public there). I'll keep you informed.

Comment by Peter Verthez [ 15/Feb/19 ]

In the end somebody of our team initiated the netmod discussion, instead of pushing this to BBF. See the following thread:
https://mailarchive.ietf.org/arch/msg/netmod/unhiYU1AWcoFMKzUeTh50h4nrSo

Comment by Peter Verthez [ 19/Feb/19 ]

Reply from the netmod mailing list indicates that this should indeed be allowed:

Re: [netmod] Augmentation with a mandatory leaf in a submodule - Is the following legal?

Robert Wilton <rwilton@cisco.com> Fri, 15 February 2019 10:08 UTC

Hi Yves,

My interpretation of the spirit of the RFC is that this should be
allowed, and I don't think that any text in 7.17 specifically prevents this.

However, this seems like a corner case, and I am also not surprised that
a YANG compiler would fail on this. This issue could perhaps be easily
mitigated by making the second augmentation also conditional on the same
when statement.

Note that the use of sub-modules doesn't really matter, in that a
compiler can treat them as one module. So, I think that the problem is
equivalent to:

module module-a {
  yang-version 1.1;
  namespace "http://www.example.com/anothermodule";
  prefix am;
  container top {
    leaf type {
      type string; mandatory true;
    }
  }
}

 

module module-b {
  yang-version 1.1;
  namespace "http://www.example.com/module-b";
  prefix mm;
  augment '/am:top' {
    when "am:type = 'test'";
    container first-augment {
    }
  }
  augment '/am:top/mm:first-augment' {
    leaf mandatory-leaf {
      type string; mandatory true;
    }
  }
}

Thanks,
Rob

Comment by Robert Varga [ 19/Feb/19 ]

Thanks for confirming, I'll take a look at what we need to do to catch this correctly.

Comment by Peter Verthez [ 25/Jun/19 ]

Hi, what is the timeline for fixing this? We are getting some pressure from device teams on this because this is occurring in a standardized model from Broadband Forum and devices are integrating that. We have provided a workaround (i.e. doing a temporary patch to the YANG model), but still they want to know when ODL will support this so that this workaround would not be needed.

Comment by Robert Varga [ 28/Jun/19 ]

Sorry, I am busy with other parts of the system. There is a candidate patch, but has a relatively-high risk, so it won't be integrated before mid-July, I suspect.

Comment by Peter Verthez [ 28/Jun/19 ]

OK, thanks for the update.

Comment by Robert Varga [ 29/Jul/19 ]

The fix breaks with OFP models and will need to be reworked.

Comment by Robert Varga [ 22/Oct/19 ]

The reason for the failure is that targetCtx.getOriginalCtx() ends up not returning the immediate copy predecessor, but rather the source-level-original definition.

The basic approach is sound, but we need the ability to walk backwards through the copy history.

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