Skip to content

Commit ffb8c29

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

File tree

9 files changed

+541
-437
lines changed

9 files changed

+541
-437
lines changed

calico-vpp-agent/cmd/calico_vpp_dataplane.go

Lines changed: 17 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,9 +158,25 @@ func main() {
159158
log.Fatalf("cannot get default BGP config %s", err)
160159
}
161160

161+
// Create secret watcher (no longer uses events)
162+
secretWatcher, err := watchers.NewSecretWatcher(k8sclient)
163+
if err != nil {
164+
log.Fatalf("could not create secret watcher: %s", err)
165+
}
166+
167+
// Create peer handler and set it in felix server (following the existing pattern)
168+
peerHandler := routing.NewPeerHandler(secretWatcher, log.WithFields(logrus.Fields{"component": "peer-handler"}))
169+
peerHandler.SetBGPConf(bgpConf)
170+
felixServer.SetPeerHandler(peerHandler)
171+
172+
// Set peer handler in routing server
173+
routingServer.SetPeerHandler(peerHandler)
174+
175+
// Create peer watcher (no longer uses events from routing server)
176+
peerWatcher := watchers.NewPeerWatcher(clientv3, peerHandler, secretWatcher, log.WithFields(logrus.Fields{"component": "peer-watcher"}))
162177
peerWatcher.SetBGPConf(bgpConf)
178+
163179
routingServer.SetBGPConf(bgpConf)
164-
felixServer.SetBGPConf(bgpConf)
165180

166181
watchDog := watchdog.NewWatchDog(log.WithFields(logrus.Fields{"component": "watchDog"}), &t)
167182
Go(felixServer.ServeFelix)

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: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/sirupsen/logrus"
2525
"gopkg.in/tomb.v2"
2626

27-
calicov3 "github.com/projectcalico/api/pkg/apis/projectcalico/v3"
2827
"github.com/projectcalico/calico/felix/proto"
2928

3029
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/common"
@@ -34,6 +33,7 @@ import (
3433
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/felix/connectivity"
3534
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/felix/policies"
3635
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/felix/services"
36+
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/routing"
3737
"github.com/projectcalico/vpp-dataplane/v3/config"
3838
"github.com/projectcalico/vpp-dataplane/v3/vpplink"
3939
"github.com/projectcalico/vpp-dataplane/v3/vpplink/types"
@@ -59,6 +59,7 @@ type Server struct {
5959
cniHandler *cni.CNIHandler
6060
connectivityHandler *connectivity.ConnectivityHandler
6161
serviceHandler *services.ServiceHandler
62+
peerHandler *routing.PeerHandler
6263
}
6364

6465
// NewFelixServer creates a felix server
@@ -104,8 +105,19 @@ func (s *Server) GetCache() *cache.Cache {
104105
return s.cache
105106
}
106107

107-
func (s *Server) SetBGPConf(bgpConf *calicov3.BGPConfigurationSpec) {
108-
s.cache.BGPConf = bgpConf
108+
// GetConnectivityHandler returns the connectivity handler
109+
func (s *Server) GetConnectivityHandler() *connectivity.ConnectivityHandler {
110+
return s.connectivityHandler
111+
}
112+
113+
// SetPeerHandler sets the peer handler for the felix server
114+
func (s *Server) SetPeerHandler(peerHandler *routing.PeerHandler) {
115+
s.peerHandler = peerHandler
116+
}
117+
118+
// GetPeerHandler returns the peer handler
119+
func (s *Server) GetPeerHandler() *routing.PeerHandler {
120+
return s.peerHandler
109121
}
110122

111123
func (s *Server) getMainInterface() *config.UplinkStatus {

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)