clicon / clixon-controller

Clixon network controller
Apache License 2.0
14 stars 5 forks source link

Device pull from configure only sync running #91

Closed denniswa closed 8 months ago

denniswa commented 8 months ago

Given that If a device config has been altered and controller is not in sync anymore unexpected diffs will be pushed during commit. Ex prefix list was first deleted on device:

dennis@ptx-ac-3# delete policy-options prefix-list a

[edit]
dennis@ptx-ac-3# show |compare
[edit policy-options]
-   prefix-list a {
-       1.1.1.1/32;
-   }

[edit]
dennis@ptx-ac-3# commit

Then another prefix list was added from the controller:

set devices device ptx-ac-3 config configuration policy-options prefix-list abc prefix-list-item 3.3.3.3/32

When trying to commit we detect that the device is not in sync anymore:

snc@snc-lab[/]# commit
Jan  8 15:57:05: transaction_notification_handler: pid: 12902 Transaction 59 failed: Device ptx-ac-3 has changed config. See: diff device-ptx-ac-3-SYNCED_db device-ptx-ac-3-TRANSIENT_db

The we pull config from device and try to commit again

snc@snc-lab[/]# op show devices ptx-ac-3 diff
ptx-ac-3:
      <policy-options xmlns="http://yang.juniper.net/junos/conf/policy-options">
+        <prefix-list>
+           <name>a</name>
+           <prefix-list-item>
+              <name>1.1.1.1/32</name>
+           </prefix-list-item>
+        </prefix-list>
      </policy-options>
snc@snc-lab[/]# op pull
OK
snc@snc-lab[/]# commit diff
ptx-ac-3:
      <policy-options xmlns="http://yang.juniper.net/junos/conf/policy-options">
+        <prefix-list>
+           <name>a</name>
+           <prefix-list-item>
+              <name>1.1.1.1/32</name>
+           </prefix-list-item>
+        </prefix-list>
+        <prefix-list>
+           <name>abc</name>
+           <prefix-list-item>
+              <name>3.3.3.3/32</name>
+           </prefix-list-item>
+        </prefix-list>
      </policy-options>
OK

This would push the deleted prefix-list 'a' back to the device since it was still present in candidate.

denniswa commented 8 months ago

Verified: pull is now not possible if candidate has been modified:

snc@snc-lab[/]# op pull
Jan  9 16:27:58: cli_rpc_pull: 646: XML error: Get configuration: application operation-failed Cannot pull if the candidate datastore is modified
CLI command error