Re: [netmod] evaluation of "when" under NMDA

Ladislav Lhotka <lhotka@nic.cz> Tue, 05 December 2017 09:45 UTC

Return-Path: <lhotka@nic.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B9C331275FD for <netmod@ietfa.amsl.com>; Tue, 5 Dec 2017 01:45:55 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.999
X-Spam-Level:
X-Spam-Status: No, score=-6.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nic.cz
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nt-nSHEOoH05 for <netmod@ietfa.amsl.com>; Tue, 5 Dec 2017 01:45:52 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 604A1124205 for <netmod@ietf.org>; Tue, 5 Dec 2017 01:45:52 -0800 (PST)
Received: from birdie (unknown [IPv6:2001:1488:fffe:6:1f99:257b:62cc:c0d5]) by mail.nic.cz (Postfix) with ESMTPSA id C3B2E63826; Tue, 5 Dec 2017 10:45:49 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1512467149; bh=9bqUXL3g44Z2fwh6ndMfteq4oiihhMGCUeSur2ZB19c=; h=From:To:Date; b=Sb0pRvF8udZuVbOIbIPCEVARYsN/4qfTMGE0HzoA/rsBnHzS5rqmqrIZejaZba1Cs clWeAysnAxZ6ysCXXkBZaRsdv8De+/YryTOq6lHySrguYCTVpqWCaaG+2Kj+yN1YZE P1uQAnzjCQgWIdTcCh8mYSyQrhTEmfOCP0jWy2JI=
Message-ID: <1512467149.7827.39.camel@nic.cz>
From: Ladislav Lhotka <lhotka@nic.cz>
To: Robert Wilton <rwilton@cisco.com>, NETMOD WG <netmod@ietf.org>
Date: Tue, 05 Dec 2017 10:45:49 +0100
In-Reply-To: <bf1cb7ba-7a01-2962-3a36-f139dc06cbd3@cisco.com>
References: <1512404811.1422.63.camel@nic.cz> <20171204.173431.1294203680272812703.mbj@tail-f.com> <1512407158.6635.8.camel@nic.cz> <bf1cb7ba-7a01-2962-3a36-f139dc06cbd3@cisco.com>
Organization: CZ.NIC
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.26.2
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: clamav-milter 0.99.2 at mail
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/FW-1-j-G3Yi-pZLyvlANDcK9c5M>
Subject: Re: [netmod] evaluation of "when" under NMDA
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 05 Dec 2017 09:45:56 -0000

On Mon, 2017-12-04 at 17:29 +0000, Robert Wilton wrote:
> Hi Lada,
> 
> 
> On 04/12/2017 17:05, Ladislav Lhotka wrote:
> > On Mon, 2017-12-04 at 17:34 +0100, Martin Bjorklund wrote:
> > > Ladislav Lhotka <lhotka@nic.cz> wrote:
> > > > Hi,
> > > > 
> > > > if we have
> > > > 
> > > > augment "/target/node" {
> > > >    when "...";
> > > >    ...
> > > > }
> > > > 
> > > > is the "when" expression supposed to be evaluated separately in each
> > > 
> > > datastore,
> > > > and the augment applied only in those datastores where the result is
> > > > true?
> > > 
> > > Yes.
> > 
> > But then it cannot be guaranteed that the schema for <operational> is a
> > superset
> > of the schema of configuration datastores - the when expression can evaluate
> > to
> > false in <operational> but true in <intended>.
> 
> I think that comes down to terminology, RFC 7950 section 7.21.5 on when 
> statements just talks about making data definition statements 
> conditional.  I don't really think that when statements (or choice 
> statements) change the schema associated with a datastore, they just 
> make parts of it inactive based on the current data.  I.e. you wouldn't 
> expect different information to be returned via YANG library depending 
> on how particular when statements in the implemented modules get evaluated.
> 
> Is seems to me that the when processing falls out quite naturally. Is 
> there a scenario where you think that this could cause a problem?

IMO it comes down to the distinction between syntactic (schema) and semantic
constraints. An important syntactic constraint for a container are the children
that a container instance (i) must, and (ii) may contain. Whenever "when" comes
into play, this cannot be determined upfront, we first have to see a particular
(complete) data tree and evaluate an XPath expression on it.

It may seem that this is an academic issue and that the borderline between
syntactic and semantic constraints is arbitrary, but it isn't: it is determined
by the need for having a robust and efficient algorithm for syntactic analysis.
Such an algorithm exists for regular and context-free grammars, as well as for
XSD and RELAX NG, but not for YANG.

As for problems caused by "when", it is by far the trickiest part in YANG and
most complicated implementation-wise. 

Lada 

> 
> Thanks,
> Rob
> 
> > 
> > Lada
> > 
> > > > RFC 7950 says in sec. 7.21.5 that the context node for XPath evaluation
> > > > is
> > > 
> > > "the
> > > > augment's target node in the data tree", but with NMDA we have multiple
> > > > data
> > > > trees, hence multiple target nodes.
> > > 
> > > We had multiple datastores even before NMDA.  The when expression
> > > could be true in candidate but false in running.
> > > 
> > > /martin
> 
> 
-- 
Ladislav Lhotka
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67