Hi,
I am currently looking at migrating my Edgecore/Broadcom-based network from Cumulus to SONiC. While attempting to migrate my Cumulus's /etc/network/interfaces templates to SONiC's config_db.json, I noticed that elements that are removed from config_db.json are not removed from the actual running configuration, as shown in the example below. This behaviour fundamentally breaks with a template-based automation workflow based on pushing the complete new configuration and reloading. Absence of an element in the pushed config means that element should not appear in the running configuration after the reload.
Is this the intentional behaviour, and if so, is there some other way to accomplish template-based automation short of having to reboot the switch completely after each configuration change?
The below example demonstrates the issue. It was performed on an Edgecore AS5812-54X running SONiC.Edgecore-SONiC_20210917_063104_ec202012_172. The starting point is a switch with the factory default configuration, without any VLANs configured. This config I save to config_db.json:
sonic$ show vlan brief
+-----------+--------------+---------+----------------+-----------------------+-------------+
| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP |
+===========+==============+=========+================+=======================+=============+
+-----------+--------------+---------+----------------+-----------------------+-------------+
sonic$ sudo config save -y
Running command: /usr/local/bin/sonic-cfggen -d --print-data > /etc/sonic/config_db.json
Next, I add a VLAN using the CLI. As expected, it shows up in the running configuration (which I do not save to config_db.json). So far so good:
sonic$ sudo config vlan add 1234
sonic$ show vlan brief
+-----------+--------------+---------+----------------+-----------------------+-------------+
| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP |
+===========+==============+=========+================+=======================+=============+
| 1234 | | | | | disabled |
+-----------+--------------+---------+----------------+-----------------------+-------------+
sonic$ diff -u /etc/sonic/config_db.json <(show runningconfig all)
--- /etc/sonic/config_db.json 2021-12-08 15:02:19.332205549 +0100
+++ /dev/fd/63 2021-12-08 15:02:37.169647768 +0100
@@ -897,6 +897,11 @@
"VERSION": "version_2_0_1"
}
},
+ "VLAN": {
+ "Vlan1234": {
+ "vlanid": "1234"
+ }
+ },
"ZTP": {
"mode": {
"inband": "true",
Next I attempt to roll back to the previous configuration using «config load» (remember that config_db.json does not contain any VLANs):
sonic$ sudo config load -y
Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
However, unexpectedly, VLAN 1234 remains present on the switch:
sonic$ show vlan brief
+-----------+--------------+---------+----------------+-----------------------+-------------+
| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP |
+===========+==============+=========+================+=======================+=============+
| 1234 | | | | | disabled |
+-----------+--------------+---------+----------------+-----------------------+-------------+
sonic$ diff -u /etc/sonic/config_db.json <(show runningconfig all)
--- /etc/sonic/config_db.json 2021-12-08 15:02:54.094344724 +0100
+++ /dev/fd/63 2021-12-08 15:02:58.881650902 +0100
@@ -897,6 +897,11 @@
"VERSION": "version_2_0_1"
}
},
+ "VLAN": {
+ "Vlan1234": {
+ "vlanid": "1234"
+ }
+ },
"ZTP": {
"mode": {
"inband": "true",
$ ip link show dev Vlan1234
66: Vlan1234@Bridge: <BROADCAST,MULTICAST> mtu 9100 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether a8:2b:b5:28:db:08 brd ff:ff:ff:ff:ff:ff
This behaviour is not limited to VLANs, it seems to apply to many different kinds of elements/resources found in config_db.json (perhaps all).
Tore