Preserving, instead of deleting, CDB nodes upon schema change

In Chapter 5 of the ConfD User Guide, the last few sections describe how data in the CDB can be upgraded when the schema changes. There are simple upgrades such as type coercions, adds/deletes, etc. And there is also a way to run handlers in Phase 0 that allow us to write code to do more complex data transformations upon upgrade. All that is understood.

My question is about how we can save data in the CDB when the data are associated with new nodes, in an upgrade–>downgrade–>upgrade scenario.

Let’s say we have version 1 of product that has schema A containing node X. Then we have version 2 of product that has schema A’ containing nodes X and Y. The yang has this minor change, of the addition of Y.

If a customer running version 2 has data in X and Y, then downgrades to version 1, the value in Y is lost. This is described in the documentation.
So when they upgrade back to version 2, it is still lost.

What I am asking for is, can we have an option to not lose the contents when nodes are deleted, but rather just “ghost” them, so that they will still remain there, unused, until such a time as they return to a schema which contains that node?

I think this would be a common enough scenario for many products, where a customer has a complex configuration in version 2 of product, but needs to temporarily downgrade for whatever reason to version 1, and then re-upgrade to version 2-- without losing all of the values for nodes that were only in version 2.

Use for example cdb_get_phase() when in start-phase 0:

$ confd -c ./confd.conf --start-phase0 
$ confd_cmd -d -d -c get_phase
TRACE Connected (cdb) to ConfD
phase: 0 flags: 0x2 UPGRADE

Now you know that an upgrade will take place and that the upgrade transaction will modify the data in start-phase 1, so here you can for example save the old data if you wish.
See more in in ConfD 6.3 UG chapter 5.9–5.12.

1 Like