@@ -3933,24 +3933,28 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
3933
3933
err := cs .CoreV1 ().Pods (f .Namespace .Name ).Delete (context .TODO (), podName , metav1.DeleteOptions {})
3934
3934
framework .ExpectNoError (err , "failed to delete pod: %s in namespace: %s" , podName , f .Namespace .Name )
3935
3935
}()
3936
-
3937
- ginkgo .By ("dumping iptables rules on the node" )
3936
+ // wait until host port manager syncs rules
3938
3937
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"
3943
3940
}
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
+ }
3944
3948
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
+ }
3951
3953
}
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 {
3954
3958
framework .Failf ("iptables rules are not set for a pod with sctp hostport" )
3955
3959
}
3956
3960
ginkgo .By ("validating sctp module is still not loaded" )
@@ -3989,28 +3993,31 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
3989
3993
3990
3994
err = e2enetwork .WaitForService (f .ClientSet , ns , serviceName , true , 5 * time .Second , e2eservice .TestTimeout )
3991
3995
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" )
3994
3996
hostExec := utils .NewHostExec (f )
3995
3997
defer hostExec .Cleanup ()
3996
3998
node , err := e2enode .GetRandomReadySchedulableNode (cs )
3997
3999
framework .ExpectNoError (err )
3998
4000
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"
4003
4003
}
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
+ }
4004
4011
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
+ }
4011
4016
}
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 {
4014
4021
framework .Failf ("iptables rules are not set for a clusterip service with sctp ports" )
4015
4022
}
4016
4023
ginkgo .By ("validating sctp module is still not loaded" )
0 commit comments