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

Collect Gloo metrics and some snapshots on test failure #10400

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ryanrolds
Copy link

@ryanrolds ryanrolds commented Nov 23, 2024

Description

I've encountered a couple of cases where this information would have been helpful in debugging

  • Adds collection of Gloo controller metrics, xds snapshot, and krt snapshot

Interesting decisions

I wanted to use the ephemeral debug containers and had to first fetch the pod name because
kubectl debug doesn't support deployment/gloo as a pod.

Testing steps

Take a look at the artifacts found this failed test.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@@ -225,6 +225,8 @@ func (s *testingSuite) TestConfigureVirtualHostOptionsWithSectionNameManualSetup
[]string{"conflict with more specific or older VirtualHostOptions"},
defaults.KubeGatewayReporter,
)

s.Assert().Equal(true, false, "intentionally failing to trigger drump, remove when done debugging")
Copy link
Author

Choose a reason for hiding this comment

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

I will be removing this after I have an artifact example to link.

Comment on lines +322 to +332
// Fetch the name of the Gloo Gateway controller pod
getGlooPodNameCmd := i.Actions.Kubectl().Command(ctx, "get", "pod", "-n", i.Metadata.InstallNamespace,
"--selector", "gloo=gloo", "--output", "jsonpath='{.items[0].metadata.name}'")
_ = getGlooPodNameCmd.WithStdout(podStdOut).WithStderr(podStdErr).Run()

// Clean up and check the output
glooPodName := strings.Trim(podStdOut.String(), "'")
if glooPodName == "" {
fmt.Printf("Failed to get the name of the Gloo Gateway controller pod: %s\n", podStdErr.String())
return
}
Copy link
Author

Choose a reason for hiding this comment

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

Happy to make this it's own method if we think we will need it more than in this case.

@ryanrolds ryanrolds marked this pull request as ready for review November 23, 2024 01:42
Copy link

Visit the preview URL for this PR (updated for commit e2b43ec):

https://gloo-edge--pr10400-rolds-test-failure-c-kkld9hrb.web.app

(expires Sat, 30 Nov 2024 01:54:49 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 77c2b86e287749579b7ff9cadb81e099042ef677

Comment on lines +339 to +356
// Using an ephemeral debug pod fetch the metrics from the Gloo Gateway controller
metricsCmd := i.Actions.Kubectl().Command(ctx, "debug", "-n", i.Metadata.InstallNamespace,
"-it", "--image=curlimages/curl:7.83.1", glooPodName, "--",
"curl", "http://localhost:9091/metrics")
_ = metricsCmd.WithStdout(metricsFile).WithStderr(metricsFile).Run()
metricsFile.Close()

// Get krt snapshot from the Gloo Gateway controller pod and write it to a file
krtSnapshotFilePath := filepath.Join(failureDir, "krt_snapshot.log")
krtSnapshotFile, err := os.OpenFile(krtSnapshotFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, os.ModePerm)
i.Assertions.Require.NoError(err)

// Using an ephemeral debug pod fetch the krt snapshot from the Gloo Gateway controller
krtSnapshotCmd := i.Actions.Kubectl().Command(ctx, "debug", "-n", i.Metadata.InstallNamespace,
"-it", "--image=curlimages/curl:7.83.1", glooPodName, "--",
"curl", "http://localhost:9095/snapshots/krt")
_ = krtSnapshotCmd.WithStdout(krtSnapshotFile).WithStderr(krtSnapshotFile).Run()
krtSnapshotFile.Close()
Copy link
Collaborator

Choose a reason for hiding this comment

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

while these make sense it would be ideal if we could add them to the main admin gloo endpoint tooling as its a pretty general case. I know its annoying to do it on a first pass (ie one case) but Im pretty sure I would love to have it on all cases

https://github.com/solo-io/gloo/blob/main/test/helpers/kube_dump.go#L46 is an example of our end dump and it includes hitting the stats endpoint like https://github.com/solo-io/gloo/blob/main/test/helpers/kube_dump.go#L311 which would be a nice setup that we can add to these types of tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants