Skip to content

Commit

Permalink
connectivity: Add checks for drops due to missed tail calls
Browse files Browse the repository at this point in the history
The test case is protected with --include-upgrade-test, as it's only
relevant in the context of Cilium upgrades.

Signed-off-by: Martynas Pumputis <[email protected]>
  • Loading branch information
brb committed Jun 20, 2023
1 parent 171bed0 commit aedcb13
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions connectivity/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch
// include --include-upgrade-tests"
return ct.Run(ctx)
}

ct.NewTest("no-missed-tail-calls").WithScenarios(tests.NoMissedTailCalls())
}

// Run all tests without any policies in place.
Expand Down
46 changes: 46 additions & 0 deletions connectivity/tests/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ package tests

import (
"context"
"strconv"
"strings"
"time"

"github.com/cilium/cilium-cli/connectivity/check"
"github.com/cilium/cilium-cli/defaults"
)

// NoErrorsInLogs checks whether there are no error messages in cilium-agent
Expand Down Expand Up @@ -41,6 +43,50 @@ func (n *noErrorsInLogs) Run(ctx context.Context, t *check.Test) {

}

// NoMissedTailCalls checks whether there were no drops due to missed (BPF)
// tail calls.
func NoMissedTailCalls() check.Scenario {
return &noMissedTailCalls{}
}

type noMissedTailCalls struct{}

func (n *noMissedTailCalls) Name() string {
return "no-missed-tail-calls"
}

func (n *noMissedTailCalls) Run(ctx context.Context, t *check.Test) {
ct := t.Context()
cmd := []string{
"/bin/sh", "-c",
"cilium metrics list -o json | jq '.[] | select( .name == \"cilium_drop_count_total\" and .labels.reason == \"Missed tail call\" ).value'",
}

for _, pod := range ct.CiliumPods() {
pod := pod
stdout, err := pod.K8sClient.ExecInPod(ctx, pod.Pod.Namespace, pod.Pod.Name, defaults.AgentContainerName, cmd)
if err != nil {
t.Fatalf("Error fetching missed tail call drop counts: %s", err)
}
countStr := stdout.String()
t.NewAction(n, pod.Pod.Name, nil, nil, check.IPFamilyNone).Run(func(a *check.Action) {
if countStr == "" {
return
}

count, err := strconv.Atoi(countStr)
if err != nil {
a.Fatalf("Failed to convert missed tail call drops %q to int: %s", countStr, err)
}

if count != 0 {
a.Fatalf("Detected drops due to missed tail calls: %d", count)
}
})
}

}

func checkErrorsInLogs(logs string, a *check.Action) {
uniqueFailures := make(map[string]int)
for _, msg := range strings.Split(logs, "\n") {
Expand Down

0 comments on commit aedcb13

Please sign in to comment.