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
9766f259
Commit
9766f259
authored
Oct 12, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14946 from aveshagarwal/master-proxy-changes
Adds new tests to improve coverage and removes unused params passed to proxy server.
parents
f27e0b2a
888a4881
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
25 deletions
+31
-25
server.go
cmd/kube-proxy/app/server.go
+9
-25
server_test.go
cmd/kube-proxy/app/server_test.go
+22
-0
No files found.
cmd/kube-proxy/app/server.go
View file @
9766f259
...
@@ -67,15 +67,10 @@ type ProxyServerConfig struct {
...
@@ -67,15 +67,10 @@ type ProxyServerConfig struct {
}
}
type
ProxyServer
struct
{
type
ProxyServer
struct
{
Client
*
kubeclient
.
Client
Config
*
ProxyServerConfig
Config
*
ProxyServerConfig
IptInterface
utiliptables
.
Interface
EndpointsConfig
*
proxyconfig
.
EndpointsConfig
Proxier
proxy
.
ProxyProvider
EndpointsHandler
proxyconfig
.
EndpointsConfigHandler
Recorder
record
.
EventRecorder
IptInterface
utiliptables
.
Interface
OOMAdjuster
*
oom
.
OOMAdjuster
Proxier
proxy
.
ProxyProvider
Recorder
record
.
EventRecorder
ServiceConfig
*
proxyconfig
.
ServiceConfig
}
}
// AddFlags adds flags for a specific ProxyServer to the specified FlagSet
// AddFlags adds flags for a specific ProxyServer to the specified FlagSet
...
@@ -122,25 +117,15 @@ func NewProxyConfig() *ProxyServerConfig {
...
@@ -122,25 +117,15 @@ func NewProxyConfig() *ProxyServerConfig {
func
NewProxyServer
(
func
NewProxyServer
(
config
*
ProxyServerConfig
,
config
*
ProxyServerConfig
,
client
*
kubeclient
.
Client
,
endpointsConfig
*
proxyconfig
.
EndpointsConfig
,
endpointsHandler
proxyconfig
.
EndpointsConfigHandler
,
iptInterface
utiliptables
.
Interface
,
iptInterface
utiliptables
.
Interface
,
oomAdjuster
*
oom
.
OOMAdjuster
,
proxier
proxy
.
ProxyProvider
,
proxier
proxy
.
ProxyProvider
,
recorder
record
.
EventRecorder
,
recorder
record
.
EventRecorder
,
serviceConfig
*
proxyconfig
.
ServiceConfig
,
)
(
*
ProxyServer
,
error
)
{
)
(
*
ProxyServer
,
error
)
{
return
&
ProxyServer
{
return
&
ProxyServer
{
Client
:
client
,
Config
:
config
,
Config
:
config
,
IptInterface
:
iptInterface
,
EndpointsConfig
:
endpointsConfig
,
Proxier
:
proxier
,
EndpointsHandler
:
endpointsHandler
,
Recorder
:
recorder
,
IptInterface
:
iptInterface
,
OOMAdjuster
:
oomAdjuster
,
Proxier
:
proxier
,
Recorder
:
recorder
,
ServiceConfig
:
serviceConfig
,
},
nil
},
nil
}
}
...
@@ -272,8 +257,7 @@ func NewProxyServerDefault(config *ProxyServerConfig) (*ProxyServer, error) {
...
@@ -272,8 +257,7 @@ func NewProxyServerDefault(config *ProxyServerConfig) (*ProxyServer, error) {
UID
:
types
.
UID
(
hostname
),
UID
:
types
.
UID
(
hostname
),
Namespace
:
""
,
Namespace
:
""
,
}
}
return
NewProxyServer
(
config
,
iptInterface
,
proxier
,
recorder
)
return
NewProxyServer
(
config
,
client
,
endpointsConfig
,
endpointsHandler
,
iptInterface
,
oomAdjuster
,
proxier
,
recorder
,
serviceConfig
)
}
}
// Run runs the specified ProxyServer. This should never exit (unless CleanupAndExit is set).
// Run runs the specified ProxyServer. This should never exit (unless CleanupAndExit is set).
...
...
cmd/kube-proxy/app/server_test.go
View file @
9766f259
...
@@ -19,6 +19,7 @@ package app
...
@@ -19,6 +19,7 @@ package app
import
(
import
(
"testing"
"testing"
"github.com/stretchr/testify/assert"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
)
)
...
@@ -59,3 +60,24 @@ func Test_mayTryIptablesProxy(t *testing.T) {
...
@@ -59,3 +60,24 @@ func Test_mayTryIptablesProxy(t *testing.T) {
}
}
}
}
}
}
//This test verifies that Proxy Server does not crash that means
//Config and iptinterface are not nil when CleanupAndExit is true.
//To avoid proxy crash: https://github.com/kubernetes/kubernetes/pull/14736
func
TestProxyServerWithCleanupAndExit
(
t
*
testing
.
T
)
{
//creates default config
config
:=
NewProxyConfig
()
//sets CleanupAndExit manually
config
.
CleanupAndExit
=
true
//creates new proxy server
proxyserver
,
err
:=
NewProxyServerDefault
(
config
)
//verifies that nothing is nill except error
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
proxyserver
)
assert
.
NotNil
(
t
,
proxyserver
.
Config
)
assert
.
NotNil
(
t
,
proxyserver
.
IptInterface
)
}
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