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
e45f92fc
Unverified
Commit
e45f92fc
authored
May 09, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 09, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77626 from ahg-g/ahg-mutex
Make thread-safe the prebind callback of stateful plugin in scheduler…
parents
3ab338df
7b127311
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
stateful.go
...scheduler/framework/plugins/examples/stateful/stateful.go
+6
-0
No files found.
pkg/scheduler/framework/plugins/examples/stateful/stateful.go
View file @
e45f92fc
...
@@ -18,6 +18,7 @@ package stateful
...
@@ -18,6 +18,7 @@ package stateful
import
(
import
(
"fmt"
"fmt"
"sync"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -31,6 +32,7 @@ import (
...
@@ -31,6 +32,7 @@ import (
type
MultipointExample
struct
{
type
MultipointExample
struct
{
mpState
map
[
int
]
string
mpState
map
[
int
]
string
numRuns
int
numRuns
int
mu
sync
.
RWMutex
}
}
var
_
=
framework
.
ReservePlugin
(
&
MultipointExample
{})
var
_
=
framework
.
ReservePlugin
(
&
MultipointExample
{})
...
@@ -46,12 +48,16 @@ func (mp *MultipointExample) Name() string {
...
@@ -46,12 +48,16 @@ func (mp *MultipointExample) Name() string {
// Reserve is the functions invoked by the framework at "reserve" extension point.
// Reserve is the functions invoked by the framework at "reserve" extension point.
func
(
mp
*
MultipointExample
)
Reserve
(
pc
*
framework
.
PluginContext
,
pod
*
v1
.
Pod
,
nodeName
string
)
*
framework
.
Status
{
func
(
mp
*
MultipointExample
)
Reserve
(
pc
*
framework
.
PluginContext
,
pod
*
v1
.
Pod
,
nodeName
string
)
*
framework
.
Status
{
// Reserve is not called concurrently, and so we don't need to lock.
mp
.
numRuns
++
mp
.
numRuns
++
return
nil
return
nil
}
}
// Prebind is the functions invoked by the framework at "prebind" extension point.
// Prebind is the functions invoked by the framework at "prebind" extension point.
func
(
mp
*
MultipointExample
)
Prebind
(
pc
*
framework
.
PluginContext
,
pod
*
v1
.
Pod
,
nodeName
string
)
*
framework
.
Status
{
func
(
mp
*
MultipointExample
)
Prebind
(
pc
*
framework
.
PluginContext
,
pod
*
v1
.
Pod
,
nodeName
string
)
*
framework
.
Status
{
// Prebind could be called concurrently for different pods.
mp
.
mu
.
Lock
()
defer
mp
.
mu
.
Unlock
()
mp
.
numRuns
++
mp
.
numRuns
++
if
pod
==
nil
{
if
pod
==
nil
{
return
framework
.
NewStatus
(
framework
.
Error
,
"pod must not be nil"
)
return
framework
.
NewStatus
(
framework
.
Error
,
"pod must not be nil"
)
...
...
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