Description

A HA deployment of Contrail requires at least two control nodes, three config nodes (including analytics and webui) and three database nodes.

The protocol between the Contrail SDN Controller and the Contrail vRouters is based on XMPP.
The Contrail controller exchange routes with the vRouter agents on the compute nodes using XMPP. They also use XMPP to send configuration state such as routing instances and forwarding policy. 

Each vRouter agent connects to two or more control nodes where all control nodes are in active/active state. The vRouter agent receives all its state (routes, routing instance configuration, etc.) from each of the control nodes.

The vrouter makes a local determination about which copy of the control state to use.

This article explains how to check the active controller wrt a compute node where vrouter is running.

Solution

To find out which is the active controller wrt a voruter agent, use the following introspect:

  • Run the curl command below from the compute node.
  • The introspect will show the controllers to which the vrouter is connected to.
  • From the output below, there is "controller_ip identifier" which is the controller IPs.
root@CFTSBM5CMP:~# curl http://127.0.0.1:8085/Snh_AgentXmppConnectionStatusReq | python -c "import sys;import xml.dom.minidom;s=sys.stdin.read();print xml.dom.minidom.parseString(s).toprettyxml()"



<AgentXmppConnectionStatus type="sandesh">
        <peer identifier="1" type="list">
                <list size="2" type="struct">
                        <AgentXmppData>
                                <controller_ip identifier="1" type="string">192.168.10.134
                                <state identifier="2" type="string">Established
                                <peer_name identifier="3" type="string">[email protected]
                                <peer_address identifier="4" type="string">192.168.10.134:5269
                                <cfg_controller identifier="5" type="string">Yes
                                <mcast_controller identifier="6" type="string">Yes
                                <last_state identifier="7" type="string">OpenSent
                                <last_event identifier="8" type="string">xmsm::EvXmppKeepalive
                                <last_state_at identifier="9" type="string">2020-Jul-28 05:53:07.491759
                                <flap_count identifier="10" type="u32">0
                                <flap_time identifier="11" type="string"/>
                                <rx_proto_stats identifier="12" type="struct">
                                        <ControllerProtoStats>
                                                <open identifier="1" type="u32">1
                                                <keepalive identifier="2" type="u32">37527
                                                <update identifier="3" type="u32">10
                                                <close identifier="4" type="u32">0
                                        
                                
                                <tx_proto_stats identifier="13" type="struct">
                                        <ControllerProtoStats>
                                                <open identifier="1" type="u32">1
                                                <keepalive identifier="2" type="u32">37512
                                                <update identifier="3" type="u32">14
                                                <close identifier="4" type="u32">0
                                        
                                
                                <xmpp_auth_type identifier="14" type="string">NIL
                        
                        <AgentXmppData>
                                <controller_ip identifier="1" type="string">192.168.10.133
                                <state identifier="2" type="string">Established
                                <peer_name identifier="3" type="string">[email protected]
                                <peer_address identifier="4" type="string">192.168.10.133:5269
                                <cfg_controller identifier="5" type="string">No
                                <mcast_controller identifier="6" type="string">No
                                <last_state identifier="7" type="string">OpenSent
                                <last_event identifier="8" type="string">xmsm::EvXmppKeepalive
                                <last_state_at identifier="9" type="string">2020-Jul-28 05:53:07.503310
                                <flap_count identifier="10" type="u32">0
                                <flap_time identifier="11" type="string"/>
                                <rx_proto_stats identifier="12" type="struct">
                                        <ControllerProtoStats>
                                                <open identifier="1" type="u32">1
                                                <keepalive identifier="2" type="u32">37519
                                                <update identifier="3" type="u32">4
                                                <close identifier="4" type="u32">0
                                        
                                
                                <tx_proto_stats identifier="13" type="struct">
                                        <ControllerProtoStats>
                                                <open identifier="1" type="u32">1
                                                <keepalive identifier="2" type="u32">37512
                                                <update identifier="3" type="u32">10
                                                <close identifier="4" type="u32">0
                                        
                                
                                <xmpp_auth_type identifier="14" type="string">NIL
                        
                
        
        <more identifier="0" type="bool">false

In the output above, look for variable "cfg_controller identifier". If it is "Yes" as shown below, that controller will be the active one . 

For controller 1:

<controller_ip identifier="1" type="string">192.168.10.134
<cfg_controller identifier="5" type="string">Yes

For controller 2 :- <output Snip>
<controller_ip identifier="1" type="string">192.168.10.133
<cfg_controller identifier="5" type="string">No

So controller 1 is the active controller for this vrouter node.