Skip to content

Commit 7710723

Browse files
authored
Use agent lib instead of ovnk-lib for NetworkEvents (#776)
We created a dedicated agent helper to decode NetworkEvents Use it instead of directly calling ovn-k That also removes a lot of dependencies
1 parent ec2f365 commit 7710723

File tree

649 files changed

+13827
-102890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

649 files changed

+13827
-102890
lines changed

go.mod

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,26 @@ require (
88
github.com/gorilla/mux v1.8.1
99
github.com/json-iterator/go v1.1.12
1010
github.com/mitchellh/mapstructure v1.5.0
11-
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20241126140656-c95491e46334
11+
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250220123714-ff37a09f6232
1212
github.com/prometheus/client_golang v1.21.1
1313
github.com/prometheus/common v0.62.0
1414
github.com/sirupsen/logrus v1.9.3
1515
github.com/stretchr/testify v1.10.0
1616
gopkg.in/yaml.v3 v3.0.1
17-
k8s.io/api v0.32.1
17+
k8s.io/api v0.32.2
1818
k8s.io/apimachinery v0.32.2
19-
k8s.io/client-go v0.32.1
19+
k8s.io/client-go v0.32.2
2020
)
2121

2222
require (
2323
github.com/beorn7/perks v1.0.1 // indirect
24-
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
25-
github.com/cenkalti/hub v1.0.1 // indirect
26-
github.com/cenkalti/rpc2 v0.0.0-20210604223624-c1acbc6ec984 // indirect
2724
github.com/cespare/xxhash/v2 v2.3.0 // indirect
28-
github.com/containernetworking/cni v1.1.2 // indirect
29-
github.com/containernetworking/plugins v1.2.0 // indirect
30-
github.com/coreos/go-iptables v0.6.0 // indirect
31-
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
3225
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
33-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
26+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
3427
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
3528
github.com/go-logr/logr v1.4.2 // indirect
36-
github.com/go-logr/stdr v1.2.2 // indirect
3729
github.com/go-openapi/jsonpointer v0.21.0 // indirect
38-
github.com/go-openapi/jsonreference v0.20.2 // indirect
30+
github.com/go-openapi/jsonreference v0.21.0 // indirect
3931
github.com/go-openapi/swag v0.23.0 // indirect
4032
github.com/gogo/protobuf v1.3.2 // indirect
4133
github.com/golang/protobuf v1.5.4 // indirect
@@ -51,31 +43,24 @@ require (
5143
github.com/modern-go/reflect2 v1.0.2 // indirect
5244
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5345
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
54-
github.com/ovn-org/libovsdb v0.7.1-0.20240820095311-ce1951614a20 // indirect
46+
github.com/netobserv/flowlogs-pipeline v1.7.0-community.0.20241217113023-fa0540a1658e // indirect
47+
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20250215040159-dd2a70c928d3 // indirect
5548
github.com/pkg/errors v0.9.1 // indirect
5649
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
5750
github.com/prometheus/client_model v0.6.1 // indirect
5851
github.com/prometheus/procfs v0.15.1 // indirect
59-
github.com/russross/blackfriday/v2 v2.1.0 // indirect
60-
github.com/safchain/ethtool v0.3.1-0.20231027162144-83e5e0097c91 // indirect
52+
github.com/spf13/pflag v1.0.5 // indirect
6153
github.com/stretchr/objx v0.5.2 // indirect
62-
github.com/urfave/cli/v2 v2.27.2 // indirect
63-
github.com/vishvananda/netlink v1.2.1-beta.2.0.20231024175852-77df5d35f725 // indirect
64-
github.com/vishvananda/netns v0.0.4 // indirect
6554
github.com/x448/float16 v0.8.4 // indirect
66-
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
6755
golang.org/x/net v0.33.0 // indirect
6856
golang.org/x/oauth2 v0.24.0 // indirect
69-
golang.org/x/sys v0.28.0 // indirect
57+
golang.org/x/sys v0.30.0 // indirect
7058
golang.org/x/term v0.27.0 // indirect
7159
golang.org/x/text v0.21.0 // indirect
7260
golang.org/x/time v0.7.0 // indirect
73-
google.golang.org/protobuf v1.36.1 // indirect
61+
google.golang.org/protobuf v1.36.5 // indirect
7462
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
75-
gopkg.in/gcfg.v1 v1.2.3 // indirect
7663
gopkg.in/inf.v0 v0.9.1 // indirect
77-
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
78-
gopkg.in/warnings.v0 v0.1.2 // indirect
7964
gopkg.in/yaml.v2 v2.4.0 // indirect
8065
k8s.io/klog/v2 v2.130.1 // indirect
8166
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect

go.sum

Lines changed: 50 additions & 114 deletions
Large diffs are not rendered by default.

pkg/decoders/network-events.go

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package decoders
33
import (
44
"encoding/json"
55

6+
ovnutils "github.com/netobserv/netobserv-ebpf-agent/pkg/utils"
67
"github.com/netobserv/network-observability-console-plugin/pkg/model/fields"
7-
ovnmodel "github.com/ovn-org/ovn-kubernetes/go-controller/observability-lib/model"
88
"github.com/sirupsen/logrus"
99
)
1010

@@ -16,48 +16,15 @@ func NetworkEventsToString(in string) string {
1616
dlog.Errorf("Could not decode NetworkEvent: %v", err)
1717
return in
1818
}
19-
if ne, found := line[fields.NetworkEvents]; found {
20-
if neList, isList := ne.([]any); isList {
21-
var messages []string
22-
for _, item := range neList {
23-
if neItem, isMap := item.(map[string]any); isMap {
24-
messages = append(messages, networkEventItemToString(neItem))
25-
}
26-
}
27-
line[fields.NetworkEvents] = messages
28-
b, err := json.Marshal(line)
29-
if err != nil {
30-
dlog.Errorf("Could not reencode NetworkEvent: %v", err)
31-
return in
32-
}
33-
return string(b)
19+
events := ovnutils.NetworkEventsToStrings(line)
20+
if events != nil {
21+
line[fields.NetworkEvents] = events
22+
b, err := json.Marshal(line)
23+
if err != nil {
24+
dlog.Errorf("Could not reencode NetworkEvent: %v", err)
25+
return in
3426
}
27+
return string(b)
3528
}
3629
return in
3730
}
38-
39-
func networkEventItemToString(in map[string]any) string {
40-
if msg := getAsString(in, "Message"); msg != "" {
41-
return msg
42-
}
43-
if feat := getAsString(in, "Feature"); feat == "acl" {
44-
aclObj := ovnmodel.ACLEvent{
45-
Action: getAsString(in, "Action"),
46-
Actor: getAsString(in, "Type"),
47-
Name: getAsString(in, "Name"),
48-
Namespace: getAsString(in, "Namespace"),
49-
Direction: getAsString(in, "Direction"),
50-
}
51-
return aclObj.String()
52-
}
53-
return ""
54-
}
55-
56-
func getAsString(in map[string]any, key string) string {
57-
if anyV, hasKey := in[key]; hasKey {
58-
if v, isStr := anyV.(string); isStr {
59-
return v
60-
}
61-
}
62-
return ""
63-
}

vendor/github.com/cenkalti/backoff/v4/.gitignore

Lines changed: 0 additions & 25 deletions
This file was deleted.

vendor/github.com/cenkalti/backoff/v4/LICENSE

Lines changed: 0 additions & 20 deletions
This file was deleted.

vendor/github.com/cenkalti/backoff/v4/README.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

vendor/github.com/cenkalti/backoff/v4/backoff.go

Lines changed: 0 additions & 66 deletions
This file was deleted.

vendor/github.com/cenkalti/backoff/v4/context.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)