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

UUID filter #919

Merged
merged 2 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions cmd/observe/flows.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ func newFlowsCmdHelper(usage cmdUsage, vp *viper.Viper, ofilter *flowFilter) *co
filterFlags.Var(filterVar(
"not", ofilter,
"Reverses the next filter to be blacklist i.e. --not --from-ip 2.2.2.2"))
filterFlags.Var(filterVar(
"uuid", ofilter,
"Show the only flow matching this unique flow identifier, if any"))
filterFlags.Var(filterVar(
"node-name", ofilter,
`Show all flows which match the given node names (e.g. "k8s*", "test-cluster/*.company.com")`))
Expand Down
6 changes: 6 additions & 0 deletions cmd/observe/flows_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func newFlowFilter() *flowFilter {
{"workload", "from-workload"},
{"node-name"},
{"tcp-flags"},
{"uuid"},
},
}
}
Expand Down Expand Up @@ -265,6 +266,11 @@ func (of *flowFilter) set(f *filterTracker, name, val string, track bool) error
}

switch name {
// flow identifier filter
case "uuid":
f.apply(func(f *flowpb.FlowFilter) {
f.Uuid = append(f.Uuid, val)
})
// fqdn filters
case "fqdn":
f.applyLeft(func(f *flowpb.FlowFilter) {
Expand Down
17 changes: 17 additions & 0 deletions cmd/observe/flows_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,20 @@ func TestTcpFlags(t *testing.T) {
require.Error(t, cmd.Flags().Parse([]string{"--tcp-flags", f}))
}
}

func TestUuid(t *testing.T) {
f := newFlowFilter()
cmd := newFlowsCmdWithFilter(viper.New(), f)

require.NoError(t, cmd.Flags().Parse([]string{"--uuid", "b9fab269-04ae-495c-9d12-b6c36d41de0d"}))
if diff := cmp.Diff(
[]*flowpb.FlowFilter{
{Uuid: []string{"b9fab269-04ae-495c-9d12-b6c36d41de0d"}},
},
f.whitelist.flowFilters(),
cmpopts.IgnoreUnexported(flowpb.FlowFilter{}),
); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
}
assert.Nil(t, f.blacklist)
}
1 change: 1 addition & 0 deletions cmd/observe_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Filters Flags:
to-proxy
to-stack
trace-sock n/a
--uuid filter Show the only flow matching this unique flow identifier, if any
--verdict filter Show only flows with this verdict [FORWARDED, DROPPED, AUDIT, REDIRECTED, ERROR, TRACED, TRANSLATED]
--workload filter Show all flows related to an endpoint with the given workload

Expand Down
19 changes: 10 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/cilium/hubble
go 1.19

require (
github.com/cilium/cilium v1.13.0-rc5
github.com/cilium/cilium v1.14.0-snapshot.0
github.com/fatih/color v1.14.1
github.com/google/go-cmp v0.5.9
github.com/sirupsen/logrus v1.9.0
Expand Down Expand Up @@ -34,7 +34,7 @@ require (
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/runtime v0.25.0 // indirect
github.com/go-openapi/spec v0.20.7 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.22.0 // indirect
Expand Down Expand Up @@ -63,39 +63,40 @@ require (
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil/v3 v3.22.10 // indirect
github.com/shirou/gopsutil/v3 v3.23.1 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/vishvananda/netlink v1.2.1-beta.2.0.20220608195807-1a118fe229fc // indirect
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.mongodb.org/mongo-driver v1.10.0 // indirect
go.opentelemetry.io/otel v1.11.2 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
go.opentelemetry.io/otel v1.12.0 // indirect
go.opentelemetry.io/otel/trace v1.12.0 // indirect
golang.org/x/exp v0.0.0-20221106115401-f9659909a136 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.2.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.26.0 // indirect
k8s.io/client-go v0.26.0 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)

// Replace directives from github.com/cilium/cilium. Keep in sync when updating Cilium!
replace (
github.com/miekg/dns => github.com/cilium/dns v1.1.51-0.20220729113855-5b94b11b46fc
github.com/optiopay/kafka => github.com/cilium/kafka v0.0.0-20180809090225-01ce283b732b
go.universe.tf/metallb => github.com/cilium/metallb v0.1.1-0.20220829170633-5d7dfb1129f7
sigs.k8s.io/controller-tools => github.com/cilium/controller-tools v0.6.2
)
42 changes: 22 additions & 20 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading