Skip to content

Commit ac519b4

Browse files
authored
Merge pull request kubernetes#94828 from aojea/sctpflake
Fix sctp job flakes
2 parents 33a07ca + 1dbf915 commit ac519b4

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

test/e2e/network/service.go

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,24 +3933,28 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
39333933
err := cs.CoreV1().Pods(f.Namespace.Name).Delete(context.TODO(), podName, metav1.DeleteOptions{})
39343934
framework.ExpectNoError(err, "failed to delete pod: %s in namespace: %s", podName, f.Namespace.Name)
39353935
}()
3936-
3937-
ginkgo.By("dumping iptables rules on the node")
3936+
// wait until host port manager syncs rules
39383937
cmd = "sudo iptables-save"
3939-
framework.Logf("Executing cmd %q on node %v", cmd, node.Name)
3940-
result, err := hostExec.IssueCommandWithResult(cmd, node)
3941-
if err != nil {
3942-
framework.Failf("Interrogation of iptables rules failed on node %v", node.Name)
3938+
if framework.TestContext.ClusterIsIPv6() {
3939+
cmd = "sudo ip6tables-save"
39433940
}
3941+
err = wait.PollImmediate(framework.Poll, framework.PollShortTimeout, func() (bool, error) {
3942+
framework.Logf("Executing cmd %q on node %v", cmd, node.Name)
3943+
result, err := hostExec.IssueCommandWithResult(cmd, node)
3944+
if err != nil {
3945+
framework.Logf("Interrogation of iptables rules failed on node %v", node.Name)
3946+
return false, nil
3947+
}
39443948

3945-
ginkgo.By("checking that iptables contains the necessary iptables rules")
3946-
found := false
3947-
for _, line := range strings.Split(result, "\n") {
3948-
if strings.Contains(line, "-p sctp") && strings.Contains(line, "--dport 5060") {
3949-
found = true
3950-
break
3949+
for _, line := range strings.Split(result, "\n") {
3950+
if strings.Contains(line, "-p sctp") && strings.Contains(line, "--dport 5060") {
3951+
return true, nil
3952+
}
39513953
}
3952-
}
3953-
if !found {
3954+
framework.Logf("retrying ... not hostport sctp iptables rules found on node %v", node.Name)
3955+
return false, nil
3956+
})
3957+
if err != nil {
39543958
framework.Failf("iptables rules are not set for a pod with sctp hostport")
39553959
}
39563960
ginkgo.By("validating sctp module is still not loaded")
@@ -3989,28 +3993,31 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
39893993

39903994
err = e2enetwork.WaitForService(f.ClientSet, ns, serviceName, true, 5*time.Second, e2eservice.TestTimeout)
39913995
framework.ExpectNoError(err, fmt.Sprintf("error while waiting for service:%s err: %v", serviceName, err))
3992-
3993-
ginkgo.By("dumping iptables rules on a node")
39943996
hostExec := utils.NewHostExec(f)
39953997
defer hostExec.Cleanup()
39963998
node, err := e2enode.GetRandomReadySchedulableNode(cs)
39973999
framework.ExpectNoError(err)
39984000
cmd := "sudo iptables-save"
3999-
framework.Logf("Executing cmd %q on node %v", cmd, node.Name)
4000-
result, err := hostExec.IssueCommandWithResult(cmd, node)
4001-
if err != nil {
4002-
framework.Failf("Interrogation of iptables rules failed on node %v", node.Name)
4001+
if framework.TestContext.ClusterIsIPv6() {
4002+
cmd = "sudo ip6tables-save"
40034003
}
4004+
err = wait.PollImmediate(framework.Poll, e2eservice.KubeProxyLagTimeout, func() (bool, error) {
4005+
framework.Logf("Executing cmd %q on node %v", cmd, node.Name)
4006+
result, err := hostExec.IssueCommandWithResult(cmd, node)
4007+
if err != nil {
4008+
framework.Logf("Interrogation of iptables rules failed on node %v", node.Name)
4009+
return false, nil
4010+
}
40044011

4005-
ginkgo.By("checking that iptables contains the necessary iptables rules")
4006-
kubeService := false
4007-
for _, line := range strings.Split(result, "\n") {
4008-
if strings.Contains(line, "-A KUBE-SERVICES") && strings.Contains(line, "-p sctp") {
4009-
kubeService = true
4010-
break
4012+
for _, line := range strings.Split(result, "\n") {
4013+
if strings.Contains(line, "-A KUBE-SERVICES") && strings.Contains(line, "-p sctp") {
4014+
return true, nil
4015+
}
40114016
}
4012-
}
4013-
if !kubeService {
4017+
framework.Logf("retrying ... no iptables rules found for service with sctp ports on node %v", node.Name)
4018+
return false, nil
4019+
})
4020+
if err != nil {
40144021
framework.Failf("iptables rules are not set for a clusterip service with sctp ports")
40154022
}
40164023
ginkgo.By("validating sctp module is still not loaded")

0 commit comments

Comments
 (0)