@@ -36,7 +36,6 @@ import (
36
36
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/cni/model"
37
37
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/cni/podinterface"
38
38
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/common"
39
- "github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/watchers"
40
39
"github.com/projectcalico/vpp-dataplane/v3/config"
41
40
"github.com/projectcalico/vpp-dataplane/v3/vpplink"
42
41
"github.com/projectcalico/vpp-dataplane/v3/vpplink/types"
@@ -53,7 +52,7 @@ type Server struct {
53
52
54
53
podInterfaceMap map [string ]model.LocalPodSpec
55
54
lock sync.Mutex /* protects Add/DelVppInterace/RescanState */
56
- cniEventChan chan common. CalicoVppEvent
55
+ cniEventChan chan any
57
56
58
57
memifDriver * podinterface.MemifPodInterfaceDriver
59
58
tuntapDriver * podinterface.TunTapPodInterfaceDriver
@@ -65,7 +64,7 @@ type Server struct {
65
64
RedirectToHostClassifyTableIndex uint32
66
65
67
66
networkDefinitions sync.Map
68
- cniMultinetEventChan chan common. CalicoVppEvent
67
+ cniMultinetEventChan chan any
69
68
nodeBGPSpec * common.LocalNodeSpec
70
69
}
71
70
@@ -96,9 +95,9 @@ func (s *Server) Add(ctx context.Context, request *cniproto.AddRequest) (*cnipro
96
95
if ! ok {
97
96
return nil , fmt .Errorf ("trying to create a pod in an unexisting network %s" , podSpec .NetworkName )
98
97
} else {
99
- networkDefinition , ok := value .(* watchers .NetworkDefinition )
98
+ networkDefinition , ok := value .(* common .NetworkDefinition )
100
99
if ! ok || networkDefinition == nil {
101
- panic ("Value is not of type *watchers .NetworkDefinition" )
100
+ panic ("Value is not of type *common .NetworkDefinition" )
102
101
}
103
102
_ , route , err := net .ParseCIDR (networkDefinition .Range )
104
103
if err == nil {
@@ -283,7 +282,7 @@ func NewCNIServer(vpp *vpplink.VppLink, felixServerIpam common.FelixServerIpam,
283
282
log : log ,
284
283
285
284
felixServerIpam : felixServerIpam ,
286
- cniEventChan : make (chan common. CalicoVppEvent , common .ChanSize ),
285
+ cniEventChan : make (chan any , common .ChanSize ),
287
286
288
287
grpcServer : grpc .NewServer (),
289
288
podInterfaceMap : make (map [string ]model.LocalPodSpec ),
@@ -292,7 +291,7 @@ func NewCNIServer(vpp *vpplink.VppLink, felixServerIpam common.FelixServerIpam,
292
291
vclDriver : podinterface .NewVclPodInterfaceDriver (vpp , log ),
293
292
loopbackDriver : podinterface .NewLoopbackPodInterfaceDriver (vpp , log ),
294
293
295
- cniMultinetEventChan : make (chan common. CalicoVppEvent , common .ChanSize ),
294
+ cniMultinetEventChan : make (chan any , common .ChanSize ),
296
295
}
297
296
reg := common .RegisterHandler (server .cniEventChan , "CNI server events" )
298
297
reg .ExpectEvents (
@@ -313,7 +312,11 @@ forloop:
313
312
select {
314
313
case <- t .Dying ():
315
314
break forloop
316
- case evt := <- s .cniEventChan :
315
+ case msg := <- s .cniEventChan :
316
+ evt , ok := msg .(common.CalicoVppEvent )
317
+ if ! ok {
318
+ continue
319
+ }
317
320
switch evt .Type {
318
321
case common .FelixConfChanged :
319
322
if new , _ := evt .New .(* felixConfig.Config ); new != nil {
@@ -434,21 +437,25 @@ func (s *Server) ServeCNI(t *tomb.Tomb) error {
434
437
case <- t .Dying ():
435
438
s .log .Warn ("Cni server asked to exit" )
436
439
return
437
- case event := <- s .cniMultinetEventChan :
440
+ case msg := <- s .cniMultinetEventChan :
441
+ event , ok := msg .(common.CalicoVppEvent )
442
+ if ! ok {
443
+ continue
444
+ }
438
445
switch event .Type {
439
446
case common .NetsSynced :
440
447
netsSynced <- true
441
448
case common .NetAddedOrUpdated :
442
- netDef , ok := event .New .(* watchers .NetworkDefinition )
449
+ netDef , ok := event .New .(* common .NetworkDefinition )
443
450
if ! ok {
444
- s .log .Errorf ("event.New is not a *watchers .NetworkDefinition %v" , event .New )
451
+ s .log .Errorf ("event.New is not a *common .NetworkDefinition %v" , event .New )
445
452
continue
446
453
}
447
454
s .networkDefinitions .Store (netDef .Name , netDef )
448
455
case common .NetDeleted :
449
- netDef , ok := event .Old .(* watchers .NetworkDefinition )
456
+ netDef , ok := event .Old .(* common .NetworkDefinition )
450
457
if ! ok {
451
- s .log .Errorf ("event.Old is not a *watchers .NetworkDefinition %v" , event .Old )
458
+ s .log .Errorf ("event.Old is not a *common .NetworkDefinition %v" , event .Old )
452
459
continue
453
460
}
454
461
s .networkDefinitions .Delete (netDef .Name )
@@ -488,6 +495,6 @@ func (s *Server) ServeCNI(t *tomb.Tomb) error {
488
495
489
496
// ForceAddingNetworkDefinition will add another NetworkDefinition to this CNI server.
490
497
// The usage is mainly for testing purposes.
491
- func (s * Server ) ForceAddingNetworkDefinition (networkDefinition * watchers .NetworkDefinition ) {
498
+ func (s * Server ) ForceAddingNetworkDefinition (networkDefinition * common .NetworkDefinition ) {
492
499
s .networkDefinitions .Store (networkDefinition .Name , networkDefinition )
493
500
}
0 commit comments