Skip to content

Commit 3a1d605

Browse files
committed
chore(gc): quarantine ip_port_mapping test
Signed-off-by: SkalaNetworks <contact@skala.network>
1 parent 029b110 commit 3a1d605

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

pkg/controller/gc.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (c *Controller) gc() error {
5151
c.gcVip,
5252
c.gcLbSvcPods,
5353
c.gcVPCDNS,
54-
c.gcOvnLb,
54+
c.gcIpPortMapping,
5555
}
5656
for _, gcFunc := range gcFunctions {
5757
if err := gcFunc(); err != nil {
@@ -1191,15 +1191,10 @@ func (c *Controller) gcLbSvcPods() error {
11911191
return nil
11921192
}
11931193

1194-
// gcOvnLb handles cleaning up loadbalancers created by SwitchLBRules/EndpointSlices
1195-
// For every LB present in OVN, we make sure:
1196-
// - the ip_port_mappings are not stale (they're used by a VIP)
1197-
// - TODO: the VIPs are linked to an EndpointSlice and are not stale
1198-
// - TODO: the healthchecks are linked to an EndpointSlice and are not stale
1199-
// Right now, if the controller is down while EPs are getting deleted, the VIPs will not be cleaned
1200-
// and the healthchecks will not be cleaned. This can lead to dangling resources in OVN.
1201-
func (c *Controller) gcOvnLb() error {
1202-
klog.Infof("start to gc ovn load balancers")
1194+
// gcIpPortMapping handles cleaning up ip_port_mappings created by SwitchLBRules/EndpointSlices
1195+
// For every LB present in OVN, we make sure the ip_port_mappings are not stale (they're used by a VIP)
1196+
func (c *Controller) gcIpPortMapping() error {
1197+
klog.Infof("start to gc ovn load balancers ip_port_mappings")
12031198
lbs, err := c.OVNNbClient.ListLoadBalancers(func(lb *ovnnb.LoadBalancer) bool {
12041199
return lb.ExternalIDs["vendor"] == util.CniTypeName
12051200
})

pkg/controller/gc_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ func Test_gcOvnLb(t *testing.T) {
115115
fakeCtrl.mockOvnClient.EXPECT().LoadBalancerDeleteIPPortMapping("lb2", "192.168.2.2").Return(nil)
116116
fakeCtrl.mockOvnClient.EXPECT().LoadBalancerDeleteIPPortMapping("lb3", "fd00::102").Return(nil)
117117

118-
err := fakeCtrl.fakeController.gcOvnLb()
118+
err := fakeCtrl.fakeController.gcIpPortMapping()
119119
if err != nil {
120-
t.Errorf("gcOvnLb() error = %v", err)
120+
t.Errorf("gcIpPortMapping() error = %v", err)
121121
}
122122
})
123123

@@ -138,9 +138,9 @@ func Test_gcOvnLb(t *testing.T) {
138138
fakeCtrl.mockOvnClient.EXPECT().ListLoadBalancers(gomock.Any()).Return([]ovnnb.LoadBalancer{*lb}, nil)
139139
// No LoadBalancerDeleteIPPortMapping expected
140140

141-
err := fakeCtrl.fakeController.gcOvnLb()
141+
err := fakeCtrl.fakeController.gcIpPortMapping()
142142
if err != nil {
143-
t.Errorf("gcOvnLb() error = %v", err)
143+
t.Errorf("gcIpPortMapping() error = %v", err)
144144
}
145145
})
146146
}

test/e2e/kube-ovn/gc/gc.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ var _ = framework.Describe("[group:gc]", func() {
6666
})
6767

6868
ginkgo.It("should gc stale ip_port_mappings in OVN LoadBalancer", func() {
69+
ginkgo.Skip("GC doesn't yet run periodically and can't be E2E tested")
6970
ginkgo.By("1. Creating a SwitchLBRule to populate LoadBalancer")
7071
labels := map[string]string{"app": "gc-test"}
7172
annotations := map[string]string{util.LogicalSwitchAnnotation: subnetName}
@@ -96,18 +97,21 @@ var _ = framework.Describe("[group:gc]", func() {
9697
framework.ExpectNotEmpty(lbName)
9798

9899
ginkgo.By("Verifying active ip_port_mapping exists for backend " + backendIP)
99-
cmd := []string{"ovn-nbctl", "get", "load_balancer", lbName, "ip_port_mappings"}
100-
stdout, _, err := framework.NBExec(cmd...)
101-
framework.ExpectNil(err)
102-
framework.ExpectContainSubstring(string(stdout), backendIP)
100+
framework.WaitUntil(5*time.Second, 2*time.Minute, func(_ context.Context) (bool, error) {
101+
cmd := []string{"ovn-nbctl", "get", "load_balancer", lbName, "ip_port_mappings"}
102+
stdout, _, err := framework.NBExec(cmd...)
103+
framework.ExpectNil(err)
104+
105+
return strings.Contains(string(stdout), backendIP), nil
106+
}, "we got correct ip_port_mappings")
103107

104108
ginkgo.By("3. Manually injecting a stale ip_port_mapping entry")
105109
staleIP := "1.2.3.4"
106110
staleMapping := "stale-node"
107111

108112
// Get existing mappings to ensure we don't overwrite them
109-
cmd = []string{"ovn-nbctl", "get", "load_balancer", lbName, "ip_port_mappings"}
110-
stdout, _, err = framework.NBExec(cmd...)
113+
cmd := []string{"ovn-nbctl", "get", "load_balancer", lbName, "ip_port_mappings"}
114+
stdout, _, err := framework.NBExec(cmd...)
111115
framework.ExpectNil(err)
112116
existingMappings := strings.TrimSpace(string(stdout))
113117

@@ -129,9 +133,9 @@ var _ = framework.Describe("[group:gc]", func() {
129133
}
130134

131135
ginkgo.By("4. Waiting for GC to clean up the stale entry")
132-
// The default GC interval might be long, but in E2E tests we expect the controller to be running.
133-
// If GC interval is e.g. 60s, we might need to wait.
134-
framework.WaitUntil(5*time.Second, 2*time.Minute, func(_ context.Context) (bool, error) {
136+
// Currently, the GC doesn't run periodically for this type of stuff...
137+
// This test can be used to test the GC by end, but not yet in E2E testing
138+
framework.WaitUntil(5*time.Second, 1*time.Minute, func(_ context.Context) (bool, error) {
135139
stdout, _, err = framework.NBExec(cmd...)
136140
if err != nil {
137141
return false, err

0 commit comments

Comments
 (0)