Support Support Downloads Knowledge Base Juniper Support Portal Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[Contrail] How Zookeeper ephemeral node is used



Article ID: KB35228 KB Last Updated: 16 Nov 2019Version: 2.0

This articles introduces how Contrail services use ephemeral nodes in Zookeeper. 


When device-manager, svc-monitor and schema connect to Zookeeper, they create an ephemeral node for itself to represent these services. One important property of ephemeral node is that it is removed automatically once the session is down.


At the beginning, we enter Zookeeper CLI and see one ephemeral znode created for svc-monitor:

# /usr/share/zookeeper/bin/
Connecting to localhost:2181
[zk: localhost:2181(CONNECTED) 1] ls /svc-monitor
[zk: localhost:2181(CONNECTED) 2] get /svc-monitor/833db70d0d674dc2b2c05d7e9016e2c8__lock__0000000008
cZxid = 0x59b
ctime = Tue Oct 29 13:45:59 PDT 2019
mZxid = 0x59b
mtime = Tue Oct 29 13:45:59 PDT 2019
pZxid = 0x59b
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x16e18e9152f0031
dataLength = 5
numChildren = 0

If we stop svc-monitor service, this node is removed automatically:

# service contrail-svc-monitor stop
contrail-svc-monitor: stopped

[zk: localhost:2181(CONNECTED) 3] ls /svc-monitor
[zk: localhost:2181(CONNECTED) 4] get /svc-monitor/833db70d0d674dc2b2c05d7e9016e2c8__lock__0000000008
Node does not exist: /svc-monitor/833db70d0d674dc2b2c05d7e9016e2c8__lock__0000000008

This property is very useful when electing active svc-monitor/schema/device-manager because these services can only have one instance running as an active one. The others should stay as backup. To coordinate these instances, they need to register an ephemeral znode. After one of them acquires the lock, it becomes active. Once the active one fails for any reason, it will lose the connection to Zookeeper. Thus, Zookeeper knows the session has timed out and removes the ephemeral node. Other sessions which set watch on ephemeral znode will get notification and retry acquiring the lock. So ephemeral znode is very important for election and failover of specific Contrail services.  

For more on ZooKeeper refer to KB31144 - Contrail Getting Started - Administration, Configuration & Troubleshooting (JumpStation)

Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search