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 K8S events and pod configuration on K8S based tests #1637

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

Molter73
Copy link
Collaborator

@Molter73 Molter73 commented Apr 18, 2024

Description

#1606 added some basic K8S based tests. Because the amount of changes needed for those to work were significant, I decided to postpone adding anything that was not absolutely necessary for the tests to work. Now that those have been merged to master, it's a great time to improve them a bit and make them easier to work with.

This PR makes it so alongside the collector logs for the tests, the events for the involved namespaces and the pod configuration used by pods are also dumped in order to provide more details when a deeper issue arises and no logs are available. The one "downside" to the approach is the dumped events and configuration are in JSON format, since that seemed like the easiest to get working, using jq and/or grep should make it relatively easy to get any required information, a couple example queries for jq have been added to the tests docs as examples.

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

Ran the tests manually and checked the new logs are created.

@Molter73 Molter73 requested a review from a team as a code owner April 18, 2024 18:29
@Molter73 Molter73 force-pushed the mauro/improve-k8s-tests-debuggability branch from 1b376a3 to c69f532 Compare April 19, 2024 11:32
Copy link
Collaborator

@Stringy Stringy left a comment

Choose a reason for hiding this comment

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

one minor typo, but otherwise LGTM!


### Get all events from the collector pod
```sh
$ jq 'select(.involvedObject.name == "collector")' core-bpf/TestK8sNamespace-collector-tests-events.jsonl
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
$ jq 'select(.involvedObject.name == "collector")' core-bpf/TestK8sNamespace-collector-tests-events.jsonl
$ jq 'select(.involvedObject.name == "collector")' core-bpf/TestK8sNamespace-collector-tests-events.json

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's actually not a typo, it's intentional 😅
https://jsonlines.org/

@Molter73 Molter73 merged commit d08f3d6 into master Apr 22, 2024
51 checks passed
@Molter73 Molter73 deleted the mauro/improve-k8s-tests-debuggability branch April 22, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants