Skip to content

Commit a944409

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

File tree

2 files changed

+49
-58
lines changed

2 files changed

+49
-58
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

+4-48
Original file line numberDiff line numberDiff line change
@@ -148,60 +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-
157151
// Start a watch on netmaster too
158-
err = objdbClient.WatchService("netmaster", masterEventCh, masterWatchStopCh)
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_PORT,
181-
})
182-
if err != nil {
183-
log.Errorf("Error adding node {%+v}. Err: %v", node, err)
184-
}
185-
}
186-
187-
// Get a list of all existing netmasters
188-
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)
189159
if err != nil {
190-
log.Errorf("Error getting master list from objdb. Err: %v", err)
191-
}
192-
193-
log.Infof("Got netmaster service list: %+v", masterList)
194-
195-
// Walk each master and add it
196-
for _, master := range masterList {
197-
// Add the master
198-
err := addMaster(netplugin, core.ServiceInfo{
199-
HostAddr: master.HostAddr,
200-
Port: ofnet.OFNET_MASTER_PORT,
201-
})
202-
if err != nil {
203-
log.Errorf("Error adding master {%+v}. Err: %v", master, err)
204-
}
160+
log.Fatalf("Could not start a watch on netplugin service. Err: %v", err)
205161
}
206162

207163
for {

0 commit comments

Comments
 (0)