Skip to content

Commit 1dbf915

Browse files
author
Antonio Ojea
committed
wait until the iptables rules are programmed
1 parent 3eeed2f commit 1dbf915

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

test/e2e/network/service.go

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,27 +3998,28 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
39983998
err := cs.CoreV1().Pods(f.Namespace.Name).Delete(context.TODO(), podName, metav1.DeleteOptions{})
39993999
framework.ExpectNoError(err, "failed to delete pod: %s in namespace: %s", podName, f.Namespace.Name)
40004000
}()
4001-
4002-
ginkgo.By("dumping iptables rules on the node")
4001+
// wait until host port manager syncs rules
40034002
cmd = "sudo iptables-save"
40044003
if framework.TestContext.ClusterIsIPv6() {
40054004
cmd = "sudo ip6tables-save"
40064005
}
4007-
framework.Logf("Executing cmd %q on node %v", cmd, node.Name)
4008-
result, err := hostExec.IssueCommandWithResult(cmd, node)
4009-
if err != nil {
4010-
framework.Failf("Interrogation of iptables rules failed on node %v", node.Name)
4011-
}
4006+
err = wait.PollImmediate(framework.Poll, framework.PollShortTimeout, func() (bool, error) {
4007+
framework.Logf("Executing cmd %q on node %v", cmd, node.Name)
4008+
result, err := hostExec.IssueCommandWithResult(cmd, node)
4009+
if err != nil {
4010+
framework.Logf("Interrogation of iptables rules failed on node %v", node.Name)
4011+
return false, nil
4012+
}
40124013

4013-
ginkgo.By("checking that iptables contains the necessary iptables rules")
4014-
found := false
4015-
for _, line := range strings.Split(result, "\n") {
4016-
if strings.Contains(line, "-p sctp") && strings.Contains(line, "--dport 5060") {
4017-
found = true
4018-
break
4014+
for _, line := range strings.Split(result, "\n") {
4015+
if strings.Contains(line, "-p sctp") && strings.Contains(line, "--dport 5060") {
4016+
return true, nil
4017+
}
40194018
}
4020-
}
4021-
if !found {
4019+
framework.Logf("retrying ... not hostport sctp iptables rules found on node %v", node.Name)
4020+
return false, nil
4021+
})
4022+
if err != nil {
40224023
framework.Failf("iptables rules are not set for a pod with sctp hostport")
40234024
}
40244025
ginkgo.By("validating sctp module is still not loaded")
@@ -4057,8 +4058,6 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
40574058

40584059
err = e2enetwork.WaitForService(f.ClientSet, ns, serviceName, true, 5*time.Second, e2eservice.TestTimeout)
40594060
framework.ExpectNoError(err, fmt.Sprintf("error while waiting for service:%s err: %v", serviceName, err))
4060-
4061-
ginkgo.By("dumping iptables rules on a node")
40624061
hostExec := utils.NewHostExec(f)
40634062
defer hostExec.Cleanup()
40644063
node, err := e2enode.GetRandomReadySchedulableNode(cs)
@@ -4067,21 +4066,23 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
40674066
if framework.TestContext.ClusterIsIPv6() {
40684067
cmd = "sudo ip6tables-save"
40694068
}
4070-
framework.Logf("Executing cmd %q on node %v", cmd, node.Name)
4071-
result, err := hostExec.IssueCommandWithResult(cmd, node)
4072-
if err != nil {
4073-
framework.Failf("Interrogation of iptables rules failed on node %v", node.Name)
4074-
}
4069+
err = wait.PollImmediate(framework.Poll, e2eservice.KubeProxyLagTimeout, func() (bool, error) {
4070+
framework.Logf("Executing cmd %q on node %v", cmd, node.Name)
4071+
result, err := hostExec.IssueCommandWithResult(cmd, node)
4072+
if err != nil {
4073+
framework.Logf("Interrogation of iptables rules failed on node %v", node.Name)
4074+
return false, nil
4075+
}
40754076

4076-
ginkgo.By("checking that iptables contains the necessary iptables rules")
4077-
kubeService := false
4078-
for _, line := range strings.Split(result, "\n") {
4079-
if strings.Contains(line, "-A KUBE-SERVICES") && strings.Contains(line, "-p sctp") {
4080-
kubeService = true
4081-
break
4077+
for _, line := range strings.Split(result, "\n") {
4078+
if strings.Contains(line, "-A KUBE-SERVICES") && strings.Contains(line, "-p sctp") {
4079+
return true, nil
4080+
}
40824081
}
4083-
}
4084-
if !kubeService {
4082+
framework.Logf("retrying ... no iptables rules found for service with sctp ports on node %v", node.Name)
4083+
return false, nil
4084+
})
4085+
if err != nil {
40854086
framework.Failf("iptables rules are not set for a clusterip service with sctp ports")
40864087
}
40874088
ginkgo.By("validating sctp module is still not loaded")

0 commit comments

Comments
 (0)