Skip to content

Commit eb5adeb

Browse files
author
Aritra Basu
committed
Remove peers_watcher dependency on pubsub
Signed-off-by: Aritra Basu <[email protected]>
1 parent 05e1278 commit eb5adeb

File tree

9 files changed

+524
-437
lines changed

9 files changed

+524
-437
lines changed

calico-vpp-agent/cmd/calico_vpp_dataplane.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ func main() {
136136
linkWatcher := watchers.NewLinkWatcher(common.VppManagerInfo.UplinkStatuses, log.WithFields(logrus.Fields{"subcomponent": "host-link-watcher"}))
137137
bgpConfigurationWatcher := watchers.NewBGPConfigurationWatcher(clientv3, log.WithFields(logrus.Fields{"subcomponent": "bgp-conf-watch"}))
138138
prefixWatcher := watchers.NewPrefixWatcher(client, log.WithFields(logrus.Fields{"subcomponent": "prefix-watcher"}))
139-
peerWatcher := watchers.NewPeerWatcher(clientv3, k8sclient, log.WithFields(logrus.Fields{"subcomponent": "peer-watcher"}))
140139
bgpFilterWatcher := watchers.NewBGPFilterWatcher(clientv3, k8sclient, log.WithFields(logrus.Fields{"subcomponent": "BGPFilter-watcher"}))
141140
netWatcher := watchers.NewNetWatcher(vpp, log.WithFields(logrus.Fields{"component": "net-watcher"}))
142141
routingServer := routing.NewRoutingServer(vpp, bgpServer, log.WithFields(logrus.Fields{"component": "routing"}))
@@ -159,10 +158,17 @@ func main() {
159158
log.Fatalf("cannot get default BGP config %s", err)
160159
}
161160

162-
peerWatcher.SetBGPConf(bgpConf)
163161
routingServer.SetBGPConf(bgpConf)
164162
felixServer.SetBGPConf(bgpConf)
165163

164+
secretWatcher := watchers.NewSecretWatcher(k8sclient, log.WithFields(logrus.Fields{"component": "secret-watcher"}))
165+
// Set secret watcher in peer handler
166+
felixServer.GetPeerHandler().SetSecretWatcher(secretWatcher)
167+
// Set peer handler in routing server
168+
routingServer.SetPeerHandler(felixServer.GetPeerHandler())
169+
// Create peer watcher
170+
peerWatcher := watchers.NewPeerWatcher(clientv3, felixServer.GetPeerHandler(), secretWatcher, log.WithFields(logrus.Fields{"component": "peer-watcher"}))
171+
166172
watchDog := watchdog.NewWatchDog(log.WithFields(logrus.Fields{"component": "watchDog"}), &t)
167173
Go(felixServer.ServeFelix)
168174
Go(felixWatcher.WatchFelix)

calico-vpp-agent/common/pubsub.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ const (
4545
TunnelAdded CalicoVppEventType = "TunnelAdded"
4646
TunnelDeleted CalicoVppEventType = "TunnelDeleted"
4747

48-
BGPPeerAdded CalicoVppEventType = "BGPPeerAdded"
49-
BGPPeerDeleted CalicoVppEventType = "BGPPeerDeleted"
50-
BGPPeerUpdated CalicoVppEventType = "BGPPeerUpdated"
51-
BGPSecretChanged CalicoVppEventType = "BGPSecretChanged"
48+
BGPPeerAdded CalicoVppEventType = "BGPPeerAdded"
49+
BGPPeerDeleted CalicoVppEventType = "BGPPeerDeleted"
50+
BGPPeerUpdated CalicoVppEventType = "BGPPeerUpdated"
5251

5352
BGPFilterAddedOrUpdated CalicoVppEventType = "BGPFilterAddedOrUpdated"
5453
BGPFilterDeleted CalicoVppEventType = "BGPFilterDeleted"

calico-vpp-agent/felix/felix_server.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/felix/connectivity"
3535
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/felix/policies"
3636
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/felix/services"
37+
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/routing"
3738
"github.com/projectcalico/vpp-dataplane/v3/config"
3839
"github.com/projectcalico/vpp-dataplane/v3/vpplink"
3940
"github.com/projectcalico/vpp-dataplane/v3/vpplink/types"
@@ -59,6 +60,7 @@ type Server struct {
5960
cniHandler *cni.CNIHandler
6061
connectivityHandler *connectivity.ConnectivityHandler
6162
serviceHandler *services.ServiceHandler
63+
peerHandler *routing.PeerHandler
6264
}
6365

6466
// NewFelixServer creates a felix server
@@ -77,6 +79,7 @@ func NewFelixServer(vpp *vpplink.VppLink, clientv3 calicov3cli.Interface, log *l
7779
cniHandler: cni.NewCNIHandler(vpp, cache, log),
7880
connectivityHandler: connectivity.NewConnectivityHandler(vpp, cache, clientv3, log),
7981
serviceHandler: services.NewServiceHandler(vpp, cache, log),
82+
peerHandler: routing.NewPeerHandler(cache, log),
8083
}
8184

8285
reg := common.RegisterHandler(server.felixServerEventChan, "felix server events")
@@ -104,6 +107,10 @@ func (s *Server) GetCache() *cache.Cache {
104107
return s.cache
105108
}
106109

110+
func (s *Server) GetPeerHandler() *routing.PeerHandler {
111+
return s.peerHandler
112+
}
113+
107114
func (s *Server) SetBGPConf(bgpConf *calicov3.BGPConfigurationSpec) {
108115
s.cache.BGPConf = bgpConf
109116
}

calico-vpp-agent/routing/bgp_watcher.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,12 @@ func (s *Server) WatchBGPPath(t *tomb.Tomb) error {
669669
}
670670
s.log.Infof("bgp(del) filter deleted: %s", filter.Name)
671671
delete(s.bgpFilters, filter.Name)
672+
case common.PeerNodeStateChanged:
673+
old, _ := evt.Old.(*common.LocalNodeSpec)
674+
new, _ := evt.New.(*common.LocalNodeSpec)
675+
if s.peerHandler != nil {
676+
s.peerHandler.OnPeerNodeStateChanged(old, new)
677+
}
672678
}
673679
}
674680
}

0 commit comments

Comments
 (0)