Skip to content

Commit 9bd1615

Browse files
authored
Merge pull request #1634 from safchain/debug-weird-node-not-found
handle metadata update error in memory backend
2 parents 8a7ef1e + 73dc8bd commit 9bd1615

File tree

9 files changed

+38
-8
lines changed

9 files changed

+38
-8
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ endif
162162

163163
ifeq ($(WITH_OPENCONTRAIL), true)
164164
BUILD_TAGS+=opencontrail
165+
EXTRA_ARGS+=-opencontrail
165166
ifeq ($(OS_RHEL),Y)
166167
STATIC_LIBS+=libxml2.a
167168
endif

graffiti/graph/elasticsearch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const graphElementMapping = `
3838
"path_match": "*",
3939
"path_unmatch": "*.Extra.*",
4040
"match_mapping_type": "string",
41-
"mapping": {
41+
"mapping": {
4242
"type": "keyword"
4343
}
4444
}

graffiti/graph/memory.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ type MemoryBackend struct {
3939

4040
// MetadataUpdated return true
4141
func (m *MemoryBackend) MetadataUpdated(i interface{}) error {
42+
switch i := i.(type) {
43+
case *Node:
44+
if _, ok := m.nodes[i.ID]; !ok {
45+
46+
return ErrNodeNotFound
47+
}
48+
case *Edge:
49+
if _, ok := m.edges[i.ID]; !ok {
50+
return ErrEdgeNotFound
51+
}
52+
}
53+
4254
return nil
4355
}
4456

graffiti/hub/pod_endpoint.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ func (t *TopologyAgentEndpoint) OnStructMessage(c ws.Speaker, msg *ws.StructMess
7171
for _, n := range r.Nodes {
7272
if t.Graph.GetNode(n.ID) == nil {
7373
if err := t.Graph.NodeAdded(n); err != nil {
74-
logging.GetLogger().Error(err)
74+
logging.GetLogger().Errorf("%s, %+v", err, n)
7575
}
7676
}
7777
}
7878
for _, e := range r.Edges {
7979
if t.Graph.GetEdge(e.ID) == nil {
8080
if err := t.Graph.EdgeAdded(e); err != nil {
81-
logging.GetLogger().Error(err)
81+
logging.GetLogger().Errorf("%s, %+v", err, e)
8282
}
8383
}
8484
}
@@ -97,7 +97,7 @@ func (t *TopologyAgentEndpoint) OnStructMessage(c ws.Speaker, msg *ws.StructMess
9797
}
9898

9999
if err != nil {
100-
logging.GetLogger().Error(err)
100+
logging.GetLogger().Errorf("%s, %+v", err, obj)
101101
}
102102
}
103103

ovs/ovsdb.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ func (o *OvsMonitor) bridgeAdded(bridgeUUID string, row *libovsdb.RowUpdate) {
211211
}
212212

213213
func (o *OvsMonitor) bridgeDeleted(bridgeUUID string, row *libovsdb.RowUpdate) {
214+
// for some reason ovs can trigger multiple time this event
215+
if _, ok := o.bridgeCache[bridgeUUID]; !ok {
216+
return
217+
}
214218
delete(o.bridgeCache, bridgeUUID)
215219

216220
logging.GetLogger().Infof("Bridge \"%s(%s)\" got deleted",
@@ -262,6 +266,10 @@ func (o *OvsMonitor) interfaceAdded(interfaceUUID string, row *libovsdb.RowUpdat
262266
}
263267

264268
func (o *OvsMonitor) interfaceDeleted(interfaceUUID string, row *libovsdb.RowUpdate) {
269+
// for some reason ovs can trigger multiple time this event
270+
if _, ok := o.interfaceCache[interfaceUUID]; !ok {
271+
return
272+
}
265273
delete(o.interfaceCache, interfaceUUID)
266274

267275
logging.GetLogger().Infof("Interface \"%s(%s)\" got deleted",
@@ -312,6 +320,10 @@ func (o *OvsMonitor) portAdded(portUUID string, row *libovsdb.RowUpdate) {
312320
}
313321

314322
func (o *OvsMonitor) portDeleted(portUUID string, row *libovsdb.RowUpdate) {
323+
// for some reason ovs can trigger multiple time this event
324+
if _, ok := o.portCache[portUUID]; !ok {
325+
return
326+
}
315327
delete(o.portCache, portUUID)
316328

317329
logging.GetLogger().Infof("Port \"%s(%s)\" got deleted",

scripts/ci/opencontrail-tests.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let
1515
testScript = ''
1616
# This is to wait until OpenContrail is ready
1717
$machine->waitUntilSucceeds("curl -s http://localhost:8083/Snh_ShowBgpNeighborSummaryReq | grep machine | grep -q Established");
18-
$machine->succeed("${skydiveTestFunctionals} -test.run TestOpenContrail -standalone");
18+
$machine->succeed("${skydiveTestFunctionals} -test.run TestOpenContrail -standalone -opencontrail");
1919
'';
2020

2121
in

scripts/ci/run-functional-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ DIR="$(dirname "$0")"
77

88
. "$DIR/run-tests-utils.sh"
99
network_setup
10-
tests_run
10+
WITH_OPENCONTRAIL=false tests_run
1111
exit $RETCODE

tests/tests.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ agent:
8282
- ovsdb
8383
- docker
8484
- lxd
85-
- opencontrail
8685
- lldp
8786
- runc
87+
{{.OpencontrailProbe}}
8888
netlink:
8989
metrics_update: 5
9090
lldp:
@@ -226,6 +226,7 @@ var (
226226
noOFTests bool
227227
standalone bool
228228
topologyBackend string
229+
opencontrailProbe bool
229230
)
230231

231232
func initConfig(conf string, params ...helperParams) error {
@@ -275,6 +276,9 @@ func initConfig(conf string, params ...helperParams) error {
275276
if analyzerProbes != "" {
276277
params[0]["AnalyzerProbes"] = strings.Split(analyzerProbes, ",")
277278
}
279+
if opencontrailProbe {
280+
params[0]["OpencontrailProbe"] = "- opencontrail"
281+
}
278282

279283
tmpl, err := template.New("config").Parse(conf)
280284
if err != nil {
@@ -792,6 +796,7 @@ func init() {
792796
flag.StringVar(&flowBackend, "analyzer.flow.backend", "", "Specify the flow storage backend used")
793797
flag.StringVar(&analyzerListen, "analyzer.listen", "0.0.0.0:64500", "Specify the analyzer listen address")
794798
flag.StringVar(&analyzerProbes, "analyzer.topology.probes", "", "Specify the analyzer probes to enable")
799+
flag.BoolVar(&opencontrailProbe, "opencontrail", false, "Enable opencontrail probe")
795800
flag.Parse()
796801

797802
http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = 100

topology/probes/ovsdb/ovs_of.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ func (probe *BridgeOfProbe) monitorGroup() error {
736736
}
737737
if _, err = launchOnSwitch(command); err != nil {
738738
logging.GetLogger().Warningf("OpenFlow 1.5 not supported on %s", probe.Bridge)
739-
return err
739+
return nil
740740
}
741741
randBytes := make([]byte, 16)
742742
rand.Read(randBytes)

0 commit comments

Comments
 (0)