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
dbd80460
Commit
dbd80460
authored
Jan 16, 2019
by
Yecheng Fu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear cache instead of saving nils if no claims to bind or provision
parent
c2d25e08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
scheduler_binder.go
pkg/controller/volume/persistentvolume/scheduler_binder.go
+5
-0
scheduler_binder_cache.go
...troller/volume/persistentvolume/scheduler_binder_cache.go
+15
-0
No files found.
pkg/controller/volume/persistentvolume/scheduler_binder.go
View file @
dbd80460
...
@@ -182,6 +182,11 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
...
@@ -182,6 +182,11 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
)
)
defer
func
()
{
defer
func
()
{
// We recreate bindings for each new schedule loop.
// We recreate bindings for each new schedule loop.
if
len
(
matchedClaims
)
==
0
&&
len
(
provisionedClaims
)
==
0
{
// Clear cache if no claims to bind or provision for this node.
b
.
podBindingCache
.
ClearBindings
(
pod
,
node
.
Name
)
return
}
// Although we do not distinguish nil from empty in this function, for
// Although we do not distinguish nil from empty in this function, for
// easier testing, we normalize empty to nil.
// easier testing, we normalize empty to nil.
if
len
(
matchedClaims
)
==
0
{
if
len
(
matchedClaims
)
==
0
{
...
...
pkg/controller/volume/persistentvolume/scheduler_binder_cache.go
View file @
dbd80460
...
@@ -30,6 +30,9 @@ type PodBindingCache interface {
...
@@ -30,6 +30,9 @@ type PodBindingCache interface {
// pod and node.
// pod and node.
UpdateBindings
(
pod
*
v1
.
Pod
,
node
string
,
bindings
[]
*
bindingInfo
,
provisionings
[]
*
v1
.
PersistentVolumeClaim
)
UpdateBindings
(
pod
*
v1
.
Pod
,
node
string
,
bindings
[]
*
bindingInfo
,
provisionings
[]
*
v1
.
PersistentVolumeClaim
)
// ClearBindings will clear the cached bindings for the given pod and node.
ClearBindings
(
pod
*
v1
.
Pod
,
node
string
)
// GetBindings will return the cached bindings for the given pod and node.
// GetBindings will return the cached bindings for the given pod and node.
// A nil return value means that the entry was not found. An empty slice
// A nil return value means that the entry was not found. An empty slice
// means that no binding operations are needed.
// means that no binding operations are needed.
...
@@ -148,3 +151,15 @@ func (c *podBindingCache) GetProvisionedPVCs(pod *v1.Pod, node string) []*v1.Per
...
@@ -148,3 +151,15 @@ func (c *podBindingCache) GetProvisionedPVCs(pod *v1.Pod, node string) []*v1.Per
}
}
return
decision
.
provisionings
return
decision
.
provisionings
}
}
func
(
c
*
podBindingCache
)
ClearBindings
(
pod
*
v1
.
Pod
,
node
string
)
{
c
.
rwMutex
.
Lock
()
defer
c
.
rwMutex
.
Unlock
()
podName
:=
getPodName
(
pod
)
decisions
,
ok
:=
c
.
bindingDecisions
[
podName
]
if
!
ok
{
return
}
delete
(
decisions
,
node
)
}
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