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
3e8690c2
Commit
3e8690c2
authored
Jun 12, 2015
by
Abhi Shah
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9515 from markturansky/scrub_thread_leak
Fixes thread leak from discarded watch
parents
d314e3d5
4210a5df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
util.go
pkg/volume/util.go
+10
-4
util_test.go
pkg/volume/util_test.go
+1
-1
No files found.
pkg/volume/util.go
View file @
3e8690c2
...
...
@@ -82,7 +82,10 @@ func internalScrubPodVolumeAndWatchUntilCompletion(pod *api.Pod, scrubberClient
defer
scrubberClient
.
DeletePod
(
pod
.
Name
,
pod
.
Namespace
)
nextPod
:=
scrubberClient
.
WatchPod
(
pod
.
Name
,
pod
.
Namespace
,
pod
.
ResourceVersion
)
stopChannel
:=
make
(
chan
struct
{})
defer
close
(
stopChannel
)
nextPod
:=
scrubberClient
.
WatchPod
(
pod
.
Name
,
pod
.
Namespace
,
pod
.
ResourceVersion
,
stopChannel
)
for
{
watchedPod
:=
nextPod
()
if
watchedPod
.
Status
.
Phase
==
api
.
PodSucceeded
{
...
...
@@ -106,7 +109,7 @@ type scrubberClient interface {
CreatePod
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
GetPod
(
name
,
namespace
string
)
(
*
api
.
Pod
,
error
)
DeletePod
(
name
,
namespace
string
)
error
WatchPod
(
name
,
namespace
,
resourceVersion
string
)
func
()
*
api
.
Pod
WatchPod
(
name
,
namespace
,
resourceVersion
string
,
stopChannel
chan
struct
{}
)
func
()
*
api
.
Pod
}
func
newScrubberClient
(
client
client
.
Interface
)
scrubberClient
{
...
...
@@ -129,7 +132,10 @@ func (c *realScrubberClient) DeletePod(name, namespace string) error {
return
c
.
client
.
Pods
(
namespace
)
.
Delete
(
name
,
nil
)
}
func
(
c
*
realScrubberClient
)
WatchPod
(
name
,
namespace
,
resourceVersion
string
)
func
()
*
api
.
Pod
{
// WatchPod returns a ListWatch for watching a pod. The stopChannel is used
// to close the reflector backing the watch. The caller is responsible for derring a close on the channel to
// stop the reflector.
func
(
c
*
realScrubberClient
)
WatchPod
(
name
,
namespace
,
resourceVersion
string
,
stopChannel
chan
struct
{})
func
()
*
api
.
Pod
{
fieldSelector
,
_
:=
fields
.
ParseSelector
(
"metadata.name="
+
name
)
podLW
:=
&
cache
.
ListWatch
{
...
...
@@ -141,7 +147,7 @@ func (c *realScrubberClient) WatchPod(name, namespace, resourceVersion string) f
},
}
queue
:=
cache
.
NewFIFO
(
cache
.
MetaNamespaceKeyFunc
)
cache
.
NewReflector
(
podLW
,
&
api
.
Pod
{},
queue
,
1
*
time
.
Minute
)
.
Run
(
)
cache
.
NewReflector
(
podLW
,
&
api
.
Pod
{},
queue
,
1
*
time
.
Minute
)
.
Run
Until
(
stopChannel
)
return
func
()
*
api
.
Pod
{
obj
:=
queue
.
Pop
()
...
...
pkg/volume/util_test.go
View file @
3e8690c2
...
...
@@ -95,7 +95,7 @@ func (c *mockScrubberClient) DeletePod(name, namespace string) error {
return
nil
}
func
(
c
*
mockScrubberClient
)
WatchPod
(
name
,
namespace
,
resourceVersion
string
)
func
()
*
api
.
Pod
{
func
(
c
*
mockScrubberClient
)
WatchPod
(
name
,
namespace
,
resourceVersion
string
,
stopChannel
chan
struct
{}
)
func
()
*
api
.
Pod
{
return
func
()
*
api
.
Pod
{
return
c
.
pod
}
...
...
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