Skip to content

Commit a76f5e4

Browse files
author
jojimt
committed
Rework the fix to read current state and watch the next index Use EtcdIndex for watching
1 parent e5da2b7 commit a76f5e4

File tree

2 files changed

+50
-67
lines changed

2 files changed

+50
-67
lines changed

Godeps/_workspace/src/github.com/contiv/objdb/etcdService.go

+45-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netplugin/cluster/cluster.go

+5-57
Original file line numberDiff line numberDiff line change
@@ -148,68 +148,16 @@ func peerDiscoveryLoop(netplugin *plugin.NetPlugin, objdbClient objdb.API, local
148148
masterEventCh := make(chan objdb.WatchServiceEvent, 1)
149149
masterWatchStopCh := make(chan bool, 1)
150150

151-
// Start a watch on netplugin service so that we dont miss any
152-
err := objdbClient.WatchService("netplugin", nodeEventCh, watchStopCh)
153-
if err != nil {
154-
log.Fatalf("Could not start a watch on netplugin service. Err: %v", err)
155-
}
156-
157-
// Start a watch on netmaster too
158-
err = objdbClient.WatchService("netmaster", masterEventCh, masterWatchStopCh)
151+
// Start a watch on netmaster
152+
err := objdbClient.WatchService("netmaster", masterEventCh, masterWatchStopCh)
159153
if err != nil {
160154
log.Fatalf("Could not start a watch on netmaster service. Err: %v", err)
161155
}
162156

163-
// Get a list of all existing netplugin nodes
164-
nodeList, err := objdbClient.GetService("netplugin")
165-
if err != nil {
166-
log.Errorf("Error getting node list from objdb. Err: %v", err)
167-
}
168-
169-
log.Infof("Got netplugin service list: %+v", nodeList)
170-
171-
// walk each node and add it as a PeerHost
172-
for _, node := range nodeList {
173-
// Ignore if its our own info
174-
if node.HostAddr == localIP {
175-
continue
176-
}
177-
// add the node
178-
err := netplugin.AddPeerHost(core.ServiceInfo{
179-
HostAddr: node.HostAddr,
180-
Port: ofnet.OFNET_AGENT_VXLAN_PORT,
181-
})
182-
if err != nil {
183-
log.Errorf("Error adding node {%+v}. Err: %v", node, err)
184-
}
185-
// add the node
186-
err = netplugin.AddPeerHost(core.ServiceInfo{
187-
HostAddr: node.HostAddr,
188-
Port: ofnet.OFNET_AGENT_VLAN_PORT,
189-
})
190-
if err != nil {
191-
log.Errorf("Error adding node {%+v}. Err: %v", node, err)
192-
}
193-
}
194-
195-
// Get a list of all existing netmasters
196-
masterList, err := objdbClient.GetService("netmaster")
157+
// Start a watch on netplugin service so that we dont miss any
158+
err = objdbClient.WatchService("netplugin", nodeEventCh, watchStopCh)
197159
if err != nil {
198-
log.Errorf("Error getting master list from objdb. Err: %v", err)
199-
}
200-
201-
log.Infof("Got netmaster service list: %+v", masterList)
202-
203-
// Walk each master and add it
204-
for _, master := range masterList {
205-
// Add the master
206-
err := addMaster(netplugin, core.ServiceInfo{
207-
HostAddr: master.HostAddr,
208-
Port: ofnet.OFNET_MASTER_PORT,
209-
})
210-
if err != nil {
211-
log.Errorf("Error adding master {%+v}. Err: %v", master, err)
212-
}
160+
log.Fatalf("Could not start a watch on netplugin service. Err: %v", err)
213161
}
214162

215163
for {

0 commit comments

Comments
 (0)