Skip to content

Commit 2a4af86

Browse files
committed
Add zebra -K argument and extend e2e testing
Signed-off-by: karampok <[email protected]>
1 parent 12e4dd6 commit 2a4af86

File tree

7 files changed

+84
-11
lines changed

7 files changed

+84
-11
lines changed

charts/frr-k8s/templates/controller.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ data:
4949
# Check /etc/pam.d/frr if you intend to use "vtysh"!
5050
#
5151
vtysh_enable=yes
52-
zebra_options=" -A 127.0.0.1 -s 90000000"
52+
zebra_options=" -A 127.0.0.1 -K 120 -s 90000000"
5353
bgpd_options=" -A 127.0.0.1 {{ if not .Values.frrk8s.frr.acceptIncomingBGPConnections }} -p 0 {{- end }}"
5454
ospfd_options=" -A 127.0.0.1"
5555
ospf6d_options=" -A ::1"

config/all-in-one/frr-k8s-prometheus.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ data:
835835
# Check /etc/pam.d/frr if you intend to use "vtysh"!
836836
#
837837
vtysh_enable=yes
838-
zebra_options=" -A 127.0.0.1 -s 90000000"
838+
zebra_options=" -A 127.0.0.1 -K 120 -s 90000000"
839839
bgpd_options=" -A 127.0.0.1 -p 0"
840840
ospfd_options=" -A 127.0.0.1"
841841
ospf6d_options=" -A ::1"

config/all-in-one/frr-k8s.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ data:
804804
# Check /etc/pam.d/frr if you intend to use "vtysh"!
805805
#
806806
vtysh_enable=yes
807-
zebra_options=" -A 127.0.0.1 -s 90000000"
807+
zebra_options=" -A 127.0.0.1 -K 120 -s 90000000"
808808
bgpd_options=" -A 127.0.0.1 -p 0"
809809
ospfd_options=" -A 127.0.0.1"
810810
ospf6d_options=" -A ::1"

config/frr-k8s/frr-cm.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ data:
4545
# Check /etc/pam.d/frr if you intend to use "vtysh"!
4646
#
4747
vtysh_enable=yes
48-
zebra_options=" -A 127.0.0.1 -s 90000000"
48+
zebra_options=" -A 127.0.0.1 -K 120 -s 90000000"
4949
bgpd_options=" -A 127.0.0.1 -p 0"
5050
ospfd_options=" -A 127.0.0.1"
5151
ospf6d_options=" -A ::1"

e2etests/go.work.sum

+1-2
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0Gq
818818
github.com/moby/spdystream v0.4.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI=
819819
github.com/moby/sys/mountinfo v0.5.0 h1:2Ks8/r6lopsxWi9m58nlwjaeSzUX9iiL1vj5qB/9ObI=
820820
github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI=
821+
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
821822
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
822823
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
823824
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
@@ -1517,8 +1518,6 @@ k8s.io/code-generator v0.29.3/go.mod h1:x47ofBhN4gxYFcxeKA1PYXeaPreAGaDN85Y/lNUs
15171518
k8s.io/code-generator v0.30.2/go.mod h1:RQP5L67QxqgkVquk704CyvWFIq0e6RCMmLTXxjE8dVA=
15181519
k8s.io/code-generator v0.31.0/go.mod h1:84y4w3es8rOJOUUP1rLsIiGlO1JuEaPFXQPA9e/K6U0=
15191520
k8s.io/component-base v0.29.0/go.mod h1:sADonFTQ9Zc9yFLghpDpmNXEdHyQmFIGbiuZbqAXQ1M=
1520-
k8s.io/component-base v0.31.0 h1:/KIzGM5EvPNQcYgwq5NwoQBaOlVFrghoVGr8lG6vNRs=
1521-
k8s.io/component-base v0.31.0/go.mod h1:TYVuzI1QmN4L5ItVdMSXKvH7/DtvIuas5/mm8YT3rTo=
15221521
k8s.io/component-helpers v0.28.3 h1:te9ieTGzcztVktUs92X53P6BamAoP73MK0qQP0WmDqc=
15231522
k8s.io/component-helpers v0.28.3/go.mod h1:oJR7I9ist5UAQ3y/CTdbw6CXxdMZ1Lw2Ua/EZEwnVLs=
15241523
k8s.io/controller-manager v0.26.0/go.mod h1:GxUYtQDBE/RHh7AnZSZqwi2xBPIXlOaWsnDLflKGYrE=

e2etests/pkg/config/from_containers.go

+11
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ func EnableGracefulRestart(pc *PeersConfig) {
103103
}
104104
}
105105

106+
func EnableReceiveAllowAll(pc *PeersConfig) {
107+
t := pc.PeersV4
108+
for i := 0; i < len(t); i++ {
109+
t[i].Neigh.ToReceive.Allowed.Mode = frrk8sv1beta1.AllowAll
110+
}
111+
t = pc.PeersV6
112+
for i := 0; i < len(t); i++ {
113+
t[i].Neigh.ToReceive.Allowed.Mode = frrk8sv1beta1.AllowAll
114+
}
115+
}
116+
106117
func EnableAllowAll(pc *PeersConfig) {
107118
t := pc.PeersV4
108119
for i := 0; i < len(t); i++ {

e2etests/tests/graceful_restart.go

+68-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
package tests
44

55
import (
6+
"encoding/json"
67
"fmt"
8+
"net"
9+
"os/exec"
710
"time"
811

912
"github.com/onsi/ginkgo/v2"
@@ -18,6 +21,7 @@ import (
1821
"github.com/metallb/frrk8stests/pkg/k8sclient"
1922
"github.com/metallb/frrk8stests/pkg/routes"
2023
. "github.com/onsi/gomega"
24+
"go.universe.tf/e2etest/pkg/executor"
2125
frrconfig "go.universe.tf/e2etest/pkg/frr/config"
2226
"go.universe.tf/e2etest/pkg/ipfamily"
2327
corev1 "k8s.io/api/core/v1"
@@ -68,19 +72,29 @@ var _ = ginkgo.Describe("Establish BGP session with EnableGracefulRestart", func
6872
dump.K8sInfo(testName, reporter)
6973
dump.BGPInfo(testName, infra.FRRContainers, cs)
7074
}
75+
76+
err := cleanup(updater)
77+
Expect(err).NotTo(HaveOccurred(), "cleanup config in API and infra containers")
7178
})
7279

7380
ginkgo.Context("When restarting the frrk8s deamon pods", func() {
7481

75-
ginkgo.DescribeTable("external BGP peer maintains routes", func(ipFam ipfamily.Family, prefix string) {
82+
ginkgo.DescribeTable("external BGP peer maintains routes", func(ipFam ipfamily.Family, prefix, learnRoute string) {
83+
cc := func(frr *container.FRR) {
84+
if ipFam == ipfamily.IPv4 {
85+
frr.NeighborConfig.ToAdvertiseV4 = []string{learnRoute}
86+
} else {
87+
frr.NeighborConfig.ToAdvertiseV6 = []string{learnRoute}
88+
}
89+
}
7690
frrs := config.ContainersForVRF(infra.FRRContainers, "")
7791
for _, c := range frrs {
78-
err := container.PairWithNodes(cs, c, ipFam)
92+
err := container.PairWithNodes(cs, c, ipFam, cc)
7993
Expect(err).NotTo(HaveOccurred(), "set frr config in infra containers failed")
8094
}
8195

8296
peersConfig := config.PeersForContainers(frrs, ipFam,
83-
config.EnableAllowAll, config.EnableGracefulRestart)
97+
config.EnableAllowAll, config.EnableReceiveAllowAll, config.EnableGracefulRestart)
8498

8599
frrConfigCR := frrk8sv1beta1.FRRConfiguration{
86100
ObjectMeta: metav1.ObjectMeta{
@@ -110,12 +124,16 @@ var _ = ginkgo.Describe("Establish BGP session with EnableGracefulRestart", func
110124
return fmt.Errorf("Neigh %s does not have prefix %s: %w", p.FRR.Name, prefix, err)
111125
}
112126
}
127+
if err := checkRoutesOnNodes(nodes, learnRoute); err != nil {
128+
return err
129+
}
113130
return nil
114131
}
115132

116133
Eventually(check, time.Minute, time.Second).ShouldNot(HaveOccurred(),
117134
"route should exist before we restart frr-k8s")
118135

136+
ginkgo.By("GR started")
119137
c := make(chan struct{})
120138
go func() { // go restart frr-k8s while Consistently check that route exists
121139
defer ginkgo.GinkgoRecover()
@@ -128,8 +146,53 @@ var _ = ginkgo.Describe("Establish BGP session with EnableGracefulRestart", func
128146
Consistently(check, 2*time.Minute, time.Second).ShouldNot(HaveOccurred())
129147
Eventually(c, time.Minute, time.Second).Should(BeClosed(), "restart FRRK8s pods are not yet ready")
130148
},
131-
ginkgo.Entry("IPV4", ipfamily.IPv4, "192.168.2.0/24"),
132-
ginkgo.Entry("IPV6", ipfamily.IPv6, "fc00:f853:ccd:e799::/64"),
149+
ginkgo.Entry("IPV4", ipfamily.IPv4, "192.168.2.0/24", "200.200.200.0/24"),
150+
ginkgo.Entry("IPV6", ipfamily.IPv6, "fc00:f853:ccd:e799::/64", "2001:db8::/64"),
133151
)
134152
})
135153
})
154+
155+
type IPRouteNexthop struct {
156+
Gateway string `json:"gateway"`
157+
Dev string `json:"dev"`
158+
Weight int `json:"weight"`
159+
Flags []any `json:"flags"`
160+
}
161+
162+
type IPRoute struct {
163+
Dst string `json:"dst"`
164+
Nhid int `json:"nhid"`
165+
Metric int `json:"metric"`
166+
Flags []any `json:"flags"`
167+
Nexthops []IPRouteNexthop `json:"nexthops"`
168+
}
169+
170+
func checkRoutesOnNodes(nodes []corev1.Node, want string) error {
171+
isIPv6 := func(address string) bool {
172+
ip, _, _ := net.ParseCIDR(address)
173+
return ip != nil && ip.To4() == nil // Valid IP and not an IPv4 address
174+
}
175+
176+
for _, n := range nodes {
177+
cmd := "ip --json route show proto bgp"
178+
if isIPv6(want) {
179+
cmd = "ip --json -6 route show proto bgp"
180+
}
181+
out, err := exec.Command(executor.ContainerRuntime,
182+
"exec", n.GetName(), "/bin/bash", "-c", cmd).CombinedOutput()
183+
if err != nil {
184+
return fmt.Errorf("%s - %w", out, err)
185+
}
186+
var routes []IPRoute
187+
if err := json.Unmarshal([]byte(out), &routes); err != nil {
188+
return fmt.Errorf("Error unmarshaling JSON: %v", err)
189+
}
190+
for _, r := range routes {
191+
if r.Dst == want {
192+
return nil
193+
}
194+
}
195+
return fmt.Errorf("local k8s node route %s was not found", want)
196+
}
197+
return nil
198+
}

0 commit comments

Comments
 (0)