Page MenuHomeVyOS Platform

Add support for the old tag node syntax to the curly config parser
Closed, ResolvedPublic

Description

The "old syntax" for tag nodes is "ethernet eth0 { ...}". The "new syntax" is "ethernet { eth0 { ... } }".

In V3, the majority of people voted for the new syntax, while a minority provided rather strong arguments for supporting the old one. Initially I thought not supporting the old syntax will let me not to write certain code, but later I've found an edge case that requires essentially the same code as support for the old syntax:

interfaces {
  ethernet {
    eth0 {
      ...
    }
  }
  ethernet {
    eth1 {
...

The "ethernet" node is duplicated. While this is somewhat pathological, this kind of config is possible to produce by careless pasting, or by generating it automatically. And, logically, it's valid, even if unusual. The most sensible strategy, as of me, is to merge these nodes after parsing. We could as well produce an error, but it still requires recognizing this case. Since there exists a unique unambiguous mapping to the "normal form" where all children are under a single node, there isn't much point in throwing an error instead of normalizing it.

Note that tag nodes still can be written in the new syntax as well as the old one, since the old syntax is a strict superset of the new one, and at the parsing stage vyconf doesn't and must not care if somethinng should be a tag node, since if it does, we will not be able to use the same parser for writing migration scripts that by definition have to work with configs that are not valid for the VyOS version they run on.

Details

Difficulty level
Normal (likely a few hours)

Related Objects