Re: [yang-doctors] YANG dialects?

Jan Lindblad <janl@tail-f.com> Fri, 20 December 2019 10:07 UTC

Return-Path: <janl@tail-f.com>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 2F0BE120839 for <yang-doctors@ietfa.amsl.com>; Fri, 20 Dec 2019 02:07:10 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
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 Nmy8CJjY_oHH for <yang-doctors@ietfa.amsl.com>; Fri, 20 Dec 2019 02:07:08 -0800 (PST)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id 3BE24120865 for <yang-doctors@ietf.org>; Fri, 20 Dec 2019 02:07:08 -0800 (PST)
Received: from [10.147.40.109] (unknown [173.38.220.35]) by mail.tail-f.com (Postfix) with ESMTPSA id 584FF1AE0336; Fri, 20 Dec 2019 11:07:04 +0100 (CET)
From: Jan Lindblad <janl@tail-f.com>
Message-Id: <18F4705E-7ECC-4698-8787-5604CDA8ED79@tail-f.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_9FE10F7A-F8FD-43E4-A19D-4EDB697D2315"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\))
Date: Fri, 20 Dec 2019 11:07:02 +0100
In-Reply-To: <1b398c323c72edc5970e90af06b70226b6eed755.camel@nic.cz>
Cc: yang-doctors@ietf.org
To: Ladislav Lhotka <lhotka@nic.cz>
References: <CABCOCHTB+V6sV8hRcAC+OfseBBN=jUQnHQxzEVB_1drWhaEVXg@mail.gmail.com> <20191218.220130.545256750871048075.mbj@tail-f.com> <CABCOCHRfNrz+cNMA8ciRYGEM-7aR=S2NYJzU-t8JQ620Zs=hvQ@mail.gmail.com> <20191219.090708.1031388562992503497.mbj@tail-f.com> <MN2PR11MB4366F797234C963E23734BA1B5520@MN2PR11MB4366.namprd11.prod.outlook.com> <6684E0F3-DC49-4E94-B4FB-1109662F394D@tail-f.com> <1b398c323c72edc5970e90af06b70226b6eed755.camel@nic.cz>
X-Mailer: Apple Mail (2.3445.104.11)
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/EG8HeTNswxLhDDMiINrGV-zLi-U>
Subject: Re: [yang-doctors] YANG dialects?
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 20 Dec 2019 10:07:10 -0000

Lada,

>>>> o  extension: An extension attaches non-YANG semantics to statements.
>>>> 
>>>> This is not the case here, it is only syntactically compatible. If tool A
>>>> says that some instance data is valid, but tool B says it isn't, then the
>>>> standard is gone.
>>>> 
>>>> Lada
>> 
>> Of course it would be legal. It's always legal for a NETCONF server to reject
>> an edit-config for no apparent reason (from a YANG perspective), so all device
>> YANG models would still be legal if all pattern statements were removed, but
>> the same string pattern constraints still enforced by the devices. The OC
>> group could therefore remove their pattern statements and introduce a YANG
>> extension oc:posix-pattern (or oc:go-pattern, or whatever) that gives a hint
>> to some clients what is expected. The clients that don't understand this
>> extension would just se a rejection for no apparent reason (from a YANG
>> perspective).
> 
> I strongly disagree. Why then do we have so much text about constraints,
> validity etc. in RFC 7950? The benefit of schema validation is that an
> implementation can rely on an external validator and needn't clutter the code
> with all kinds of input data checks. But if the validation result depends on
> whether I choose library A or B, this concept simply falls apart.
> 
> Lada

I completely agree that the device interface behavior should be exposed with much detail in the corresponding YANG.

Practically, however, I don't think it is reasonable to expect that every little rule of the implementation is exposed. YANG isn't expressive enough to cover everything. And actually, there are sometimes cases where I advise not to add as many constraints into the model as technically possible by the YANG language. Half-a-page long XPath expressions may detract sharply from readability, performance and universality. Implementation details may start to leak into the interface.

There are also operational aspects to consider, such as a device running out of memory at some point. A client therefore has to be prepared that an edit-config may be refused for no apparent reason. There is no text in the RFC stating that the YANG constraints in a module must be complete, even if I regard that as a goal. One reason UML models tend to be useless as interface descriptions in practice is that they lack these constraints.

YANG extensions are a practical way to introduce validation concepts not feasible to express with YANG and XPath. Here are some examples:
+ Constraints on compatible colors in an optical YANG model (Not expressive enough)
+ Constraints on configured paths being disjunct (Not computationally efficient)
+ Constraints on an interface being unused by all other services (Not universally reusable [layer violation] if service YANG depends on device YANG)

In these cases it may not be possible or desirable to express the constraints in YANG/XPath. It may be possible express the constraint using domain specific extension keywords, which should be better than not expressing it at all. Clients that do not understand the added keywords would still work as long as the configurations generated are valid. Clients with domain understanding, possibly including understanding of the extension keywords, have a better chance at generating valid configurations.

/jan