Skip to content
New issue

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

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

Already on GitHub? # to your account

Add option to tetra to filter on event types #1549

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

darox
Copy link
Contributor

@darox darox commented Oct 3, 2023

This commit adds the ability to filter on the event types.

Implement the ability to filter on event types in the getevents CLI.

@darox darox requested a review from a team as a code owner October 3, 2023 13:07
@darox darox requested a review from kevsecurity October 3, 2023 13:07
@darox darox marked this pull request as draft October 3, 2023 13:07
@darox darox force-pushed the add-event-type-filter branch from 56662a7 to 39aeb06 Compare October 3, 2023 13:30
@willfindlay willfindlay added the release-note/minor This PR introduces a minor user-visible change label Oct 3, 2023
@willfindlay willfindlay self-requested a review October 3, 2023 13:32
@darox darox force-pushed the add-event-type-filter branch 3 times, most recently from 5ba3f39 to 3ba593d Compare October 3, 2023 15:54
@darox darox marked this pull request as ready for review October 3, 2023 15:55
@darox darox force-pushed the add-event-type-filter branch 2 times, most recently from f024511 to defead4 Compare October 4, 2023 07:12
@darox
Copy link
Contributor Author

darox commented Oct 4, 2023

Go tests fail but locally they're passing:

ok      github.com/cilium/tetragon/cmd/tetra/getevents  0.025s

Tests locally also fail when running with:

go test -p 1 -parallel 1  -gcflags= -timeout 40m -failfast -cover ./pkg/... ./cmd/... ./operator/... 

Running tests with:

go test -p 1 -parallel 1  -cover ./pkg/... ./cmd/... ./operator/...

The following also works:

go test -p 1 -parallel 1  -gcflags=  -cover ./pkg/... ./cmd/... ./operator/...

This as well:

go test -p 1 -parallel 1  -gcflags=  -cover -failfast ./pkg/... ./cmd/... ./operator/... 

It seems that -timeout 40 is the problem

@mtardy
Copy link
Member

mtardy commented Oct 4, 2023

Hey!! Thanks! I have this in the test right now:

Error: invalid value for "event-types" flag: INEXISTENT. Supported are UNDEF, PROCESS_KPROBE, PROCESS_TRACEPOINT, PROCESS_UPROBE, TEST, RATE_LIMIT_INFO, PROCESS_EXEC, PROCESS_EXIT, PROCESS_LOADER
Usage:
  getevents [flags]

Flags:
      --color string             Colorize compact output. auto, always, or never (default "auto")
  -e, --event-types strings      Include only events of given types
  -F, --exclude-fields strings   Exclude fields from events
  -h, --help                     help for getevents
      --host                     Get host events
  -f, --include-fields strings   Include only fields in events
  -n, --namespaces strings       Get events by Kubernetes namespaces
  -o, --output string            Output format. json or compact (default "json")
      --pods strings             Get events by pods name regex
      --processes strings        Get events by processes name regex
      --timestamps               Include timestamps in compact output
  -t, --tty-encode string        Encode terminal data by file path (all other events will be ignored)

panic: write |1: broken pipe

goroutine 8 [running]:
github.com/cilium/tetragon/pkg/testutils.MockPipedFile.func1()
	/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/testutils/cmd.go:153 +0xe5
created by github.com/cilium/tetragon/pkg/testutils.MockPipedFile in goroutine 7
	/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/testutils/cmd.go:147 +0xf7
FAIL	github.com/cilium/tetragon/cmd/tetra/getevents	0.025s

So I guess there may be an issue on how the one supposed to fail/do nothing is written or return.

@darox
Copy link
Contributor Author

darox commented Oct 4, 2023

I did some more testing, and apparently, it's a flake. Because sometimes it works even with:

go test -p 1 -parallel 1  -gcflags= -timeout 40m -failfast -cover ./pkg/... ./cmd/... ./operator/...

Result

ok      github.com/cilium/tetragon/cmd/tetra/getevents  0.023s  coverage: 78.6% of statements

Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

This should fix your test case failing! :) And a small comment.

@netlify
Copy link

netlify bot commented Oct 5, 2023

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit 835e206
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/651eb6eeac46bf00089953a4
😎 Deploy Preview https://deploy-preview-1549--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mtardy
Copy link
Member

mtardy commented Oct 5, 2023

Could you squash your commit into the first one? :) thanks!!

take this opportunity to also start the commit message with cmd/tetra: ....

This commit adds the ability to filter on the event types.

Signed-off-by: darox <maderdario@gmail.com>
@darox darox force-pushed the add-event-type-filter branch from 4b43bc2 to 01b4fbc Compare October 5, 2023 19:23
@darox
Copy link
Contributor Author

darox commented Oct 5, 2023

Could you squash your commit into the first one? :) thanks!!

take this opportunity to also start the commit message with cmd/tetra: ....

done

Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

Thanks a lot for taking the time to implement that! :) 🎉 🌮

I'll let @willfindlay approve/merge.

@darox
Copy link
Contributor Author

darox commented Oct 6, 2023

Thanks a lot for taking the time to implement that! :) 🎉 🌮

I'll let @willfindlay approve/merge.

No problem. It was a pleasure to work on the first PR for tetragon.

@willfindlay willfindlay merged commit fb26d23 into cilium:main Oct 6, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
release-note/minor This PR introduces a minor user-visible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants