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

Add endpoint workload filters #794

Merged
merged 3 commits into from
Oct 13, 2022

Conversation

chancez
Copy link
Contributor

@chancez chancez commented Oct 6, 2022

This adds support to Hubble CLI for filtering against endpoints workloads
The server side of this was implemented in cilium/cilium#21296

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label PR is blocked until the release note is set label Oct 6, 2022
@chancez
Copy link
Contributor Author

chancez commented Oct 7, 2022

Need to also figure out if this works correctly with --workload "". For "any workload". I special cased *, but I have a feeling the default is "" so it's always selecting pods with workloads currently.

cmd/observe/workload.go Outdated Show resolved Hide resolved
cmd/observe/workload.go Outdated Show resolved Hide resolved
@kaworu kaworu added the release-note/minor This PR introduces functionality that users may find relevant to operating Hubble. label Oct 7, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label PR is blocked until the release note is set label Oct 7, 2022
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

CI complains seems legit (I tested it and it's pulling LICENSE.txt files):

please run 'go mod tidy && go mod vendor', and submit your changes

@chancez
Copy link
Contributor Author

chancez commented Oct 7, 2022

Apparently my global gitignore ignores license.txt and that's how that happened 😓

@chancez
Copy link
Contributor Author

chancez commented Oct 7, 2022

So far I think the flag properly handles the difference between --workload "" and not specifying the flag at all, so my remaining question is should I keep * as a synonym for --workload "" or just use one or the other? My thinking with * was that it might be a bit more obvious than "" meaning "any flow with workloads".

@kaworu
Copy link
Member

kaworu commented Oct 7, 2022

@chancez I feel conflicted about *. On one hand it make sense and on the other hand it's inconsistent with other * wildcard that can be used by the Hubble CLI. For example, in both the FQDN and namespace filters * can be used for partial matches (e.g. *.cilium.io and k8s*, respectively) while we can't do that for workload (as the filter is a strict match on the server side).

Now we could change the workload filter on the server side to support partial matching but I don't think it makes a lot of sense for workloads, and also we could still do that later if need be (it would be a backward compatible change).

If we elect to support * then I think we should consider supporting both */foo-deploy (same behaviour as foo-deploy) and Deployment/* (same behaviour as Deployment/).

cc @rolinh @gandro

@chancez
Copy link
Contributor Author

chancez commented Oct 7, 2022

Then maybe to start we remove * and support just "" for the use-case and we can see if we want to do partial matching in the future.

@chancez
Copy link
Contributor Author

chancez commented Oct 7, 2022

i updated cilium in hubble and now this fails:

15
    flows_test.go:37: 
16
        	Error Trace:	/home/runner/work/hubble/hubble/cmd/observe/flows_test.go:37
17
        	Error:      	"[capture drop l7 policy-verdict trace]" should have 6 item(s), but has 5
18
        	Test:       	TestEventTypes

This is because my update to cilium adds a new event type

+       // MessageTypeTraceSock is a BPF datapath notification carrying a TraceNotifySock
+       // which corresponds to trace_sock_notify defined in bpf/lib/trace_sock.h
+       MessageTypeTraceSock

do we need this as an option in the CLI event types?

@kaworu kaworu added the :basecamp: needs-rebase This PR needs to be rebased because it has merge conflicts. label Oct 10, 2022
@gandro
Copy link
Member

gandro commented Oct 10, 2022

I agree with just supporting "" for now. It allows us to extend the expression logic in the future if we ever decide we want to support "foo*" serverside.

@rolinh
Copy link
Member

rolinh commented Oct 10, 2022

i updated cilium in hubble and now this fails:

15
    flows_test.go:37: 
16
        	Error Trace:	/home/runner/work/hubble/hubble/cmd/observe/flows_test.go:37
17
        	Error:      	"[capture drop l7 policy-verdict trace]" should have 6 item(s), but has 5
18
        	Test:       	TestEventTypes

This is because my update to cilium adds a new event type

+       // MessageTypeTraceSock is a BPF datapath notification carrying a TraceNotifySock
+       // which corresponds to trace_sock_notify defined in bpf/lib/trace_sock.h
+       MessageTypeTraceSock

do we need this as an option in the CLI event types?

Ah, CI working as expected 🙂 I'm not sure about what level of support is expected for MessageTypeTraceSock from the Hubble CLI. cc @aditighag who authored cilium/cilium#20492 and is working on the follow-ups (cilium/cilium#21510).

@gandro
Copy link
Member

gandro commented Oct 10, 2022

Yes, we want to add the trace sock events as well, but the server-side code is still missing. The Hubble portion is on my TODO list at the moment.

@rolinh
Copy link
Member

rolinh commented Oct 10, 2022

@gandro So to answer Chance's question (and have CI happy), the fix would be to add monitorAPI.MessageTypeTraceSock to flowEventTypes in cmd/observe/flows.go it seems.

@chancez
Copy link
Contributor Author

chancez commented Oct 10, 2022

@gandro So to answer Chance's question (and have CI happy), the fix would be to add monitorAPI.MessageTypeTraceSock to flowEventTypes in cmd/observe/flows.go it seems.

Even if it isn't supported on the server? The other option is to just adjust the test.

@gandro
Copy link
Member

gandro commented Oct 10, 2022

@gandro So to answer Chance's question (and have CI happy), the fix would be to add monitorAPI.MessageTypeTraceSock to flowEventTypes in cmd/observe/flows.go it seems.

Even if it isn't supported on the server? The other option is to just adjust the test.

Ah, I thought the error was due to the list of possible values is being pulled in via vendor (which I think we used to). But I was wrong, we maintain our own list here and ensure it's kept up to date via test. In that case, yes, we should adjust the test, and add TraceSock to the test's exclude list.

Sorry about that, I should have read the failing test first.

@aditighag
Copy link
Member

aditighag commented Oct 10, 2022

@chancez @gandro I don't have context on the Hubble side much. Based on Sebastian's last comment, I presume this PR needs to be extended to exclude TraceSock? @rolinh If that's the case, do you still need me assigned to this PR?
Thanks Sebastian for chiming in!

@rolinh rolinh removed the request for review from aditighag October 10, 2022 15:43
@chancez chancez force-pushed the pr/chancez/workload_filter branch 2 times, most recently from 38ff5b7 to 46aaea9 Compare October 10, 2022 16:15
@chancez chancez marked this pull request as ready for review October 10, 2022 17:30
@chancez chancez requested review from a team as code owners October 10, 2022 17:30
@chancez chancez requested review from a team as code owners October 10, 2022 17:30
@chancez chancez requested review from rolinh and nbusseneau and removed request for a team October 10, 2022 17:30
@chancez
Copy link
Contributor Author

chancez commented Oct 10, 2022

Updated tests and I removed the usage of *.

go.mod Show resolved Hide resolved
@kaworu kaworu added 🌟 kind/feature This introduces new functionality. and removed :basecamp: needs-rebase This PR needs to be rebased because it has merge conflicts. labels Oct 11, 2022
Also updates flow tests to exclude trace-sock message type

We need an updated cilium from master so that we can pull in the newest
protobufs with the TraceContext field.

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Thanks @chancez LGTM. One more nit on the way: about the first commit ("go.{mod,sum},vendor: Update cilium") can we have the cilium version updated to in the commit message please? Make it a bit easier to track without having to look at the diff.

This adds support to Hubble CLI for filtering against endpoints workloads
The server side of this was implemented in cilium/cilium#21296

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
This will aid debugging if improperly vendored

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
Copy link
Member

@nbusseneau nbusseneau left a comment

Choose a reason for hiding this comment

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

ci-structure was pinged due to a trivial change in workflow files, acking without looking further.

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Oct 13, 2022
@michi-covalent michi-covalent merged commit 701d9f9 into cilium:master Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 kind/feature This introduces new functionality. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/minor This PR introduces functionality that users may find relevant to operating Hubble.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants