clicon / clixon-controller

Clixon network controller
Apache License 2.0
12 stars 4 forks source link

Backend exited after YANG leafref error #50

Closed krihal closed 8 months ago

krihal commented 8 months ago

CLI:

debian@khn-dev[/]# commit diff
juniper1:
            <group xmlns="http://yang.juniper.net/junos/conf/root">
               <name>test</name>
+              <neighbor>
+                 <name>1.1.1.1</name>
+                 <description>Foo</description>
+                 <import>test-in</import>
+                 <import>test-in</import>
+                 <family>
+                    <inet>
+                       <unicast>
+                          <prefix-limit>
+                             <maximum>10</maximum>
+                             <teardown>
+                                <limit-threshold>20</limit-threshold>
+                                <idle-timeout>
+                                   <timeout>10</timeout>
+                                </idle-timeout>
+                             </teardown>
+                          </prefix-limit>
+                       </unicast>
+                    </inet>
+                 </family>
+                 <peer-as>4444</peer-as>
+              </neighbor>
            </group>
juniper2:
            <group xmlns="http://yang.juniper.net/junos/conf/root">
               <name>test</name>
+              <neighbor>
+                 <name>1.1.1.1</name>
+                 <description>Foo</description>
+                 <import>test-in</import>
+                 <import>test-in</import>
+                 <family>
+                    <inet>
+                       <unicast>
+                          <prefix-limit>
+                             <maximum>10</maximum>
+                             <teardown>
+                                <limit-threshold>20</limit-threshold>
+                                <idle-timeout>
+                                   <timeout>10</timeout>
+                                </idle-timeout>
+                             </teardown>
+                          </prefix-limit>
+                       </unicast>
+                    </inet>
+                 </family>
+                 <peer-as>4444</peer-as>
+              </neighbor>
            </group>
OK
debian@khn-dev[/]# comm
 diff                   local                  push
debian@khn-dev[/]# commit
Transaction 9 failed application bad-element Leafref validation failed: No leaf juniper1 matching path /ctrl:devices/device/name in bgp-peer.yang:145 <bad-element>juniper1</bad-element>
debian@khn-dev[/]#

Backend error:

Oct 19 06:41:23: device_input_cb ret:1
Oct 19 06:41:23: device_state_recv_config
Oct 19 06:41:23: Reading datastore /usr/local/var/controller/device-juniper2-TRANSIENT_db using xml
Oct 19 06:41:23: Send [juniper2]: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"><edit-config><target><candidate/></target><default-operation>none</default-operation><config><configuration xmlns="http://yang.juniper.net/junos/conf/root"><protocols><bgp><group><name>test</name><neighbor nc:operation="merge"><name>1.1.1.1</name><description>Foo</description><import>test-in</import><import>test-in</import><family><inet><unicast><prefix-limit><maximum>10</maximum><teardown><limit-threshold>20</limit-threshold><idle-timeout><timeout>10</timeout></idle-timeout></teardown></prefix-limit></unicast></inet></family><peer-as>4444</peer-as></neighbor></group></bgp></protocols></configuration></config></edit-config></rpc>]]>]]>
Oct 19 06:41:23: device_state_timeout_unregister juniper2
Oct 19 06:41:23: device_handle_conn_state_set juniper2: PUSH-CHECK -> PUSH-EDIT
Oct 19 06:41:23: device_state_timeout_register juniper2
Oct 19 06:41:23: device_state_timeout_register timeout:60 s
Oct 19 06:41:23: Recv from juniper1:
<nc:rpc-reply  xmlns:junos="http://xml.juniper.net/junos/22.3R0/junos"  xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<nc:ok/>
</nc:rpc-reply>

Oct 19 06:41:23: device_input_cb ret:1
Oct 19 06:41:23: device_send_rpc <validate><source><candidate/></source></validate>
Oct 19 06:41:23: Send [juniper1]: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4"><validate><source><candidate/></source></validate></rpc>]]>]]>
Oct 19 06:41:23: device_state_timeout_unregister juniper1
Oct 19 06:41:23: device_handle_conn_state_set juniper1: PUSH-EDIT -> PUSH-VALIDATE
Oct 19 06:41:23: device_state_timeout_register juniper1
Oct 19 06:41:23: device_state_timeout_register timeout:60 s
Oct 19 06:41:23: Recv from juniper2:
<nc:rpc-reply  xmlns:junos="http://xml.juniper.net/junos/22.3R0/junos"  xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<nc:ok/>
</nc:rpc-reply>

Oct 19 06:41:23: device_input_cb ret:1
Oct 19 06:41:23: device_send_rpc <validate><source><candidate/></source></validate>
Oct 19 06:41:23: Send [juniper2]: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4"><validate><source><candidate/></source></validate></rpc>]]>]]>
Oct 19 06:41:23: device_state_timeout_unregister juniper2
Oct 19 06:41:23: device_handle_conn_state_set juniper2: PUSH-EDIT -> PUSH-VALIDATE
Oct 19 06:41:23: device_state_timeout_register juniper2
Oct 19 06:41:23: device_state_timeout_register timeout:60 s
Oct 19 06:41:23: Recv from juniper2:
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.3R0/junos"  message-id="4">
 * Reloading keepalived configuration......
   ...done.
<nc:ok/>
</nc:rpc-reply>

Oct 19 06:41:23: device_input_cb ret:1
Oct 19 06:41:23: device_state_timeout_unregister juniper2
Oct 19 06:41:23: device_handle_conn_state_set juniper2: PUSH-VALIDATE -> PUSH-WAIT
Oct 19 06:41:23: device_state_timeout_register juniper2
Oct 19 06:41:23: device_state_timeout_register timeout:60 s
Oct 19 06:41:24: Recv from juniper1:
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.3R0/junos"  message-id="4">
 * Reloading keepalived configuration......
   ...fail!
<nc:ok/>
</nc:rpc-reply>

Oct 19 06:41:24: device_input_cb ret:1
Oct 19 06:41:24: device_state_timeout_unregister juniper1
Oct 19 06:41:24: device_handle_conn_state_set juniper1: PUSH-VALIDATE -> PUSH-WAIT
Oct 19 06:41:24: device_state_timeout_register juniper1
Oct 19 06:41:24: device_state_timeout_register timeout:60 s
Oct 19 06:41:24: device_send_rpc <commit/>
Oct 19 06:41:24: Send [juniper1]: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="5"><commit/></rpc>]]>]]>
Oct 19 06:41:24: device_state_timeout_unregister juniper1
Oct 19 06:41:24: device_handle_conn_state_set juniper1: PUSH-WAIT -> PUSH-COMMIT
Oct 19 06:41:24: device_state_timeout_register juniper1
Oct 19 06:41:24: device_state_timeout_register timeout:60 s
Oct 19 06:41:24: device_send_rpc <commit/>
Oct 19 06:41:24: Send [juniper2]: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="5"><commit/></rpc>]]>]]>
Oct 19 06:41:24: device_state_timeout_unregister juniper2
Oct 19 06:41:24: device_handle_conn_state_set juniper2: PUSH-WAIT -> PUSH-COMMIT
Oct 19 06:41:24: device_state_timeout_register juniper2
Oct 19 06:41:24: device_state_timeout_register timeout:60 s
Oct 19 06:41:24: xmldb_copy actions candidate
Oct 19 06:41:24: controller_transaction_failed
Oct 19 06:41:24: controller_transaction_state_set 9 : INIT -> RESOLVED result: FAILED
Oct 19 06:41:24: controller_transaction_notify 9
Oct 19 06:41:24: ce_event_cb op:0
Oct 19 06:41:24: Send: <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>2023-10-19T06:41:24.027596Z</eventTime><controller-transaction xmlns="http://clicon.org/controller"><tid>9</tid><result>FAILED</result><origin>juniper1</origin><reason>application bad-element Leafref validation failed: No leaf juniper1 matching path /ctrl:devices/device/name in bgp-peer.yang:145 &lt;bad-element&gt;juniper1&lt;/bad-element&gt;</reason></controller-transaction></notification>
Oct 19 06:41:24: ce_event_cb op:0
Oct 19 06:41:24: Send: <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>2023-10-19T06:41:24.027596Z</eventTime><controller-transaction xmlns="http://clicon.org/controller"><tid>9</tid><result>FAILED</result><origin>juniper1</origin><reason>application bad-element Leafref validation failed: No leaf juniper1 matching path /ctrl:devices/device/name in bgp-peer.yang:145 &lt;bad-element&gt;juniper1&lt;/bad-element&gt;</reason></controller-transaction></notification>
Oct 19 06:41:24: controller_transaction_failed retval:0
Oct 19 06:41:24: Recv from juniper2:
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.3R0/junos"  message-id="5">
 * Reloading keepalived configuration......
   ...done.
<nc:ok/>
</nc:rpc-reply>

Oct 19 06:41:24: device_input_cb ret:1
Oct 19 06:41:24: device_state_timeout_unregister juniper2
Oct 19 06:41:24: device_handle_conn_state_set juniper2: PUSH-COMMIT -> OPEN
Oct 19 06:41:24: Reading datastore /usr/local/var/controller/device-juniper2-SYNCED_db using xml
clixon_backend: controller_transaction.c:133: controller_transaction_state_set: Assertion `state != ct->ct_state' failed.
Aborted
debian@khn-dev:~$
olofhagsand commented 8 months ago

Due to the following log line:

Oct 19 06:41:24: device_handle_conn_state_set juniper2: PUSH-WAIT -> PUSH-COMMIT

It could have been fixed by https://github.com/clicon/clixon-controller/issues/47 since it fixed a similar issue. Can you please try to see if it remains?

krihal commented 8 months ago

Seems to survive:

debian@khn-dev[/]# commit diff
Nov  5 12:39:49: Get configuration: application bad-element Leafref validation failed: No leaf test as-number 1111 matching path /ctrl:services/foo:properties/bgp:bgp-peer/bgp:exchange-points/bgp:name in bgp-peer.yang:67 <bad-element>test as-number 1111</bad-element>
debian@khn-dev[/]#