Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectivity: Add checks for agent error logs and drops due to missed tail calls #1736

Merged
merged 2 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably out of scope, but I wonder if we could generalize that to more than just the upgrade and more than just missed tail calls drops. There are a lot of drops that we never expect to see. In a sense, they are the same as level=error log messages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good idea. Maybe let's start an issue to collect all thoughts?

}

// Run all tests without any policies in place.
Expand Down
44 changes: 44 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 @@ -39,6 +41,48 @@ 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()
if countStr == "" {
return
}

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

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

}

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