Skip to content

Commit 0ef7f27

Browse files
committed
dump conntrack table on e2e conntrack failures
Signed-off-by: Antonio Ojea <[email protected]>
1 parent db8a887 commit 0ef7f27

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/e2e/network/conntrack.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package network
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"strings"
2223
"time"
@@ -116,6 +117,9 @@ var _ = SIGDescribe("Conntrack", func() {
116117
})
117118

118119
ginkgo.It("should be able to preserve UDP traffic when server pod cycles for a NodePort service", func() {
120+
// TODO(#91236): Remove once the test is debugged and fixed.
121+
// dump conntrack table for debugging
122+
defer dumpConntrack(cs)
119123

120124
// Create a NodePort service
121125
udpJig := e2eservice.NewTestJig(cs, ns, serviceName)
@@ -193,6 +197,9 @@ var _ = SIGDescribe("Conntrack", func() {
193197
})
194198

195199
ginkgo.It("should be able to preserve UDP traffic when server pod cycles for a ClusterIP service", func() {
200+
// TODO(#91236): Remove once the test is debugged and fixed.
201+
// dump conntrack table for debugging
202+
defer dumpConntrack(cs)
196203

197204
// Create a ClusterIP service
198205
udpJig := e2eservice.NewTestJig(cs, ns, serviceName)
@@ -269,3 +276,24 @@ var _ = SIGDescribe("Conntrack", func() {
269276
}
270277
})
271278
})
279+
280+
func dumpConntrack(cs clientset.Interface) {
281+
// Dump conntrack table of each node for troubleshooting using the kube-proxy pods
282+
namespace := "kube-system"
283+
pods, err := cs.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{})
284+
if err != nil || len(pods.Items) == 0 {
285+
framework.Logf("failed to list kube-proxy pods in namespace: %s", namespace)
286+
return
287+
}
288+
cmd := "conntrack -L"
289+
for _, pod := range pods.Items {
290+
if strings.Contains(pod.Name, "kube-proxy") {
291+
stdout, err := framework.RunHostCmd(namespace, pod.Name, cmd)
292+
if err != nil {
293+
framework.Logf("Failed to dump conntrack table of node %s: %v", pod.Spec.NodeName, err)
294+
continue
295+
}
296+
framework.Logf("conntrack table of node %s: %s", pod.Spec.NodeName, stdout)
297+
}
298+
}
299+
}

0 commit comments

Comments
 (0)