Skip to content

Commit 50db1d7

Browse files
committed
updating l3 sanity fix
1 parent 767e939 commit 50db1d7

File tree

7 files changed

+133
-61
lines changed

7 files changed

+133
-61
lines changed

netmaster/daemon.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,16 @@ func (d *daemon) runLeader() {
256256
// Create a new api controller
257257
d.apiController = objApi.NewAPIController(router, d.clusterStore)
258258

259+
//Restore state from clusterStore
260+
261+
d.restoreCache()
262+
259263
// Register netmaster service
260264
d.registerService()
261265

262266
// initialize policy manager
263267
mastercfg.InitPolicyMgr(d.stateDriver, d.ofnetMaster)
264268

265-
d.restoreCache()
266-
267269
// setup HTTP routes
268270
d.registerRoutes(router)
269271

netmaster/master/api.go

+3
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ func ServiceProviderUpdateHandler(w http.ResponseWriter, r *http.Request, vars m
422422
}
423423

424424
provider := mastercfg.ProviderDb[providerDbID]
425+
if provider == nil {
426+
log.Errorf("Provider not present in Provider DB. Invalid state")
427+
}
425428
for _, serviceID := range provider.Services {
426429
service := mastercfg.ServiceLBDb[serviceID]
427430
providerID := getProviderID(provider)

netmaster/master/servicelb.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ func RestoreServiceProviderLBDb() {
225225
mastercfg.ProviderDb[providerDBId] = providerInfo
226226
}
227227
}
228+
} else {
229+
log.Errorf("Error reading service load balancer state from cluster store")
228230
}
229231
//Recover from endpoint state as well .
230232
epCfgState := mastercfg.CfgEndpointState{}
@@ -233,21 +235,23 @@ func RestoreServiceProviderLBDb() {
233235
if err == nil {
234236
for _, epCfg := range epCfgs {
235237
ep := epCfg.(*mastercfg.CfgEndpointState)
236-
if ep.Labels != nil {
238+
providerDBId := ep.ContainerID
239+
if ep.Labels != nil && mastercfg.ProviderDb[providerDBId] == nil {
237240
//Create provider info and store it in provider db
238241
providerInfo := &mastercfg.Provider{}
239242
providerInfo.ContainerID = ep.ContainerID
240243
providerInfo.Network = strings.Split(ep.NetID, ".")[0]
241244
providerInfo.Tenant = strings.Split(ep.NetID, ".")[1]
242245
providerInfo.Labels = make(map[string]string)
246+
providerInfo.IPAddress = ep.IPAddress
243247

244248
for k, v := range ep.Labels {
245249
providerInfo.Labels[k] = v
246250
}
247-
providerDBId := providerInfo.ContainerID
248251
mastercfg.ProviderDb[providerDBId] = providerInfo
249-
250252
}
251253
}
254+
} else {
255+
log.Errorf("Error reading endpoint config during restore")
252256
}
253257
}

systemtests/basic_test.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ func (s *systemtestSuite) testBasicStartRemoveContainer(c *C, encap string) {
3838
c.Assert(err, IsNil)
3939

4040
if s.fwdMode == "routing" && encap == "vlan" {
41-
s.CheckBgpRouteDistribution(c, s.vagrant.GetNode("quagga1"), containers)
41+
var err error
42+
_, err = s.CheckBgpRouteDistribution(c, containers)
43+
c.Assert(err, IsNil)
4244
}
4345

4446
c.Assert(s.pingTest(containers), IsNil)
@@ -73,7 +75,9 @@ func (s *systemtestSuite) testBasicStartStopContainer(c *C, encap string) {
7375
containers, err := s.runContainers(s.containers, false, "private", nil, nil)
7476
c.Assert(err, IsNil)
7577
if s.fwdMode == "routing" && encap == "vlan" {
76-
s.CheckBgpRouteDistribution(c, s.vagrant.GetNode("quagga1"), containers)
78+
var err error
79+
_, err = s.CheckBgpRouteDistribution(c, containers)
80+
c.Assert(err, IsNil)
7781
}
7882

7983
for i := 0; i < s.iterations; i++ {
@@ -97,7 +101,9 @@ func (s *systemtestSuite) testBasicStartStopContainer(c *C, encap string) {
97101
}
98102

99103
if s.fwdMode == "routing" && encap == "vlan" {
100-
s.CheckBgpRouteDistribution(c, s.vagrant.GetNode("quagga1"), containers)
104+
var err error
105+
_, err = s.CheckBgpRouteDistribution(c, containers)
106+
c.Assert(err, IsNil)
101107
}
102108

103109
}
@@ -156,6 +162,11 @@ func (s *systemtestSuite) testBasicSvcDiscovery(c *C, encap string) {
156162
c.Assert(err, IsNil)
157163

158164
containers := append(containers1, containers2...)
165+
if s.fwdMode == "routing" && encap == "vlan" {
166+
var err error
167+
_, err = s.CheckBgpRouteDistribution(c, containers)
168+
c.Assert(err, IsNil)
169+
}
159170
if s.fwdMode == "routing" && encap == "vlan" {
160171
time.Sleep(5 * time.Second)
161172
}

0 commit comments

Comments
 (0)