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
af243f48
Commit
af243f48
authored
Nov 30, 2017
by
Harry Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PV counter predicate in eclass
parent
8c1ee761
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
14 deletions
+53
-14
equivalence_cache.go
plugin/pkg/scheduler/core/equivalence_cache.go
+17
-0
factory.go
plugin/pkg/scheduler/factory/factory.go
+36
-14
No files found.
plugin/pkg/scheduler/core/equivalence_cache.go
View file @
af243f48
...
...
@@ -188,6 +188,23 @@ func (ec *EquivalenceCache) InvalidateCachedPredicateItemForPodAdd(pod *v1.Pod,
// GeneralPredicates: will always be affected by adding a new pod
invalidPredicates
:=
sets
.
NewString
(
"GeneralPredicates"
)
// MaxPDVolumeCountPredicate: we check the volumes of pod to make decision.
for
_
,
vol
:=
range
pod
.
Spec
.
Volumes
{
if
vol
.
PersistentVolumeClaim
!=
nil
{
invalidPredicates
.
Insert
(
"MaxEBSVolumeCount"
,
"MaxGCEPDVolumeCount"
,
"MaxAzureDiskVolumeCount"
)
}
else
{
if
vol
.
AWSElasticBlockStore
!=
nil
{
invalidPredicates
.
Insert
(
"MaxEBSVolumeCount"
)
}
if
vol
.
GCEPersistentDisk
!=
nil
{
invalidPredicates
.
Insert
(
"MaxGCEPDVolumeCount"
)
}
if
vol
.
AzureDisk
!=
nil
{
invalidPredicates
.
Insert
(
"MaxAzureDiskVolumeCount"
)
}
}
}
ec
.
InvalidateCachedPredicateItem
(
nodeName
,
invalidPredicates
)
}
...
...
plugin/pkg/scheduler/factory/factory.go
View file @
af243f48
...
...
@@ -71,11 +71,11 @@ const (
)
var
(
serviceAffinitySet
=
sets
.
NewString
(
"ServiceAffinity"
)
ma
xPDVolumeCountPredicateSet
=
sets
.
NewString
(
"MaxPDVolumeCountPredicate
"
)
matchInterPodAffinitySet
=
sets
.
NewString
(
"MatchInterPodAffinity
"
)
generalPredicatesSets
=
sets
.
NewString
(
"GeneralPredicates
"
)
noDiskConflictSet
=
sets
.
NewString
(
"NoDiskConflict"
)
serviceAffinitySet
=
sets
.
NewString
(
"ServiceAffinity"
)
ma
tchInterPodAffinitySet
=
sets
.
NewString
(
"MatchInterPodAffinity
"
)
generalPredicatesSets
=
sets
.
NewString
(
"GeneralPredicates
"
)
noDiskConflictSet
=
sets
.
NewString
(
"NoDiskConflict
"
)
maxPDVolumeCountPredicateKeys
=
[]
string
{
"MaxGCEPDVolumeCount"
,
"MaxAzureDiskVolumeCount"
,
"MaxEBSVolumeCount"
}
)
// configFactory is the default implementation of the scheduler.Configurator interface.
...
...
@@ -384,7 +384,11 @@ func (c *configFactory) onPvDelete(obj interface{}) {
}
func
(
c
*
configFactory
)
invalidatePredicatesForPv
(
pv
*
v1
.
PersistentVolume
)
{
invalidPredicates
:=
sets
.
NewString
(
"MaxPDVolumeCountPredicate"
)
// You could have a PVC that points to a PV, but the PV object doesn't exist.
// So when the PV object gets added, we can recount.
invalidPredicates
:=
sets
.
NewString
()
// PV types which impact MaxPDVolumeCountPredicate
if
pv
.
Spec
.
AWSElasticBlockStore
!=
nil
{
invalidPredicates
.
Insert
(
"MaxEBSVolumeCount"
)
}
...
...
@@ -395,6 +399,14 @@ func (c *configFactory) invalidatePredicatesForPv(pv *v1.PersistentVolume) {
invalidPredicates
.
Insert
(
"MaxAzureDiskVolumeCount"
)
}
// If PV contains zone related label, it may impact cached NoVolumeZoneConflict
for
k
:=
range
pv
.
ObjectMeta
.
Labels
{
if
k
==
kubeletapis
.
LabelZoneFailureDomain
||
k
==
kubeletapis
.
LabelZoneRegion
{
invalidPredicates
.
Insert
(
"NoVolumeZoneConflict"
)
break
}
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
// Add/delete impacts the available PVs to choose from
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
)
...
...
@@ -458,24 +470,34 @@ func (c *configFactory) onPvcDelete(obj interface{}) {
}
func
(
c
*
configFactory
)
invalidatePredicatesForPvc
(
pvc
*
v1
.
PersistentVolumeClaim
)
{
if
pvc
.
Spec
.
VolumeName
!=
""
{
c
.
equivalencePodCache
.
InvalidateCachedPredicateItemOfAllNodes
(
maxPDVolumeCountPredicateSet
)
// We need to do this here because the ecache uses PVC uid as part of equivalence hash of pod
// The binded volume type may change
invalidPredicates
:=
sets
.
NewString
(
maxPDVolumeCountPredicateKeys
...
)
// // The binded volume's label may change
invalidPredicates
.
Insert
(
"NoVolumeZoneConflict"
)
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
// Add/delete impacts the available PVs to choose from
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
)
}
c
.
equivalencePodCache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
}
func
(
c
*
configFactory
)
invalidatePredicatesForPvcUpdate
(
old
,
new
*
v1
.
PersistentVolumeClaim
)
{
invalidPredicates
:=
sets
.
NewString
()
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
if
old
.
Spec
.
VolumeName
!=
new
.
Spec
.
VolumeName
{
if
old
.
Spec
.
VolumeName
!=
new
.
Spec
.
VolumeName
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
// PVC volume binding has changed
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
)
}
// The binded volume type may change
invalidPredicates
.
Insert
(
maxPDVolumeCountPredicateKeys
...
)
// The binded volume's label may change
invalidPredicates
.
Insert
(
"NoVolumeZoneConflict"
)
}
if
invalidPredicates
.
Len
()
>
0
{
c
.
equivalencePodCache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
}
c
.
equivalencePodCache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
}
func
(
c
*
configFactory
)
onServiceAdd
(
obj
interface
{})
{
...
...
@@ -541,7 +563,7 @@ func (c *configFactory) addPodToCache(obj interface{}) {
c
.
podQueue
.
AssignedPodAdded
(
pod
)
// NOTE: Updating equivalence cache of addPodToCache has been
// handled optimistically in
InvalidateCachedPredicateItemForPodAdd.
// handled optimistically in
: plugin/pkg/scheduler/scheduler.go#assume()
}
func
(
c
*
configFactory
)
updatePodInCache
(
oldObj
,
newObj
interface
{})
{
...
...
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