Skip to content

Commit

Permalink
Merge pull request #47 from msherif1234/ovs_monitor
Browse files Browse the repository at this point in the history
NETOBSERV-1640: add ovs monitoring feature to cli repo
  • Loading branch information
jpinsonneau committed Sep 16, 2024
2 parents ce58170 + 3d3a9cf commit 248df00
Show file tree
Hide file tree
Showing 1,454 changed files with 75,513 additions and 36,793 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pull_request_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ jobs:
- name: run end-to-end tests
run: make tests-e2e
- name: upload e2e test logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-logs
path: e2e-logs
path: |
e2e-logs
e2e/commands
e2e/output
36 changes: 25 additions & 11 deletions cmd/flow_capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ var (
regexes = []string{}
lastFlows = []config.GenericMap{}

rawDisplay = "Raw"
standardDisplay = "Standard"
pktDropDisplay = "PktDrop"
dnsDisplay = "DNS"
rttDisplay = "RTT"
display = []string{pktDropDisplay, dnsDisplay, rttDisplay}
rawDisplay = "Raw"
standardDisplay = "Standard"
pktDropDisplay = "PktDrop"
dnsDisplay = "DNS"
rttDisplay = "RTT"
networkEventsDisplay = "NetworkEvents"
display = []string{pktDropDisplay, dnsDisplay, rttDisplay, networkEventsDisplay}

noEnrichment = "None"
zoneEnrichment = "Zone"
Expand Down Expand Up @@ -196,7 +197,7 @@ func toSize(fieldName string) int {
return 40
case "DropState":
return 20
case "Time", "Interfaces", "SrcZone", "DstZone":
case "Time", "Interfaces", "SrcZone", "DstZone", "NetworkEvents":
return 16
case "DropBytes", "DropPackets", "SrcOwnerType", "DstOwnerType":
return 12
Expand Down Expand Up @@ -313,6 +314,11 @@ func updateTable() {
"RTT",
)
}
if slices.Contains(display, networkEventsDisplay) {
cols = append(cols,
"NetworkEvents",
)
}
} else {
cols = append(cols,
"Dir",
Expand Down Expand Up @@ -389,7 +395,8 @@ func scanner() {
flowsToShow = flowsToShow - 1
}
} else if key == keyboard.KeyArrowRight {
if slices.Contains(display, pktDropDisplay) && slices.Contains(display, dnsDisplay) && slices.Contains(display, rttDisplay) {
if slices.Contains(display, pktDropDisplay) && slices.Contains(display, dnsDisplay) &&
slices.Contains(display, rttDisplay) && slices.Contains(display, networkEventsDisplay) {
display = []string{rawDisplay}
} else if slices.Contains(display, rawDisplay) {
display = []string{standardDisplay}
Expand All @@ -398,23 +405,30 @@ func scanner() {
} else if slices.Contains(display, pktDropDisplay) {
display = []string{dnsDisplay}
} else if slices.Contains(display, dnsDisplay) {
display = []string{networkEventsDisplay}
} else if slices.Contains(display, networkEventsDisplay) {
display = []string{rttDisplay}
} else if slices.Contains(display, rttDisplay) {
display = []string{rawDisplay}
} else {
display = []string{pktDropDisplay, dnsDisplay, rttDisplay}
display = []string{pktDropDisplay, dnsDisplay, rttDisplay, networkEventsDisplay}
}
} else if key == keyboard.KeyArrowLeft {
if slices.Contains(display, pktDropDisplay) && slices.Contains(display, dnsDisplay) && slices.Contains(display, rttDisplay) {
if slices.Contains(display, pktDropDisplay) && slices.Contains(display, dnsDisplay) && slices.Contains(display, rttDisplay) &&
slices.Contains(display, networkEventsDisplay) {
display = []string{rttDisplay}
} else if slices.Contains(display, rttDisplay) {
display = []string{dnsDisplay}
} else if slices.Contains(display, dnsDisplay) {
display = []string{pktDropDisplay}
} else if slices.Contains(display, pktDropDisplay) {
display = []string{networkEventsDisplay}
} else if slices.Contains(display, networkEventsDisplay) {
display = []string{standardDisplay}
} else if slices.Contains(display, standardDisplay) {
display = []string{rawDisplay}
} else {
display = []string{pktDropDisplay, dnsDisplay, rttDisplay}
display = []string{pktDropDisplay, dnsDisplay, rttDisplay, networkEventsDisplay}
}
} else if key == keyboard.KeyPgup {
if slices.Contains(enrichement, zoneEnrichment) && slices.Contains(enrichement, hostEnrichment) && slices.Contains(enrichement, ownerEnrichment) {
Expand Down
23 changes: 15 additions & 8 deletions cmd/flow_capture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func TestFlowTableDefaultDisplay(t *testing.T) {
rows := strings.Split(buf.String(), "\n")

assert.Equal(t, 4, len(rows))
assert.Equal(t, `Time SrcName SrcType DstName DstType DropBytes DropPackets DropState DropCause DnsId DnsLatency DnsRCode DnsErrno RTT `, rows[0])
assert.Equal(t, `17:25:28.703000 src-pod Pod dst-pod Pod 32B 1 TCP_INVALID_STATE SKB_DROP_REASON_TCP_INVALID_SEQUENCE 31319 1ms NoError 0 10µs `, rows[1])
assert.Equal(t, `---------------- --------------------------------------------- -------- --------------------------------------------- -------- ------------ ------------ -------------------- ---------------------------------------- ------ ------ ------ ------ ------ `, rows[2])
assert.Equal(t, `Time SrcName SrcType DstName DstType DropBytes DropPackets DropState DropCause DnsId DnsLatency DnsRCode DnsErrno RTT NetworkEvents `, rows[0])
assert.Equal(t, `17:25:28.703000 src-pod Pod dst-pod Pod 32B 1 TCP_INVALID_STATE SKB_DROP_REASON_TCP_INVALID_SEQUENCE 31319 1ms NoError 0 10µs hello `, rows[1])
assert.Equal(t, `---------------- --------------------------------------------- -------- --------------------------------------------- -------- ------------ ------------ -------------------- ---------------------------------------- ------ ------ ------ ------ ------ ---------------- `, rows[2])
assert.Empty(t, rows[3])
}

Expand Down Expand Up @@ -127,12 +127,11 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
}

// set display without enrichment
rows := getRows([]string{pktDropDisplay, dnsDisplay, rttDisplay}, []string{noEnrichment})

rows := getRows([]string{pktDropDisplay, dnsDisplay, rttDisplay, networkEventsDisplay}, []string{noEnrichment})
assert.Equal(t, 4, len(rows))
assert.Equal(t, `Time SrcAddr SrcPort DstAddr DstPort DropBytes DropPackets DropState DropCause DnsId DnsLatency DnsRCode DnsErrno RTT `, rows[0])
assert.Equal(t, `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 32B 1 TCP_INVALID_STATE SKB_DROP_REASON_TCP_INVALID_SEQUENCE 31319 1ms NoError 0 10µs `, rows[1])
assert.Equal(t, `---------------- ---------------------------------------- ------ ---------------------------------------- ------ ------------ ------------ -------------------- ---------------------------------------- ------ ------ ------ ------ ------ `, rows[2])
assert.Equal(t, `Time SrcAddr SrcPort DstAddr DstPort DropBytes DropPackets DropState DropCause DnsId DnsLatency DnsRCode DnsErrno RTT NetworkEvents `, rows[0])
assert.Equal(t, `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 32B 1 TCP_INVALID_STATE SKB_DROP_REASON_TCP_INVALID_SEQUENCE 31319 1ms NoError 0 10µs hello `, rows[1])
assert.Equal(t, `---------------- ---------------------------------------- ------ ---------------------------------------- ------ ------------ ------------ -------------------- ---------------------------------------- ------ ------ ------ ------ ------ ---------------- `, rows[2])
assert.Empty(t, rows[3])

// set display to standard
Expand Down Expand Up @@ -170,4 +169,12 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
assert.Equal(t, `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 10µs `, rows[1])
assert.Equal(t, `---------------- ---------------------------------------- ------ ---------------------------------------- ------ ------ `, rows[2])
assert.Empty(t, rows[3])

// set display to NetworkEvents
rows = getRows([]string{networkEventsDisplay}, []string{noEnrichment})
assert.Equal(t, 4, len(rows))
assert.Equal(t, `Time SrcAddr SrcPort DstAddr DstPort NetworkEvents `, rows[0])
assert.Equal(t, `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 hello `, rows[1])
assert.Equal(t, `---------------- ---------------------------------------- ------ ---------------------------------------- ------ ---------------- `, rows[2])
assert.Empty(t, rows[3])
}
1 change: 1 addition & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
"PktDropLatestFlags":16,
"PktDropLatestState":"TCP_INVALID_STATE",
"PktDropPackets":1,
"NetworkEvents":["hello"],
"Proto":6,
"SrcAddr":"10.128.0.29",
"SrcK8S_HostIP":"10.0.1.1",
Expand Down
2 changes: 1 addition & 1 deletion e2e/capture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestFlowCapture(t *testing.T) {
func TestPacketCapture(t *testing.T) {
f1 := features.New("packet capture").Setup(
func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
output, err := RunCommand(clog, "oc-netobserv", "packets", "--protocol=TCP", "--port=443")
output, err := RunCommand(clog, "oc-netobserv", "packets", "--protocol=TCP", "--port=6443")
// TODO: find a way to avoid error here; this is probably related to SIGTERM instead of CTRL + C call
//assert.Nil(t, err)

Expand Down
45 changes: 24 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,27 @@ require (
require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/moby/spdystream v0.4.0 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/netobserv/netobserv-ebpf-agent v1.6.1-crc2.0.20240724142153-7acdf8de147f // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
k8s.io/component-base v0.30.1 // indirect
sigs.k8s.io/controller-runtime v0.18.2 // indirect
github.com/netobserv/netobserv-ebpf-agent v1.6.1-crc2.0.20240913155426-6ac7c5ccbf59 // indirect
github.com/x448/float16 v0.8.4 // indirect
k8s.io/component-base v0.30.2 // indirect
sigs.k8s.io/controller-runtime v0.18.4 // indirect
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
Expand All @@ -59,34 +62,34 @@ require (
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/client_golang v1.20.3 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/segmentio/kafka-go v0.4.47 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vladimirvivien/gexe v0.3.0
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.30.3 // indirect
k8s.io/apimachinery v0.30.3 // indirect
k8s.io/client-go v0.30.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/api v0.31.1 // indirect
k8s.io/apimachinery v0.31.1 // indirect
k8s.io/client-go v0.31.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
Expand Down
Loading

0 comments on commit 248df00

Please sign in to comment.