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
c26debec
Commit
c26debec
authored
Nov 29, 2017
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return no volume match if prebound PV node affinity doesn't match node
parent
2aeace40
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
index.go
pkg/controller/volume/persistentvolume/index.go
+14
-1
index_test.go
pkg/controller/volume/persistentvolume/index_test.go
+1
-1
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+3
-3
No files found.
pkg/controller/volume/persistentvolume/index.go
View file @
c26debec
...
@@ -169,12 +169,13 @@ func findMatchingVolume(
...
@@ -169,12 +169,13 @@ func findMatchingVolume(
continue
continue
}
}
nodeAffinityValid
:=
true
if
node
!=
nil
{
if
node
!=
nil
{
// Scheduler path, check that the PV NodeAffinity
// Scheduler path, check that the PV NodeAffinity
// is satisfied by the node
// is satisfied by the node
err
:=
volumeutil
.
CheckNodeAffinity
(
volume
,
node
.
Labels
)
err
:=
volumeutil
.
CheckNodeAffinity
(
volume
,
node
.
Labels
)
if
err
!=
nil
{
if
err
!=
nil
{
continu
e
nodeAffinityValid
=
fals
e
}
}
}
}
...
@@ -185,6 +186,14 @@ func findMatchingVolume(
...
@@ -185,6 +186,14 @@ func findMatchingVolume(
if
volumeQty
.
Cmp
(
requestedQty
)
<
0
{
if
volumeQty
.
Cmp
(
requestedQty
)
<
0
{
continue
continue
}
}
// If PV node affinity is invalid, return no match.
// This means the prebound PV (and therefore PVC)
// is not suitable for this node.
if
!
nodeAffinityValid
{
return
nil
,
nil
}
return
volume
,
nil
return
volume
,
nil
}
}
...
@@ -199,6 +208,7 @@ func findMatchingVolume(
...
@@ -199,6 +208,7 @@ func findMatchingVolume(
// - volumes bound to another claim
// - volumes bound to another claim
// - volumes whose labels don't match the claim's selector, if specified
// - volumes whose labels don't match the claim's selector, if specified
// - volumes in Class that is not requested
// - volumes in Class that is not requested
// - volumes whose NodeAffinity does not match the node
if
volume
.
Spec
.
ClaimRef
!=
nil
{
if
volume
.
Spec
.
ClaimRef
!=
nil
{
continue
continue
}
else
if
selector
!=
nil
&&
!
selector
.
Matches
(
labels
.
Set
(
volume
.
Labels
))
{
}
else
if
selector
!=
nil
&&
!
selector
.
Matches
(
labels
.
Set
(
volume
.
Labels
))
{
...
@@ -207,6 +217,9 @@ func findMatchingVolume(
...
@@ -207,6 +217,9 @@ func findMatchingVolume(
if
v1helper
.
GetPersistentVolumeClass
(
volume
)
!=
requestedClass
{
if
v1helper
.
GetPersistentVolumeClass
(
volume
)
!=
requestedClass
{
continue
continue
}
}
if
!
nodeAffinityValid
{
continue
}
if
node
!=
nil
{
if
node
!=
nil
{
// Scheduler path
// Scheduler path
...
...
pkg/controller/volume/persistentvolume/index_test.go
View file @
c26debec
...
@@ -1218,7 +1218,7 @@ func TestFindMatchVolumeWithNode(t *testing.T) {
...
@@ -1218,7 +1218,7 @@ func TestFindMatchVolumeWithNode(t *testing.T) {
pvc
.
Spec
.
StorageClassName
=
&
classWait
pvc
.
Spec
.
StorageClassName
=
&
classWait
pvc
.
Name
=
"claim02"
pvc
.
Name
=
"claim02"
}),
}),
node
:
node
2
,
node
:
node
3
,
},
},
"success-bad-and-good-node-affinity"
:
{
"success-bad-and-good-node-affinity"
:
{
expectedMatch
:
"affinity-pv3"
,
expectedMatch
:
"affinity-pv3"
,
...
...
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
c26debec
...
@@ -1475,12 +1475,12 @@ func (c *VolumeBindingChecker) predicate(pod *v1.Pod, meta algorithm.PredicateMe
...
@@ -1475,12 +1475,12 @@ func (c *VolumeBindingChecker) predicate(pod *v1.Pod, meta algorithm.PredicateMe
failReasons
:=
[]
algorithm
.
PredicateFailureReason
{}
failReasons
:=
[]
algorithm
.
PredicateFailureReason
{}
if
!
boundSatisfied
{
if
!
boundSatisfied
{
glog
.
V
(
5
)
.
Info
(
"Bound PVs not satisfied for pod %v/%v, node %q"
,
pod
.
Namespace
,
pod
.
Name
,
node
.
Name
)
glog
.
V
(
5
)
.
Info
f
(
"Bound PVs not satisfied for pod %v/%v, node %q"
,
pod
.
Namespace
,
pod
.
Name
,
node
.
Name
)
failReasons
=
append
(
failReasons
,
ErrVolumeNodeConflict
)
failReasons
=
append
(
failReasons
,
ErrVolumeNodeConflict
)
}
}
if
!
unboundSatisfied
{
if
!
unboundSatisfied
{
glog
.
V
(
5
)
.
Info
(
"Couldn't find matching PVs for pod %v/%v, node %q"
,
pod
.
Namespace
,
pod
.
Name
,
node
.
Name
)
glog
.
V
(
5
)
.
Info
f
(
"Couldn't find matching PVs for pod %v/%v, node %q"
,
pod
.
Namespace
,
pod
.
Name
,
node
.
Name
)
failReasons
=
append
(
failReasons
,
ErrVolumeBindConflict
)
failReasons
=
append
(
failReasons
,
ErrVolumeBindConflict
)
}
}
...
@@ -1489,6 +1489,6 @@ func (c *VolumeBindingChecker) predicate(pod *v1.Pod, meta algorithm.PredicateMe
...
@@ -1489,6 +1489,6 @@ func (c *VolumeBindingChecker) predicate(pod *v1.Pod, meta algorithm.PredicateMe
}
}
// All volumes bound or matching PVs found for all unbound PVCs
// All volumes bound or matching PVs found for all unbound PVCs
glog
.
V
(
5
)
.
Info
(
"All PVCs found matches for pod %v/%v, node %q"
,
pod
.
Namespace
,
pod
.
Name
,
node
.
Name
)
glog
.
V
(
5
)
.
Info
f
(
"All PVCs found matches for pod %v/%v, node %q"
,
pod
.
Namespace
,
pod
.
Name
,
node
.
Name
)
return
true
,
nil
,
nil
return
true
,
nil
,
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