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
9b00b7ef
Commit
9b00b7ef
authored
Nov 05, 2015
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid MockPodsListWatch deadlock of blocked channel while lock is hold
parent
1831a057
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
24 deletions
+37
-24
plugin_test.go
contrib/mesos/pkg/scheduler/plugin_test.go
+37
-24
No files found.
contrib/mesos/pkg/scheduler/plugin_test.go
View file @
9b00b7ef
...
@@ -184,7 +184,8 @@ func (lw *MockPodsListWatch) Pods() api.PodList {
...
@@ -184,7 +184,8 @@ func (lw *MockPodsListWatch) Pods() api.PodList {
lw
.
lock
.
Lock
()
lw
.
lock
.
Lock
()
defer
lw
.
lock
.
Unlock
()
defer
lw
.
lock
.
Unlock
()
return
lw
.
list
obj
,
_
:=
api
.
Scheme
.
DeepCopy
(
&
lw
.
list
)
return
*
(
obj
.
(
*
api
.
PodList
))
}
}
func
(
lw
*
MockPodsListWatch
)
Pod
(
name
string
)
*
api
.
Pod
{
func
(
lw
*
MockPodsListWatch
)
Pod
(
name
string
)
*
api
.
Pod
{
...
@@ -200,44 +201,56 @@ func (lw *MockPodsListWatch) Pod(name string) *api.Pod {
...
@@ -200,44 +201,56 @@ func (lw *MockPodsListWatch) Pod(name string) *api.Pod {
return
nil
return
nil
}
}
func
(
lw
*
MockPodsListWatch
)
Add
(
pod
*
api
.
Pod
,
notify
bool
)
{
func
(
lw
*
MockPodsListWatch
)
Add
(
pod
*
api
.
Pod
,
notify
bool
)
{
lw
.
lock
.
Lock
()
func
()
{
defer
lw
.
lock
.
Unlock
()
lw
.
lock
.
Lock
()
defer
lw
.
lock
.
Unlock
()
lw
.
list
.
Items
=
append
(
lw
.
list
.
Items
,
*
pod
)
}()
lw
.
list
.
Items
=
append
(
lw
.
list
.
Items
,
*
pod
)
if
notify
{
if
notify
{
lw
.
fakeWatcher
.
Add
(
pod
)
lw
.
fakeWatcher
.
Add
(
pod
)
}
}
}
}
func
(
lw
*
MockPodsListWatch
)
Modify
(
pod
*
api
.
Pod
,
notify
bool
)
{
func
(
lw
*
MockPodsListWatch
)
Modify
(
pod
*
api
.
Pod
,
notify
bool
)
{
lw
.
lock
.
Lock
()
found
:=
false
defer
lw
.
lock
.
Unlock
()
func
()
{
lw
.
lock
.
Lock
()
for
i
,
otherPod
:=
range
lw
.
list
.
Items
{
defer
lw
.
lock
.
Unlock
()
if
otherPod
.
Name
==
pod
.
Name
{
lw
.
list
.
Items
[
i
]
=
*
pod
for
i
,
otherPod
:=
range
lw
.
list
.
Items
{
if
notify
{
if
otherPod
.
Name
==
pod
.
Name
{
lw
.
fakeWatcher
.
Modify
(
pod
)
lw
.
list
.
Items
[
i
]
=
*
pod
found
=
true
return
}
}
return
}
}
log
.
Fatalf
(
"Cannot find pod %v to modify in MockPodsListWatch"
,
pod
.
Name
)
}()
if
notify
&&
found
{
lw
.
fakeWatcher
.
Modify
(
pod
)
}
}
log
.
Fatalf
(
"Cannot find pod %v to modify in MockPodsListWatch"
,
pod
.
Name
)
}
}
func
(
lw
*
MockPodsListWatch
)
Delete
(
pod
*
api
.
Pod
,
notify
bool
)
{
func
(
lw
*
MockPodsListWatch
)
Delete
(
pod
*
api
.
Pod
,
notify
bool
)
{
lw
.
lock
.
Lock
()
var
notifyPod
*
api
.
Pod
defer
lw
.
lock
.
Unlock
()
func
()
{
lw
.
lock
.
Lock
()
for
i
,
otherPod
:=
range
lw
.
list
.
Items
{
defer
lw
.
lock
.
Unlock
()
if
otherPod
.
Name
==
pod
.
Name
{
lw
.
list
.
Items
=
append
(
lw
.
list
.
Items
[
:
i
],
lw
.
list
.
Items
[
i
+
1
:
]
...
)
for
i
,
otherPod
:=
range
lw
.
list
.
Items
{
if
notify
{
if
otherPod
.
Name
==
pod
.
Name
{
lw
.
fakeWatcher
.
Delete
(
&
otherPod
)
lw
.
list
.
Items
=
append
(
lw
.
list
.
Items
[
:
i
],
lw
.
list
.
Items
[
i
+
1
:
]
...
)
notifyPod
=
&
otherPod
return
}
}
return
}
}
log
.
Fatalf
(
"Cannot find pod %v to delete in MockPodsListWatch"
,
pod
.
Name
)
}()
if
notifyPod
!=
nil
&&
notify
{
lw
.
fakeWatcher
.
Delete
(
notifyPod
)
}
}
log
.
Fatalf
(
"Cannot find pod %v to delete in MockPodsListWatch"
,
pod
.
Name
)
}
}
// Create a pod with a given index, requiring one port
// Create a pod with a given index, requiring one port
...
...
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