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
04b943ce
Commit
04b943ce
authored
Mar 31, 2019
by
Dan Williams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy/userspace: track initial service/endpoints sync
We'll use this shortly to prevent premature syncing before all initial endpoints and services have been received from the apiserver.
parent
ddab79a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
proxier.go
pkg/proxy/userspace/proxier.go
+26
-0
No files found.
pkg/proxy/userspace/proxier.go
View file @
04b943ce
...
@@ -109,6 +109,12 @@ type Proxier struct {
...
@@ -109,6 +109,12 @@ type Proxier struct {
proxyPorts
PortAllocator
proxyPorts
PortAllocator
makeProxySocket
ProxySocketFunc
makeProxySocket
ProxySocketFunc
exec
utilexec
.
Interface
exec
utilexec
.
Interface
// endpointsSynced and servicesSynced are set to 1 when the corresponding
// objects are synced after startup. This is used to avoid updating iptables
// with some partial data after kube-proxy restart.
endpointsSynced
int32
servicesSynced
int32
initialized
int32
stopChan
chan
struct
{}
stopChan
chan
struct
{}
}
}
...
@@ -304,6 +310,10 @@ func (proxier *Proxier) shutdown() {
...
@@ -304,6 +310,10 @@ func (proxier *Proxier) shutdown() {
close
(
proxier
.
stopChan
)
close
(
proxier
.
stopChan
)
}
}
func
(
proxier
*
Proxier
)
isInitialized
()
bool
{
return
atomic
.
LoadInt32
(
&
proxier
.
initialized
)
>
0
}
// Sync is called to immediately synchronize the proxier state to iptables
// Sync is called to immediately synchronize the proxier state to iptables
func
(
proxier
*
Proxier
)
Sync
()
{
func
(
proxier
*
Proxier
)
Sync
()
{
if
err
:=
iptablesInit
(
proxier
.
iptables
);
err
!=
nil
{
if
err
:=
iptablesInit
(
proxier
.
iptables
);
err
!=
nil
{
...
@@ -545,6 +555,14 @@ func (proxier *Proxier) OnServiceDelete(service *v1.Service) {
...
@@ -545,6 +555,14 @@ func (proxier *Proxier) OnServiceDelete(service *v1.Service) {
}
}
func
(
proxier
*
Proxier
)
OnServiceSynced
()
{
func
(
proxier
*
Proxier
)
OnServiceSynced
()
{
klog
.
V
(
2
)
.
Infof
(
"userspace OnServiceSynced"
)
// Mark services as initialized and (if endpoints are already
// initialized) the entire proxy as initialized
atomic
.
StoreInt32
(
&
proxier
.
servicesSynced
,
1
)
if
atomic
.
LoadInt32
(
&
proxier
.
endpointsSynced
)
>
0
{
atomic
.
StoreInt32
(
&
proxier
.
initialized
,
1
)
}
}
}
func
(
proxier
*
Proxier
)
OnEndpointsAdd
(
endpoints
*
v1
.
Endpoints
)
{
func
(
proxier
*
Proxier
)
OnEndpointsAdd
(
endpoints
*
v1
.
Endpoints
)
{
...
@@ -560,7 +578,15 @@ func (proxier *Proxier) OnEndpointsDelete(endpoints *v1.Endpoints) {
...
@@ -560,7 +578,15 @@ func (proxier *Proxier) OnEndpointsDelete(endpoints *v1.Endpoints) {
}
}
func
(
proxier
*
Proxier
)
OnEndpointsSynced
()
{
func
(
proxier
*
Proxier
)
OnEndpointsSynced
()
{
klog
.
V
(
2
)
.
Infof
(
"userspace OnEndpointsSynced"
)
proxier
.
loadBalancer
.
OnEndpointsSynced
()
proxier
.
loadBalancer
.
OnEndpointsSynced
()
// Mark endpoints as initialized and (if services are already
// initialized) the entire proxy as initialized
atomic
.
StoreInt32
(
&
proxier
.
endpointsSynced
,
1
)
if
atomic
.
LoadInt32
(
&
proxier
.
servicesSynced
)
>
0
{
atomic
.
StoreInt32
(
&
proxier
.
initialized
,
1
)
}
}
}
func
sameConfig
(
info
*
ServiceInfo
,
service
*
v1
.
Service
,
port
*
v1
.
ServicePort
)
bool
{
func
sameConfig
(
info
*
ServiceInfo
,
service
*
v1
.
Service
,
port
*
v1
.
ServicePort
)
bool
{
...
...
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