Skip to content

Commit 583289a

Browse files
authored
NETOBSERV-1788: manage services case (#580)
* manage services case * use type instead of owner type
1 parent aef2627 commit 583289a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

pkg/handler/topology.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func expandQueries(queries filters.MultiQueries, namespace string, isForProm fun
234234
}
235235
q2 := filters.SingleQuery{
236236
filters.NewMatch(fields.FlowDirection, `"`+string(constants.Egress)+`"`),
237-
filters.NewMatch(fields.DstOwnerName, `""`),
237+
filters.NewMatch(fields.DstType, `"","Service"`),
238238
}
239239

240240
shouldSkip := func(q filters.SingleQuery) bool {

pkg/handler/topology_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestSplitForReportersMerge(t *testing.T) {
3030
}, res[0])
3131
assert.Equal(t, filters.SingleQuery{
3232
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
33-
filters.NewMatch("DstK8S_OwnerName", `""`),
33+
filters.NewMatch("DstK8S_Type", `"","Service"`),
3434
filters.NewMatch("srcns", "a"),
3535
filters.NewMatch("dstns", "b"),
3636
}, res[1])
@@ -73,14 +73,14 @@ func TestExpand_ComplexQuery(t *testing.T) {
7373
assert.Equal(t, filters.SingleQuery{
7474
filters.NewMatch("SrcK8S_Namespace", `"my-namespace"`),
7575
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
76-
filters.NewMatch("DstK8S_OwnerName", `""`),
76+
filters.NewMatch("DstK8S_Type", `"","Service"`),
7777
filters.NewMatch("key1", "a"),
7878
filters.NewMatch("key2", "b"),
7979
}, res[4])
8080
assert.Equal(t, filters.SingleQuery{
8181
filters.NewMatch("DstK8S_Namespace", `"my-namespace"`),
8282
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
83-
filters.NewMatch("DstK8S_OwnerName", `""`),
83+
filters.NewMatch("DstK8S_Type", `"","Service"`),
8484
filters.NewMatch("key1", "a"),
8585
filters.NewMatch("key2", "b"),
8686
}, res[5])
@@ -104,14 +104,14 @@ func TestExpand_ComplexQuery(t *testing.T) {
104104
assert.Equal(t, filters.SingleQuery{
105105
filters.NewMatch("SrcK8S_Namespace", `"my-namespace"`),
106106
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
107-
filters.NewMatch("DstK8S_OwnerName", `""`),
107+
filters.NewMatch("DstK8S_Type", `"","Service"`),
108108
filters.NewMatch("key1", "c"),
109109
filters.NewMatch("key2", "d"),
110110
}, res[9])
111111
assert.Equal(t, filters.SingleQuery{
112112
filters.NewMatch("DstK8S_Namespace", `"my-namespace"`),
113113
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
114-
filters.NewMatch("DstK8S_OwnerName", `""`),
114+
filters.NewMatch("DstK8S_Type", `"","Service"`),
115115
filters.NewMatch("key1", "c"),
116116
filters.NewMatch("key2", "d"),
117117
}, res[10])

pkg/server/server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func TestLokiConfigurationForTopology(t *testing.T) {
339339
Loki: config.Loki{
340340
URL: lokiSvc.URL,
341341
Timeout: config.Duration{Duration: time.Second},
342-
Labels: []string{fields.SrcNamespace, fields.DstNamespace, fields.SrcOwnerName, fields.DstOwnerName, fields.FlowDirection},
342+
Labels: []string{fields.SrcNamespace, fields.DstNamespace, fields.SrcOwnerName, fields.DstOwnerName, fields.SrcType, fields.DstType, fields.FlowDirection},
343343
},
344344
Frontend: config.Frontend{Deduper: config.Deduper{
345345
Mark: true,
@@ -361,7 +361,7 @@ func TestLokiConfigurationForTopology(t *testing.T) {
361361
queries := []string{req1.URL.Query().Get("query"), req2.URL.Query().Get("query")}
362362
expected := []string{
363363
`topk(100,sum by(SrcK8S_Name,SrcK8S_Type,SrcK8S_OwnerName,SrcK8S_OwnerType,SrcK8S_Namespace,SrcAddr,SrcK8S_HostName,DstK8S_Name,DstK8S_Type,DstK8S_OwnerName,DstK8S_OwnerType,DstK8S_Namespace,DstAddr,DstK8S_HostName)(rate({app="netobserv-flowcollector",FlowDirection=~"^0$|^2$"}!~` + "`" + `Duplicate":true` + "`" + `|json|unwrap Bytes|__error__=""[1m])))`,
364-
`topk(100,sum by(SrcK8S_Name,SrcK8S_Type,SrcK8S_OwnerName,SrcK8S_OwnerType,SrcK8S_Namespace,SrcAddr,SrcK8S_HostName,DstK8S_Name,DstK8S_Type,DstK8S_OwnerName,DstK8S_OwnerType,DstK8S_Namespace,DstAddr,DstK8S_HostName)(rate({app="netobserv-flowcollector",FlowDirection="1",DstK8S_OwnerName=""}!~` + "`" + `Duplicate":true` + "`" + `|json|unwrap Bytes|__error__=""[1m])))`,
364+
`topk(100,sum by(SrcK8S_Name,SrcK8S_Type,SrcK8S_OwnerName,SrcK8S_OwnerType,SrcK8S_Namespace,SrcAddr,SrcK8S_HostName,DstK8S_Name,DstK8S_Type,DstK8S_OwnerName,DstK8S_OwnerType,DstK8S_Namespace,DstAddr,DstK8S_HostName)(rate({app="netobserv-flowcollector",FlowDirection="1",DstK8S_Type=~"^$|^Service$"}!~` + "`" + `Duplicate":true` + "`" + `|json|unwrap Bytes|__error__=""[1m])))`,
365365
}
366366
// We don't predict the order so sort both actual and expected
367367
sort.Strings(queries)
@@ -397,7 +397,7 @@ func TestLokiConfigurationForTableHistogram(t *testing.T) {
397397
Loki: config.Loki{
398398
URL: lokiSvc.URL,
399399
Timeout: config.Duration{Duration: time.Second},
400-
Labels: []string{fields.SrcNamespace, fields.DstNamespace, fields.SrcOwnerName, fields.DstOwnerName, fields.FlowDirection},
400+
Labels: []string{fields.SrcNamespace, fields.DstNamespace, fields.SrcOwnerName, fields.DstOwnerName, fields.SrcType, fields.DstType, fields.FlowDirection},
401401
},
402402
Frontend: config.Frontend{Deduper: config.Deduper{
403403
Mark: true,

0 commit comments

Comments
 (0)