Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mizu
Commits
bb3ae1ef
Unverified
Commit
bb3ae1ef
authored
3 years ago
by
Gustavo Massaneiro
Committed by
GitHub
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Service Map node key as entry.Name instead of entry.IP (#818)
parent
5dfa94d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
agent/pkg/controllers/service_map_controller_test.go
+2
-2
agent/pkg/controllers/service_map_controller_test.go
agent/pkg/servicemap/servicemap.go
+23
-10
agent/pkg/servicemap/servicemap.go
agent/pkg/servicemap/servicemap_test.go
+19
-6
agent/pkg/servicemap/servicemap_test.go
with
44 additions
and
18 deletions
+44
-18
agent/pkg/controllers/service_map_controller_test.go
+
2
-
2
View file @
bb3ae1ef
...
...
@@ -102,13 +102,13 @@ func (s *ServiceMapControllerSuite) TestGet() {
// response nodes
aNode
:=
servicemap
.
ServiceMapNode
{
Id
:
1
,
Name
:
TCPEntryA
.
IP
,
Name
:
TCPEntryA
.
Name
,
Entry
:
TCPEntryA
,
Count
:
1
,
}
bNode
:=
servicemap
.
ServiceMapNode
{
Id
:
2
,
Name
:
TCPEntryB
.
IP
,
Name
:
TCPEntryB
.
Name
,
Entry
:
TCPEntryB
,
Count
:
1
,
}
...
...
This diff is collapsed.
Click to expand it.
agent/pkg/servicemap/servicemap.go
+
23
-
10
View file @
bb3ae1ef
...
...
@@ -172,20 +172,33 @@ func (s *serviceMap) NewTCPEntry(src *tapApi.TCP, dst *tapApi.TCP, p *tapApi.Pro
return
}
srcEntry
:=
&
entryData
{
key
:
key
(
src
.
IP
),
entry
:
src
,
}
if
len
(
srcEntry
.
entry
.
Name
)
==
0
{
var
srcEntry
*
entryData
var
dstEntry
*
entryData
if
len
(
src
.
Name
)
==
0
{
srcEntry
=
&
entryData
{
key
:
key
(
src
.
IP
),
entry
:
src
,
}
srcEntry
.
entry
.
Name
=
UnresolvedNodeName
}
else
{
srcEntry
=
&
entryData
{
key
:
key
(
src
.
Name
),
entry
:
src
,
}
}
dstEntry
:=
&
entryData
{
key
:
key
(
dst
.
IP
),
entry
:
dst
,
}
if
len
(
dstEntry
.
entry
.
Name
)
==
0
{
if
len
(
dst
.
Name
)
==
0
{
dstEntry
=
&
entryData
{
key
:
key
(
dst
.
IP
)
,
entry
:
dst
,
}
dstEntry
.
entry
.
Name
=
UnresolvedNodeName
}
else
{
dstEntry
=
&
entryData
{
key
:
key
(
dst
.
Name
),
entry
:
dst
,
}
}
s
.
addEdge
(
srcEntry
,
dstEntry
,
p
)
...
...
This diff is collapsed.
Click to expand it.
agent/pkg/servicemap/servicemap_test.go
+
19
-
6
View file @
bb3ae1ef
...
...
@@ -268,9 +268,14 @@ func (s *ServiceMapEnabledSuite) TestServiceMap() {
assert
.
LessOrEqual
(
node
.
Id
,
expectedNodeCount
)
// entry
// node.Name is the key of the node, key = entry.
IP
// node.Name is the key of the node, key = entry.
Name by default
// entry.Name is the name of the service and could be unresolved
assert
.
Equal
(
node
.
Name
,
node
.
Entry
.
IP
)
// when entry.Name is unresolved, key = entry.IP
if
node
.
Entry
.
Name
==
UnresolvedNodeName
{
assert
.
Equal
(
node
.
Name
,
node
.
Entry
.
IP
)
}
else
{
assert
.
Equal
(
node
.
Name
,
node
.
Entry
.
Name
)
}
assert
.
Equal
(
Port
,
node
.
Entry
.
Port
)
assert
.
Equal
(
entryName
,
node
.
Entry
.
Name
)
...
...
@@ -320,16 +325,24 @@ func (s *ServiceMapEnabledSuite) TestServiceMap() {
cdEdge
:=
-
1
acEdge
:=
-
1
var
validateEdge
=
func
(
edge
ServiceMapEdge
,
sourceEntryName
string
,
destEntryName
string
,
protocolName
string
,
protocolCount
int
)
{
// source
// source
node
assert
.
Contains
(
nodeIds
,
edge
.
Source
.
Id
)
assert
.
LessOrEqual
(
edge
.
Source
.
Id
,
expectedNodeCount
)
assert
.
Equal
(
edge
.
Source
.
Name
,
edge
.
Source
.
Entry
.
IP
)
if
edge
.
Source
.
Entry
.
Name
==
UnresolvedNodeName
{
assert
.
Equal
(
edge
.
Source
.
Name
,
edge
.
Source
.
Entry
.
IP
)
}
else
{
assert
.
Equal
(
edge
.
Source
.
Name
,
edge
.
Source
.
Entry
.
Name
)
}
assert
.
Equal
(
sourceEntryName
,
edge
.
Source
.
Entry
.
Name
)
// destination
// destination
node
assert
.
Contains
(
nodeIds
,
edge
.
Destination
.
Id
)
assert
.
LessOrEqual
(
edge
.
Destination
.
Id
,
expectedNodeCount
)
assert
.
Equal
(
edge
.
Destination
.
Name
,
edge
.
Destination
.
Entry
.
IP
)
if
edge
.
Destination
.
Entry
.
Name
==
UnresolvedNodeName
{
assert
.
Equal
(
edge
.
Destination
.
Name
,
edge
.
Destination
.
Entry
.
IP
)
}
else
{
assert
.
Equal
(
edge
.
Destination
.
Name
,
edge
.
Destination
.
Entry
.
Name
)
}
assert
.
Equal
(
destEntryName
,
edge
.
Destination
.
Entry
.
Name
)
// protocol
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment