Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5e43c140
Commit
5e43c140
authored
Apr 02, 2017
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return healthcheck info from buildNewEndpointsMap
parent
87d3f2c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
proxier.go
pkg/proxy/iptables/proxier.go
+11
-10
proxier_test.go
pkg/proxy/iptables/proxier_test.go
+3
-4
No files found.
pkg/proxy/iptables/proxier.go
View file @
5e43c140
...
...
@@ -546,7 +546,13 @@ func (proxier *Proxier) OnEndpointsUpdate(allEndpoints []*api.Endpoints) {
proxier
.
allEndpoints
=
allEndpoints
// TODO: once service has made this same transform, move this into proxier.syncProxyRules()
newMap
,
staleConnections
:=
buildNewEndpointsMap
(
proxier
.
allEndpoints
,
proxier
.
endpointsMap
,
proxier
.
hostname
,
proxier
.
healthChecker
)
newMap
,
hcEndpoints
,
staleConnections
:=
buildNewEndpointsMap
(
proxier
.
allEndpoints
,
proxier
.
endpointsMap
,
proxier
.
hostname
)
// update healthcheck endpoints
if
err
:=
proxier
.
healthChecker
.
SyncEndpoints
(
hcEndpoints
);
err
!=
nil
{
glog
.
Errorf
(
"Error syncing healthcheck endoints: %v"
,
err
)
}
if
len
(
newMap
)
!=
len
(
proxier
.
endpointsMap
)
||
!
reflect
.
DeepEqual
(
newMap
,
proxier
.
endpointsMap
)
{
proxier
.
endpointsMap
=
newMap
proxier
.
syncProxyRules
(
syncReasonEndpoints
)
...
...
@@ -558,11 +564,11 @@ func (proxier *Proxier) OnEndpointsUpdate(allEndpoints []*api.Endpoints) {
}
// Convert a slice of api.Endpoints objects into a map of service-port -> endpoints.
func
buildNewEndpointsMap
(
allEndpoints
[]
*
api
.
Endpoints
,
curMap
proxyEndpointMap
,
hostname
string
,
healthChecker
healthcheck
.
Server
)
(
newMap
proxyEndpointMap
,
staleSet
map
[
endpointServicePair
]
bool
)
{
func
buildNewEndpointsMap
(
allEndpoints
[]
*
api
.
Endpoints
,
curMap
proxyEndpointMap
,
hostname
string
)
(
newMap
proxyEndpointMap
,
hcEndpoints
map
[
types
.
NamespacedName
]
int
,
staleSet
map
[
endpointServicePair
]
bool
)
{
// return values
newMap
=
make
(
proxyEndpointMap
)
hcEndpoints
=
make
(
map
[
types
.
NamespacedName
]
int
)
staleSet
=
make
(
map
[
endpointServicePair
]
bool
)
// Update endpoints for services.
...
...
@@ -607,16 +613,11 @@ func buildNewEndpointsMap(allEndpoints []*api.Endpoints, curMap proxyEndpointMap
}
}
// produce a count per service
localEndpointCounts
:=
map
[
types
.
NamespacedName
]
int
{}
for
nsn
,
ips
:=
range
localIPs
{
localEndpointCounts
[
nsn
]
=
len
(
ips
)
}
// update healthcheck endpoints
if
err
:=
healthChecker
.
SyncEndpoints
(
localEndpointCounts
);
err
!=
nil
{
glog
.
Errorf
(
"Error syncing healthcheck endoints: %v"
,
err
)
hcEndpoints
[
nsn
]
=
len
(
ips
)
}
return
newMap
,
staleSet
return
newMap
,
hcEndpoints
,
staleSet
}
// Gather information about all the endpoint state for a given api.Endpoints.
...
...
pkg/proxy/iptables/proxier_test.go
View file @
5e43c140
...
...
@@ -2010,8 +2010,7 @@ func Test_buildNewEndpointsMap(t *testing.T) {
}}
for
tci
,
tc
:=
range
testCases
{
hc
:=
newFakeHealthChecker
()
newMap
,
stale
:=
buildNewEndpointsMap
(
tc
.
newEndpoints
,
tc
.
oldEndpoints
,
nodeName
,
hc
)
newMap
,
hcEndpoints
,
stale
:=
buildNewEndpointsMap
(
tc
.
newEndpoints
,
tc
.
oldEndpoints
,
nodeName
)
if
len
(
newMap
)
!=
len
(
tc
.
expectedResult
)
{
t
.
Errorf
(
"[%d] expected %d results, got %d: %v"
,
tci
,
len
(
tc
.
expectedResult
),
len
(
newMap
),
newMap
)
}
...
...
@@ -2034,8 +2033,8 @@ func Test_buildNewEndpointsMap(t *testing.T) {
t
.
Errorf
(
"[%d] expected stale[%v], but didn't find it: %v"
,
tci
,
x
,
stale
)
}
}
if
!
reflect
.
DeepEqual
(
hc
.
e
ndpoints
,
tc
.
expectedHealthchecks
)
{
t
.
Errorf
(
"[%d] expected healthchecks %v, got %v"
,
tci
,
tc
.
expectedHealthchecks
,
hc
.
e
ndpoints
)
if
!
reflect
.
DeepEqual
(
hc
E
ndpoints
,
tc
.
expectedHealthchecks
)
{
t
.
Errorf
(
"[%d] expected healthchecks %v, got %v"
,
tci
,
tc
.
expectedHealthchecks
,
hc
E
ndpoints
)
}
}
}
...
...
Write
Preview
Markdown
is supported
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