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
3fc950ee
Commit
3fc950ee
authored
Apr 04, 2017
by
Kubernetes Submit Queue
Committed by
GitHub
Apr 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #44051 from thockin/proxy-rename-functions
Automatic merge from submit-queue Rename functions for congruence part of async cleanup
parents
7e18392f
099e55c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
proxier.go
pkg/proxy/iptables/proxier.go
+5
-5
proxier_test.go
pkg/proxy/iptables/proxier_test.go
+10
-10
No files found.
pkg/proxy/iptables/proxier.go
View file @
3fc950ee
...
...
@@ -458,7 +458,7 @@ type healthCheckPort struct {
// Accepts a list of Services and the existing service map. Returns the new
// service map, a list of healthcheck ports to add to or remove from the health
// checking listener service, and a set of stale UDP services.
func
buildServiceMap
(
allServices
[]
*
api
.
Service
,
oldServiceMap
proxyServiceMap
)
(
proxyServiceMap
,
[]
healthCheckPort
,
[]
healthCheckPort
,
sets
.
String
)
{
func
build
New
ServiceMap
(
allServices
[]
*
api
.
Service
,
oldServiceMap
proxyServiceMap
)
(
proxyServiceMap
,
[]
healthCheckPort
,
[]
healthCheckPort
,
sets
.
String
)
{
newServiceMap
:=
make
(
proxyServiceMap
)
healthCheckAdd
:=
make
([]
healthCheckPort
,
0
)
healthCheckDel
:=
make
([]
healthCheckPort
,
0
)
...
...
@@ -537,7 +537,7 @@ func (proxier *Proxier) OnServiceUpdate(allServices []*api.Service) {
}
proxier
.
allServices
=
allServices
newServiceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
buildServiceMap
(
allServices
,
proxier
.
serviceMap
)
newServiceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
build
New
ServiceMap
(
allServices
,
proxier
.
serviceMap
)
for
_
,
hc
:=
range
hcAdd
{
glog
.
V
(
4
)
.
Infof
(
"Adding health check for %+v, port %v"
,
hc
.
namespace
,
hc
.
nodeport
)
// Turn on healthcheck responder to listen on the health check nodePort
...
...
@@ -572,7 +572,7 @@ 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
:=
updateEndpoints
(
proxier
.
allEndpoints
,
proxier
.
endpointsMap
,
proxier
.
hostname
,
proxier
.
healthChecker
)
newMap
,
staleConnections
:=
buildNewEndpointsMap
(
proxier
.
allEndpoints
,
proxier
.
endpointsMap
,
proxier
.
hostname
,
proxier
.
healthChecker
)
if
len
(
newMap
)
!=
len
(
proxier
.
endpointsMap
)
||
!
reflect
.
DeepEqual
(
newMap
,
proxier
.
endpointsMap
)
{
proxier
.
endpointsMap
=
newMap
proxier
.
syncProxyRules
()
...
...
@@ -584,7 +584,7 @@ func (proxier *Proxier) OnEndpointsUpdate(allEndpoints []*api.Endpoints) {
}
// Convert a slice of api.Endpoints objects into a map of service-port -> endpoints.
func
updateEndpoints
(
allEndpoints
[]
*
api
.
Endpoints
,
curMap
proxyEndpointMap
,
hostname
string
,
func
buildNewEndpointsMap
(
allEndpoints
[]
*
api
.
Endpoints
,
curMap
proxyEndpointMap
,
hostname
string
,
healthChecker
healthChecker
)
(
newMap
proxyEndpointMap
,
staleSet
map
[
endpointServicePair
]
bool
)
{
// return values
...
...
@@ -638,7 +638,7 @@ func updateEndpoints(allEndpoints []*api.Endpoints, curMap proxyEndpointMap, hos
//
// TODO: this could be simplified:
// - hostPortInfo and endpointsInfo overlap too much
// - the test for this is overlapped by the test for
updateEndpoints
// - the test for this is overlapped by the test for
buildNewEndpointsMap
// - naming is poor and responsibilities are muddled
func
accumulateEndpointsMap
(
endpoints
*
api
.
Endpoints
,
hostname
string
,
curEndpoints
proxyEndpointMap
,
...
...
pkg/proxy/iptables/proxier_test.go
View file @
3fc950ee
...
...
@@ -926,7 +926,7 @@ func TestBuildServiceMapAddRemove(t *testing.T) {
}),
}
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
buildServiceMap
(
services
,
make
(
proxyServiceMap
))
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
build
New
ServiceMap
(
services
,
make
(
proxyServiceMap
))
if
len
(
serviceMap
)
!=
8
{
t
.
Errorf
(
"expected service map length 8, got %v"
,
serviceMap
)
}
...
...
@@ -961,7 +961,7 @@ func TestBuildServiceMapAddRemove(t *testing.T) {
// Remove some stuff
services
=
[]
*
api
.
Service
{
services
[
0
]}
services
[
0
]
.
Spec
.
Ports
=
[]
api
.
ServicePort
{
services
[
0
]
.
Spec
.
Ports
[
1
]}
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
=
buildServiceMap
(
services
,
serviceMap
)
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
=
build
New
ServiceMap
(
services
,
serviceMap
)
if
len
(
serviceMap
)
!=
1
{
t
.
Errorf
(
"expected service map length 1, got %v"
,
serviceMap
)
}
...
...
@@ -1008,7 +1008,7 @@ func TestBuildServiceMapServiceHeadless(t *testing.T) {
}
// Headless service should be ignored
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
buildServiceMap
(
services
,
make
(
proxyServiceMap
))
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
build
New
ServiceMap
(
services
,
make
(
proxyServiceMap
))
if
len
(
serviceMap
)
!=
0
{
t
.
Errorf
(
"expected service map length 0, got %d"
,
len
(
serviceMap
))
}
...
...
@@ -1036,7 +1036,7 @@ func TestBuildServiceMapServiceTypeExternalName(t *testing.T) {
}),
}
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
buildServiceMap
(
services
,
make
(
proxyServiceMap
))
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
build
New
ServiceMap
(
services
,
make
(
proxyServiceMap
))
if
len
(
serviceMap
)
!=
0
{
t
.
Errorf
(
"expected service map length 0, got %v"
,
serviceMap
)
}
...
...
@@ -1081,7 +1081,7 @@ func TestBuildServiceMapServiceUpdate(t *testing.T) {
}),
}
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
buildServiceMap
(
first
,
make
(
proxyServiceMap
))
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
:=
build
New
ServiceMap
(
first
,
make
(
proxyServiceMap
))
if
len
(
serviceMap
)
!=
2
{
t
.
Errorf
(
"expected service map length 2, got %v"
,
serviceMap
)
}
...
...
@@ -1097,7 +1097,7 @@ func TestBuildServiceMapServiceUpdate(t *testing.T) {
}
// Change service to load-balancer
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
=
buildServiceMap
(
second
,
serviceMap
)
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
=
build
New
ServiceMap
(
second
,
serviceMap
)
if
len
(
serviceMap
)
!=
2
{
t
.
Errorf
(
"expected service map length 2, got %v"
,
serviceMap
)
}
...
...
@@ -1113,7 +1113,7 @@ func TestBuildServiceMapServiceUpdate(t *testing.T) {
// No change; make sure the service map stays the same and there are
// no health-check changes
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
=
buildServiceMap
(
second
,
serviceMap
)
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
=
build
New
ServiceMap
(
second
,
serviceMap
)
if
len
(
serviceMap
)
!=
2
{
t
.
Errorf
(
"expected service map length 2, got %v"
,
serviceMap
)
}
...
...
@@ -1128,7 +1128,7 @@ func TestBuildServiceMapServiceUpdate(t *testing.T) {
}
// And back to ClusterIP
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
=
buildServiceMap
(
first
,
serviceMap
)
serviceMap
,
hcAdd
,
hcDel
,
staleUDPServices
=
build
New
ServiceMap
(
first
,
serviceMap
)
if
len
(
serviceMap
)
!=
2
{
t
.
Errorf
(
"expected service map length 2, got %v"
,
serviceMap
)
}
...
...
@@ -1396,7 +1396,7 @@ func makeServicePortName(ns, name, port string) proxy.ServicePortName {
}
}
func
Test_
updateEndpoints
(
t
*
testing
.
T
)
{
func
Test_
buildNewEndpointsMap
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
newEndpoints
[]
*
api
.
Endpoints
oldEndpoints
map
[
proxy
.
ServicePortName
][]
*
endpointsInfo
...
...
@@ -1993,7 +1993,7 @@ func Test_updateEndpoints(t *testing.T) {
}}
for
tci
,
tc
:=
range
testCases
{
newMap
,
stale
:=
updateEndpoints
(
tc
.
newEndpoints
,
tc
.
oldEndpoints
,
"host"
,
fakeHealthChecker
{})
newMap
,
stale
:=
buildNewEndpointsMap
(
tc
.
newEndpoints
,
tc
.
oldEndpoints
,
"host"
,
fakeHealthChecker
{})
if
len
(
newMap
)
!=
len
(
tc
.
expectedResult
)
{
t
.
Errorf
(
"[%d] expected %d results, got %d: %v"
,
tci
,
len
(
tc
.
expectedResult
),
len
(
newMap
),
newMap
)
}
...
...
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