Skip to content

Commit 6d4434f

Browse files
brbtklauser
authored andcommitted
connectivity: Add --flush-ct
To flush CT of each Cilium node after running all connectivity tests. It's needed when running connectivity tests multiple times on the same cluster, and the L7 netpol tests might interfere with other tests [1]. [1]: cilium/cilium#17459 Signed-off-by: Martynas Pumputis <m@lambda.lt>
1 parent c166dab commit 6d4434f

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

connectivity/check/check.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ type Parameters struct {
6464
JunitFile string
6565
JunitProperties map[string]string
6666

67+
FlushCT bool
68+
6769
K8sVersion string
6870
HelmChartDirectory string
6971
HelmValuesSecretName string

connectivity/check/context.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os"
1414
"strconv"
1515
"strings"
16+
"sync"
1617
"time"
1718

1819
"github.com/blang/semver/v4"
@@ -383,6 +384,26 @@ func (ct *ConnectivityTest) Run(ctx context.Context) error {
383384
ct.Failf("writing to junit file %s failed: %s", ct.Params().JunitFile, err)
384385
}
385386

387+
if ct.Params().FlushCT {
388+
var wg sync.WaitGroup
389+
390+
wg.Add(len(ct.CiliumPods()))
391+
for _, ciliumPod := range ct.CiliumPods() {
392+
cmd := strings.Split("cilium bpf ct flush global", " ")
393+
go func(ctx context.Context, pod Pod) {
394+
defer wg.Done()
395+
396+
ct.Debugf("Flushing CT entries in %s/%s", pod.Pod.Namespace, pod.Pod.Name)
397+
_, err := pod.K8sClient.ExecInPod(ctx, pod.Pod.Namespace, pod.Pod.Name, defaults.AgentContainerName, cmd)
398+
if err != nil {
399+
ct.Fatal("failed to flush ct entries: %w", err)
400+
}
401+
}(ctx, ciliumPod)
402+
}
403+
404+
wg.Wait()
405+
}
406+
386407
// Report the test results.
387408
return ct.report()
388409
}

internal/cli/cmd/connectivity.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ func newCmdConnectivityTest(hooks Hooks) *cobra.Command {
172172

173173
initSysdumpFlags(cmd, &params.SysdumpOptions, "sysdump-", hooks)
174174

175+
cmd.Flags().BoolVar(&params.FlushCT, "flush-ct", false, "Flush conntrack of Cilium on each node")
176+
175177
hooks.AddConnectivityTestFlags(cmd.Flags())
176178

177179
return cmd

0 commit comments

Comments
 (0)