Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion calico-vpp-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ FROM ubuntu:22.04
LABEL maintainer="[email protected]"

ADD bin/gobgp /bin/gobgp
ADD bin/debug /bin/debug
ADD version /etc/calicovppversion
ADD bin/felix-api-proxy /bin/felix-api-proxy
ADD bin/calico-vpp-agent /bin/calico-vpp-agent
Expand Down
1 change: 0 additions & 1 deletion calico-vpp-agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ felix-api-proxy: bin

build: felix-api-proxy bin
${DOCKER_RUN} go build -o ./bin/calico-vpp-agent ./cmd
${DOCKER_RUN} go build -o ./bin/debug ./cmd/debug-state

gobgp: bin
${DOCKER_RUN} go build -o ./bin/gobgp github.com/osrg/gobgp/v3/cmd/gobgp/
Expand Down
81 changes: 42 additions & 39 deletions calico-vpp-agent/cmd/calico_vpp_dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
"context"
"os"
"os/signal"
"runtime/coverage"
"syscall"
"time"

apipb "github.com/osrg/gobgp/v3/api"
bgpserver "github.com/osrg/gobgp/v3/pkg/server"
"github.com/pkg/errors"
felixconfig "github.com/projectcalico/calico/felix/config"
calicocli "github.com/projectcalico/calico/libcalico-go/lib/client"
calicov3cli "github.com/projectcalico/calico/libcalico-go/lib/clientv3"
"github.com/sirupsen/logrus"
Expand All @@ -34,13 +34,10 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/cni"
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/common"
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/connectivity"
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/felix"
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/prometheus"
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/routing"
"github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/services"
"github.com/projectcalico/vpp-dataplane/v3/config"

watchdog "github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/watch_dog"
Expand Down Expand Up @@ -143,19 +140,17 @@ func main() {
bgpFilterWatcher := watchers.NewBGPFilterWatcher(clientv3, k8sclient, log.WithFields(logrus.Fields{"subcomponent": "BGPFilter-watcher"}))
netWatcher := watchers.NewNetWatcher(vpp, log.WithFields(logrus.Fields{"component": "net-watcher"}))
routingServer := routing.NewRoutingServer(vpp, bgpServer, log.WithFields(logrus.Fields{"component": "routing"}))
serviceServer := services.NewServiceServer(vpp, k8sclient, log.WithFields(logrus.Fields{"component": "services"}))
prometheusServer := prometheus.NewPrometheusServer(vpp, log.WithFields(logrus.Fields{"component": "prometheus"}))
localSIDWatcher := watchers.NewLocalSIDWatcher(vpp, clientv3, log.WithFields(logrus.Fields{"subcomponent": "localsid-watcher"}))
felixServer, err := felix.NewFelixServer(vpp, log.WithFields(logrus.Fields{"component": "policy"}))
if err != nil {
log.Fatalf("Failed to create policy server %s", err)
}
err = felix.InstallFelixPlugin()
felixServer := felix.NewFelixServer(vpp, clientv3, log.WithFields(logrus.Fields{"component": "policy"}))
felixWatcher := watchers.NewFelixWatcher(felixServer.GetFelixServerEventChan(), log.WithFields(logrus.Fields{"component": "felix watcher"}))
cniServer := watchers.NewCNIServer(felixServer.GetFelixServerEventChan(), log.WithFields(logrus.Fields{"component": "cni"}))
serviceServer := watchers.NewServiceServer(felixServer.GetFelixServerEventChan(), k8sclient, log.WithFields(logrus.Fields{"component": "services"}))

err = watchers.InstallFelixPlugin()
if err != nil {
log.Fatalf("could not install felix plugin: %s", err)
}
connectivityServer := connectivity.NewConnectivityServer(vpp, felixServer, clientv3, log.WithFields(logrus.Fields{"subcomponent": "connectivity"}))
cniServer := cni.NewCNIServer(vpp, felixServer, log.WithFields(logrus.Fields{"component": "cni"}))

/* Pubsub should now be registered */

Expand All @@ -166,11 +161,11 @@ func main() {

peerWatcher.SetBGPConf(bgpConf)
routingServer.SetBGPConf(bgpConf)
serviceServer.SetBGPConf(bgpConf)
felixServer.SetBGPConf(bgpConf)

watchDog := watchdog.NewWatchDog(log.WithFields(logrus.Fields{"component": "watchDog"}), &t)
Go(felixServer.ServeFelix)
felixConfig := watchDog.Wait(felixServer.FelixConfigChan, "Waiting for FelixConfig to be provided by the calico pod")
Go(felixWatcher.WatchFelix)
ourBGPSpec := watchDog.Wait(felixServer.GotOurNodeBGPchan, "Waiting for bgp spec to be provided on node add")
// check if the watchDog timer has issued the t.Kill() which would mean we are dead
if !t.Alive() {
Expand All @@ -183,35 +178,22 @@ func main() {
panic("ourBGPSpec is not *common.LocalNodeSpec")
}
prefixWatcher.SetOurBGPSpec(bgpSpec)
connectivityServer.SetOurBGPSpec(bgpSpec)
routingServer.SetOurBGPSpec(bgpSpec)
serviceServer.SetOurBGPSpec(bgpSpec)
localSIDWatcher.SetOurBGPSpec(bgpSpec)
netWatcher.SetOurBGPSpec(bgpSpec)
cniServer.SetOurBGPSpec(bgpSpec)
}

if *config.GetCalicoVppFeatureGates().MultinetEnabled {
Go(netWatcher.WatchNetworks)
watchDog.Wait(netWatcher.InSync, "Waiting for networks to be listed and synced")
}

if felixConfig != nil {
felixCfg, ok := felixConfig.(*felixconfig.Config)
if !ok {
panic("ourBGPSpec is not *felixconfig.Config")
}
cniServer.SetFelixConfig(felixCfg)
connectivityServer.SetFelixConfig(felixCfg)
}

Go(routeWatcher.WatchRoutes)
Go(linkWatcher.WatchLinks)
Go(bgpConfigurationWatcher.WatchBGPConfiguration)
Go(prefixWatcher.WatchPrefix)
Go(peerWatcher.WatchBGPPeers)
Go(bgpFilterWatcher.WatchBGPFilters)
Go(connectivityServer.ServeConnectivity)
Go(routingServer.ServeRouting)
Go(serviceServer.ServeService)
Go(cniServer.ServeCNI)
Expand All @@ -224,20 +206,41 @@ func main() {

log.Infof("Agent started")

interruptSignalChannel := make(chan os.Signal, 2)
signal.Notify(interruptSignalChannel, os.Interrupt, syscall.SIGTERM)

usr1SignalChannel := make(chan os.Signal, 2)
signal.Notify(usr1SignalChannel, syscall.SIGUSR1)
sigChan := make(chan os.Signal, 2)
signal.Notify(sigChan,
os.Interrupt,
syscall.SIGTERM,
syscall.SIGUSR1,
syscall.SIGUSR2,
)

select {
case <-usr1SignalChannel:
/* vpp-manager pokes us with USR1 if VPP terminates */
log.Warnf("Vpp stopped, exiting...")
t.Kill(errors.Errorf("Caught signal USR1"))
case <-interruptSignalChannel:
log.Infof("SIG received, exiting")
t.Kill(errors.Errorf("Caught INT signal"))
case sig := <-sigChan:
switch sig {
case os.Interrupt:
fallthrough
case syscall.SIGTERM:
log.Infof("SIG received, exiting")
t.Kill(errors.Errorf("Caught INT signal"))
case syscall.SIGUSR1:
// vpp-manager pokes us with USR1 if VPP terminates
log.Warnf("Vpp stopped, exiting...")
t.Kill(errors.Errorf("Caught signal USR1"))
case syscall.SIGUSR2:
// the USR2 signal outputs the coverage data,
// provided the binary is compiled with -cover and
// GOCOVERDIR is set. This allows us to not require
// a proper binary termination in order to get coverage data.
log.Warn("Received SIGUSR2, writing coverage")
err := coverage.WriteCountersDir(os.Getenv("GOCOVERDIR"))
if err != nil {
log.WithError(err).Error("Could not write counters dir")
}
err = coverage.WriteMetaDir(os.Getenv("GOCOVERDIR"))
if err != nil {
log.WithError(err).Error("Could not write meta dir")
}
}
case <-t.Dying():
log.Errorf("tomb Dying %s", t.Err())
}
Expand Down
43 changes: 0 additions & 43 deletions calico-vpp-agent/cmd/debug-state/debug-state.go

This file was deleted.

Loading