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
690a06b9
Commit
690a06b9
authored
Sep 23, 2016
by
shashidharatd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle review comments for Fix goroutine leak in federation service controller
parent
d8ff4870
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
39 deletions
+40
-39
endpoint_helper.go
...tion/pkg/federation-controller/service/endpoint_helper.go
+20
-19
service_helper.go
...ation/pkg/federation-controller/service/service_helper.go
+19
-19
servicecontroller.go
...on/pkg/federation-controller/service/servicecontroller.go
+1
-1
No files found.
federation/pkg/federation-controller/service/endpoint_helper.go
View file @
690a06b9
...
@@ -32,43 +32,44 @@ import (
...
@@ -32,43 +32,44 @@ import (
// It enforces that the syncHandler is never invoked concurrently with the same key.
// It enforces that the syncHandler is never invoked concurrently with the same key.
func
(
sc
*
ServiceController
)
clusterEndpointWorker
()
{
func
(
sc
*
ServiceController
)
clusterEndpointWorker
()
{
// process all pending events in endpointWorkerDoneChan
// process all pending events in endpointWorkerDoneChan
eventPending
:=
true
ForLoop
:
for
eventPending
{
for
{
select
{
select
{
case
clusterName
:=
<-
sc
.
endpointWorkerDoneChan
:
case
clusterName
:=
<-
sc
.
endpointWorkerDoneChan
:
sc
.
endpointWorkerMap
[
clusterName
]
=
false
sc
.
endpointWorkerMap
[
clusterName
]
=
false
default
:
default
:
// non-blocking, comes here if all existing events are processed
// non-blocking, comes here if all existing events are processed
eventPending
=
false
break
ForLoop
break
}
}
}
}
for
clusterName
,
cache
:=
range
sc
.
clusterCache
.
clientMap
{
for
clusterName
,
cache
:=
range
sc
.
clusterCache
.
clientMap
{
workerExist
,
keyF
ound
:=
sc
.
endpointWorkerMap
[
clusterName
]
workerExist
,
f
ound
:=
sc
.
endpointWorkerMap
[
clusterName
]
if
keyF
ound
&&
workerExist
{
if
f
ound
&&
workerExist
{
continue
continue
}
}
sc
.
endpointWorkerMap
[
clusterName
]
=
true
// create a worker only if the previous worker has finished and gone out of scope
// create a worker only if the previous worker has finished and gone out of scope
go
func
(
cache
*
clusterCache
,
clusterName
string
)
{
go
func
(
cache
*
clusterCache
,
clusterName
string
)
{
fedClient
:=
sc
.
federationClient
fedClient
:=
sc
.
federationClient
for
{
for
{
key
,
quit
:=
cache
.
endpointQueue
.
Get
()
func
()
{
// update endpoint cache
key
,
quit
:=
cache
.
endpointQueue
.
Get
()
if
quit
{
// update endpoint cache
// send signal that current worker has finished tasks and is going out of scope
if
quit
{
sc
.
endpointWorkerDoneChan
<-
clusterName
// send signal that current worker has finished tasks and is going out of scope
return
sc
.
endpointWorkerDoneChan
<-
clusterName
}
return
defer
cache
.
endpointQueue
.
Done
(
key
)
}
err
:=
sc
.
clusterCache
.
syncEndpoint
(
key
.
(
string
),
clusterName
,
cache
,
sc
.
serviceCache
,
fedClient
,
sc
)
defer
cache
.
endpointQueue
.
Done
(
key
)
if
err
!=
nil
{
err
:=
sc
.
clusterCache
.
syncEndpoint
(
key
.
(
string
),
clusterName
,
cache
,
sc
.
serviceCache
,
fedClient
,
sc
)
glog
.
V
(
2
)
.
Infof
(
"Failed to sync endpoint: %+v"
,
err
)
if
err
!=
nil
{
}
glog
.
V
(
2
)
.
Infof
(
"Failed to sync endpoint: %+v"
,
err
)
}
}()
}
}
}(
cache
,
clusterName
)
}(
cache
,
clusterName
)
sc
.
endpointWorkerMap
[
clusterName
]
=
true
}
}
}
}
...
...
federation/pkg/federation-controller/service/service_helper.go
View file @
690a06b9
...
@@ -36,43 +36,43 @@ import (
...
@@ -36,43 +36,43 @@ import (
// It enforces that the syncHandler is never invoked concurrently with the same key.
// It enforces that the syncHandler is never invoked concurrently with the same key.
func
(
sc
*
ServiceController
)
clusterServiceWorker
()
{
func
(
sc
*
ServiceController
)
clusterServiceWorker
()
{
// process all pending events in serviceWorkerDoneChan
// process all pending events in serviceWorkerDoneChan
eventPending
:=
true
ForLoop
:
for
eventPending
{
for
{
select
{
select
{
case
clusterName
:=
<-
sc
.
serviceWorkerDoneChan
:
case
clusterName
:=
<-
sc
.
serviceWorkerDoneChan
:
sc
.
serviceWorkerMap
[
clusterName
]
=
false
sc
.
serviceWorkerMap
[
clusterName
]
=
false
default
:
default
:
// non-blocking, comes here if all existing events are processed
// non-blocking, comes here if all existing events are processed
eventPending
=
false
break
ForLoop
break
}
}
}
}
for
clusterName
,
cache
:=
range
sc
.
clusterCache
.
clientMap
{
for
clusterName
,
cache
:=
range
sc
.
clusterCache
.
clientMap
{
workerExist
,
keyF
ound
:=
sc
.
serviceWorkerMap
[
clusterName
]
workerExist
,
f
ound
:=
sc
.
serviceWorkerMap
[
clusterName
]
if
keyF
ound
&&
workerExist
{
if
f
ound
&&
workerExist
{
continue
continue
}
}
sc
.
serviceWorkerMap
[
clusterName
]
=
true
// create a worker only if the previous worker has finished and gone out of scope
// create a worker only if the previous worker has finished and gone out of scope
go
func
(
cache
*
clusterCache
,
clusterName
string
)
{
go
func
(
cache
*
clusterCache
,
clusterName
string
)
{
fedClient
:=
sc
.
federationClient
fedClient
:=
sc
.
federationClient
for
{
for
{
key
,
quit
:=
cache
.
serviceQueue
.
Get
()
func
()
{
if
quit
{
key
,
quit
:=
cache
.
serviceQueue
.
Get
()
// send signal that current worker has finished tasks and is going out of scope
if
quit
{
sc
.
serviceWorkerDoneChan
<-
clusterName
// send signal that current worker has finished tasks and is going out of scope
return
sc
.
serviceWorkerDoneChan
<-
clusterName
}
return
defer
cache
.
serviceQueue
.
Done
(
key
)
}
err
:=
sc
.
clusterCache
.
syncService
(
key
.
(
string
),
clusterName
,
cache
,
sc
.
serviceCache
,
fedClient
,
sc
)
defer
cache
.
serviceQueue
.
Done
(
key
)
if
err
!=
nil
{
err
:=
sc
.
clusterCache
.
syncService
(
key
.
(
string
),
clusterName
,
cache
,
sc
.
serviceCache
,
fedClient
,
sc
)
glog
.
Errorf
(
"Failed to sync service: %+v"
,
err
)
if
err
!=
nil
{
}
glog
.
Errorf
(
"Failed to sync service: %+v"
,
err
)
}
}()
}
}
}(
cache
,
clusterName
)
}(
cache
,
clusterName
)
sc
.
serviceWorkerMap
[
clusterName
]
=
true
}
}
}
}
...
...
federation/pkg/federation-controller/service/servicecontroller.go
View file @
690a06b9
...
@@ -68,7 +68,7 @@ const (
...
@@ -68,7 +68,7 @@ const (
KubeAPIQPS
=
20.0
KubeAPIQPS
=
20.0
KubeAPIBurst
=
30
KubeAPIBurst
=
30
maxNoOfClusters
=
256
maxNoOfClusters
=
100
)
)
type
cachedService
struct
{
type
cachedService
struct
{
...
...
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