eBay / go-ovn

A Go library for OVN Northbound/Southbound DB access using native OVSDB protocol
Apache License 2.0
108 stars 59 forks source link

crash on populateCache #119

Closed amorenoz closed 3 years ago

amorenoz commented 3 years ago

Sometimes, when the cache is populated (e.g: on goovn.NewClient()) the library can crash the program (in several ways). An example crash traceback is here:

panic: interface conversion: interface {} is nil, not string
goroutine 94 [running]:
github.com/ebay/go-ovn.(*ovndb).rowToLogicalRouterPort(0xc000e89c80, 0xc0024bdcb0, 0x24, 0x5)
        /home/amorenoz/src/skynet/workdir/go/pkg/mod/github.com/amorenoz/go-ovn@v0.1.1-0.20201111124657-2a0d4d618412/logical_router_port.go:136 +0x14c4
github.com/ebay/go-ovn.(*ovndb).rowToLogicalRouter(0xc000e89c80, 0xc0024bdd40, 0x24, 0x24)
        /home/amorenoz/src/skynet/workdir/go/pkg/mod/github.com/amorenoz/go-ovn@v0.1.1-0.20201111124657-2a0d4d618412/logical_router.go:159 +0x1539
github.com/ebay/go-ovn.(*ovndb).populateCache(0xc000e89c80, 0xc0025daa50)
        /home/amorenoz/src/skynet/workdir/go/pkg/mod/github.com/amorenoz/go-ovn@v0.1.1-0.20201111124657-2a0d4d618412/ovnimp.go:235 +0x24d5
github.com/ebay/go-ovn.connect(0xc000e89c80, 0x0, 0x0)
        /home/amorenoz/src/skynet/workdir/go/pkg/mod/github.com/amorenoz/go-ovn@v0.1.1-0.20201111124657-2a0d4d618412/client.go:261 +0x1f7
github.com/ebay/go-ovn.NewClient(0xc0008ede70, 0xc002594600, 0x1f, 0x0, 0x0)
        /home/amorenoz/src/skynet/workdir/go/pkg/mod/github.com/amorenoz/go-ovn@v0.1.1-0.20201111124657-2a0d4d618412/client.go:290 +0x39f
github.com/skydive-project/skydive/topology/probes/ovn.(*Probe).Do(0xc000170000, 0x7c23700, 0xc0016e0600, 0xc00044a820, 0x0, 0xc000743ec0)
        /home/amorenoz/src/skynet/workdir/go/src/github.com/skydive-project/skydive/topology/probes/ovn/ovn.go:714 +0x228
github.com/skydive-project/skydive/topology/probes.(*serviceManager).Start.func1(0xc00044a800, 0x7c23700, 0xc0016e0600)
        /home/amorenoz/src/skynet/workdir/go/src/github.com/skydive-project/skydive/topology/probes/wrapper.go:51 +0xf5
created by github.com/skydive-project/skydive/topology/probes.(*serviceManager).Start
        /home/amorenoz/src/skynet/workdir/go/src/github.com/skydive-project/skydive/topology/probes/wrapper.go:49 +0xf1

The reason behind it is the lack of table order enforcement in PopulateCache due to golang not guaranteeing maps are ranged in the same order they are created. This can make a LogicalRouter object be created before its LogicalRouterPorts are, which causes the above crash.

I'll send a PR to fix this soon.

amorenoz commented 3 years ago

Fixed by #116