@@ -3998,27 +3998,28 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
3998
3998
err := cs .CoreV1 ().Pods (f .Namespace .Name ).Delete (context .TODO (), podName , metav1.DeleteOptions {})
3999
3999
framework .ExpectNoError (err , "failed to delete pod: %s in namespace: %s" , podName , f .Namespace .Name )
4000
4000
}()
4001
-
4002
- ginkgo .By ("dumping iptables rules on the node" )
4001
+ // wait until host port manager syncs rules
4003
4002
cmd = "sudo iptables-save"
4004
4003
if framework .TestContext .ClusterIsIPv6 () {
4005
4004
cmd = "sudo ip6tables-save"
4006
4005
}
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
+ }
4012
4013
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
+ }
4019
4018
}
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 {
4022
4023
framework .Failf ("iptables rules are not set for a pod with sctp hostport" )
4023
4024
}
4024
4025
ginkgo .By ("validating sctp module is still not loaded" )
@@ -4057,8 +4058,6 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
4057
4058
4058
4059
err = e2enetwork .WaitForService (f .ClientSet , ns , serviceName , true , 5 * time .Second , e2eservice .TestTimeout )
4059
4060
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" )
4062
4061
hostExec := utils .NewHostExec (f )
4063
4062
defer hostExec .Cleanup ()
4064
4063
node , err := e2enode .GetRandomReadySchedulableNode (cs )
@@ -4067,21 +4066,23 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
4067
4066
if framework .TestContext .ClusterIsIPv6 () {
4068
4067
cmd = "sudo ip6tables-save"
4069
4068
}
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
+ }
4075
4076
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
+ }
4082
4081
}
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 {
4085
4086
framework .Failf ("iptables rules are not set for a clusterip service with sctp ports" )
4086
4087
}
4087
4088
ginkgo .By ("validating sctp module is still not loaded" )
0 commit comments