clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
206 stars 69 forks source link

Problems with diff of YANG lists ordered-by user #496

Closed olofhagsand closed 3 months ago

olofhagsand commented 5 months ago

This issue may be specific to the clixon controller where the synch of multiple datastores is made, but may also appear in other circumstances, such as a local ACL list.

Consider a YANG ordered-by user list, eg:

list xlist {
  key x;
  leaf x { type string; }
  ordered-by user;
}

The problem occurs if you do iterative changes to this list, eg:

  1. add <x>2</x>
  2. add <x>1</x>

Suppose in the second case that you enter <x>1</x> first in the list, either using "insert before" or by rewriting the whole list, resulting in a candidate datastore:

<x>1</x>
<x>2</x>

Then the clixon diff algorithm (show diff) will show:

+ <x>1</x>

A backend may then send this new entry to a target (eg device driver/ remote device or some other system) to add/append to the list of existing entries, resulting in a list:

<x>2</x>
<x>1</x>  <--- New entry

But there has also been a reorder, what actually happened is that the entry was not only added but also inserted before the existing entry. Therefore, a correct action of the diff algorithm would be to detect out-of-order elements. Or to replace the whole list with the new element order.

A sub-part of this problem was fixed in: https://github.com/clicon/clixon/issues/475