Skip to content

Commit b842c3d

Browse files
committed
Move to json storage, address pblindex issue
This patch changes the way we persist the data on disk when running Calico/VPP. Instead of using struc and binary format we transition to json files. Size should not be an issue as number of pods per node are typically low (~100). This will make troubleshooting easier and errors clearer when parsing fails. We thus remove the /bin/debug troubleshooting utility as the data format is not human readable. Doing this, we address an issue where PBL indexes were reused upon dataplane restart, as they were stored in a list. We now will use a map to retain the containerIP mapping. We also split the configuration from runtime spec in LocalPodSpec and add a step to clear it when corresponding VRFs are not found in VPP. Finally we address an issue where uRPF was not properly set up for ipv6. Signed-off-by: Nathan Skrzypczak <[email protected]>
1 parent cb060eb commit b842c3d

30 files changed

+995
-1047
lines changed

calico-vpp-agent/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ FROM ubuntu:22.04
33
LABEL maintainer="[email protected]"
44

55
ADD bin/gobgp /bin/gobgp
6-
ADD bin/debug /bin/debug
76
ADD version /etc/calicovppversion
87
ADD bin/felix-api-proxy /bin/felix-api-proxy
98
ADD bin/calico-vpp-agent /bin/calico-vpp-agent

calico-vpp-agent/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ felix-api-proxy: bin
2020

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

2524
gobgp: bin
2625
${DOCKER_RUN} go build -o ./bin/gobgp github.com/osrg/gobgp/v3/cmd/gobgp/

calico-vpp-agent/cmd/calico_vpp_dataplane.go

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020
"os"
2121
"os/signal"
22+
"runtime/coverage"
2223
"syscall"
2324
"time"
2425

@@ -224,20 +225,41 @@ func main() {
224225

225226
log.Infof("Agent started")
226227

227-
interruptSignalChannel := make(chan os.Signal, 2)
228-
signal.Notify(interruptSignalChannel, os.Interrupt, syscall.SIGTERM)
229-
230-
usr1SignalChannel := make(chan os.Signal, 2)
231-
signal.Notify(usr1SignalChannel, syscall.SIGUSR1)
228+
sigChan := make(chan os.Signal, 2)
229+
signal.Notify(sigChan,
230+
os.Interrupt,
231+
syscall.SIGTERM,
232+
syscall.SIGUSR1,
233+
syscall.SIGUSR2,
234+
)
232235

233236
select {
234-
case <-usr1SignalChannel:
235-
/* vpp-manager pokes us with USR1 if VPP terminates */
236-
log.Warnf("Vpp stopped, exiting...")
237-
t.Kill(errors.Errorf("Caught signal USR1"))
238-
case <-interruptSignalChannel:
239-
log.Infof("SIG received, exiting")
240-
t.Kill(errors.Errorf("Caught INT signal"))
237+
case sig := <-sigChan:
238+
switch sig {
239+
case os.Interrupt:
240+
fallthrough
241+
case syscall.SIGTERM:
242+
log.Infof("SIG received, exiting")
243+
t.Kill(errors.Errorf("Caught INT signal"))
244+
case syscall.SIGUSR1:
245+
// vpp-manager pokes us with USR1 if VPP terminates
246+
log.Warnf("Vpp stopped, exiting...")
247+
t.Kill(errors.Errorf("Caught signal USR1"))
248+
case syscall.SIGUSR2:
249+
// the USR2 signal outputs the coverage data,
250+
// provided the binary is compiled with -cover and
251+
// GOCOVERDIR is set. This allows us to not require
252+
// a proper binary termination in order to get coverage data.
253+
log.Warn("Received SIGUSR2, writing coverage")
254+
err := coverage.WriteCountersDir(os.Getenv("GOCOVERDIR"))
255+
if err != nil {
256+
log.WithError(err).Error("Could not write counters dir")
257+
}
258+
err = coverage.WriteMetaDir(os.Getenv("GOCOVERDIR"))
259+
if err != nil {
260+
log.WithError(err).Error("Could not write meta dir")
261+
}
262+
}
241263
case <-t.Dying():
242264
log.Errorf("tomb Dying %s", t.Err())
243265
}

calico-vpp-agent/cmd/debug-state/debug-state.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

calico-vpp-agent/cni/cni_pod_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ var _ = Describe("Pod-related functionality of CNI", func() {
182182
Workload: &cniproto.WorkloadIDs{
183183
Annotations: map[string]string{
184184
// needed just for setting up steering of traffic to default Tun/Tap and to secondary Memif
185-
cni.VppAnnotationPrefix + cni.MemifPortAnnotation: fmt.Sprintf("tcp:%d-%d,udp:%d-%d",
185+
config.MemifPortAnnotation: fmt.Sprintf("tcp:%d-%d,udp:%d-%d",
186186
memifTCPPortStart, memifTCPPortEnd, memifUDPPortStart, memifUDPPortEnd),
187187
},
188188
},
@@ -418,7 +418,7 @@ var _ = Describe("Pod-related functionality of CNI", func() {
418418
Workload: &cniproto.WorkloadIDs{
419419
Annotations: map[string]string{
420420
// needed just for setting up steering of traffic to default Tun/Tap and to secondary Memif
421-
cni.VppAnnotationPrefix + cni.MemifPortAnnotation: fmt.Sprintf("tcp:%d-%d,udp:%d-%d",
421+
config.MemifPortAnnotation: fmt.Sprintf("tcp:%d-%d,udp:%d-%d",
422422
memifTCPPortStart, memifTCPPortEnd, memifUDPPortStart, memifUDPPortEnd),
423423
},
424424
},

0 commit comments

Comments
 (0)