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
e62952d0
Commit
e62952d0
authored
Dec 18, 2017
by
Yassine TIJANI
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using consts to refer to predicate names
parent
ecba5049
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
42 deletions
+41
-42
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+11
-11
defaults.go
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
+20
-20
defaults_test.go
...pkg/scheduler/algorithmprovider/defaults/defaults_test.go
+1
-1
generic_scheduler.go
plugin/pkg/scheduler/core/generic_scheduler.go
+1
-1
generic_scheduler_test.go
plugin/pkg/scheduler/core/generic_scheduler_test.go
+2
-2
factory.go
plugin/pkg/scheduler/factory/factory.go
+3
-3
scheduler.go
plugin/pkg/scheduler/scheduler.go
+1
-1
scheduler_test.go
plugin/pkg/scheduler/scheduler_test.go
+2
-3
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
e62952d0
...
@@ -49,8 +49,8 @@ import (
...
@@ -49,8 +49,8 @@ import (
)
)
const
(
const
(
MatchInterPodAffinity
=
"MatchInterPodAffinity"
MatchInterPodAffinity
Pred
=
"MatchInterPodAffinity"
CheckVolumeBinding
=
"CheckVolumeBinding"
CheckVolumeBinding
Pred
=
"CheckVolumeBinding"
CheckNodeConditionPred
=
"CheckNodeCondition"
CheckNodeConditionPred
=
"CheckNodeCondition"
GeneralPred
=
"GeneralPredicates"
GeneralPred
=
"GeneralPredicates"
HostNamePred
=
"HostName"
HostNamePred
=
"HostName"
...
@@ -67,7 +67,7 @@ const (
...
@@ -67,7 +67,7 @@ const (
MaxAzureDiskVolumeCountPred
=
"MaxAzureDiskVolumeCount"
MaxAzureDiskVolumeCountPred
=
"MaxAzureDiskVolumeCount"
NoVolumeZoneConflictPred
=
"NoVolumeZoneConflict"
NoVolumeZoneConflictPred
=
"NoVolumeZoneConflict"
CheckNodeMemoryPressurePred
=
"CheckNodeMemoryPressure"
CheckNodeMemoryPressurePred
=
"CheckNodeMemoryPressure"
CheckNodeDiskPressure
=
"CheckNodeDiskPressure"
CheckNodeDiskPressure
Pred
=
"CheckNodeDiskPressure"
// DefaultMaxGCEPDVolumes defines the maximum number of PD Volumes for GCE
// DefaultMaxGCEPDVolumes defines the maximum number of PD Volumes for GCE
// GCE instances can have up to 16 PD volumes attached.
// GCE instances can have up to 16 PD volumes attached.
DefaultMaxGCEPDVolumes
=
16
DefaultMaxGCEPDVolumes
=
16
...
@@ -95,19 +95,19 @@ const (
...
@@ -95,19 +95,19 @@ const (
// For example:
// For example:
// https://github.com/kubernetes/kubernetes/blob/36a218e/plugin/pkg/scheduler/factory/factory.go#L422
// https://github.com/kubernetes/kubernetes/blob/36a218e/plugin/pkg/scheduler/factory/factory.go#L422
// IMPORTANT
: this list contains the ordering of the predicates, if you develop a new predicates
// IMPORTANT
NOTE: this list contains the ordering of the predicates, if you develop a new predicate
// it is mandatory to add its name
on
this list.
// it is mandatory to add its name
to
this list.
//
otherwise it won't be processed, see generic_scheduler#podFitsOnNode()
//
Otherwise it won't be processed, see generic_scheduler#podFitsOnNode().
//
the order is based on the restrictiveness & complexity of predicates
//
The order is based on the restrictiveness & complexity of predicates.
//
d
esign doc: https://github.com/kubernetes/community/blob/master/contributors/design-proposals/scheduling/predicates-ordering.md
//
D
esign doc: https://github.com/kubernetes/community/blob/master/contributors/design-proposals/scheduling/predicates-ordering.md
var
(
var
(
predicatesOrdering
=
[]
string
{
CheckNodeConditionPred
,
predicatesOrdering
=
[]
string
{
CheckNodeConditionPred
,
GeneralPred
,
HostNamePred
,
PodFitsHostPortsPred
,
GeneralPred
,
HostNamePred
,
PodFitsHostPortsPred
,
MatchNodeSelectorPred
,
PodFitsResourcesPred
,
NoDiskConflictPred
,
MatchNodeSelectorPred
,
PodFitsResourcesPred
,
NoDiskConflictPred
,
PodToleratesNodeTaintsPred
,
PodToleratesNodeNoExecuteTaintsPred
,
CheckNodeLabelPresencePred
,
PodToleratesNodeTaintsPred
,
PodToleratesNodeNoExecuteTaintsPred
,
CheckNodeLabelPresencePred
,
checkServiceAffinityPred
,
MaxEBSVolumeCountPred
,
MaxGCEPDVolumeCountPred
,
checkServiceAffinityPred
,
MaxEBSVolumeCountPred
,
MaxGCEPDVolumeCountPred
,
MaxAzureDiskVolumeCountPred
,
CheckVolumeBinding
,
NoVolumeZoneConflictPred
,
MaxAzureDiskVolumeCountPred
,
CheckVolumeBinding
Pred
,
NoVolumeZoneConflictPred
,
CheckNodeMemoryPressurePred
,
CheckNodeDiskPressure
,
MatchInterPodAffinity
}
CheckNodeMemoryPressurePred
,
CheckNodeDiskPressure
Pred
,
MatchInterPodAffinityPred
}
)
)
// NodeInfo: Other types for predicate functions...
// NodeInfo: Other types for predicate functions...
...
@@ -124,7 +124,7 @@ type CachedPersistentVolumeInfo struct {
...
@@ -124,7 +124,7 @@ type CachedPersistentVolumeInfo struct {
corelisters
.
PersistentVolumeLister
corelisters
.
PersistentVolumeLister
}
}
func
Get
PredicatesOrdering
()
[]
string
{
func
PredicatesOrdering
()
[]
string
{
return
predicatesOrdering
return
predicatesOrdering
}
}
...
...
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
View file @
e62952d0
...
@@ -65,17 +65,17 @@ func init() {
...
@@ -65,17 +65,17 @@ func init() {
// Fit is defined based on the absence of port conflicts.
// Fit is defined based on the absence of port conflicts.
// This predicate is actually a default predicate, because it is invoked from
// This predicate is actually a default predicate, because it is invoked from
// predicates.GeneralPredicates()
// predicates.GeneralPredicates()
factory
.
RegisterFitPredicate
(
"PodFitsHostPorts"
,
predicates
.
PodFitsHostPorts
)
factory
.
RegisterFitPredicate
(
predicates
.
PodFitsHostPortsPred
,
predicates
.
PodFitsHostPorts
)
// Fit is determined by resource availability.
// Fit is determined by resource availability.
// This predicate is actually a default predicate, because it is invoked from
// This predicate is actually a default predicate, because it is invoked from
// predicates.GeneralPredicates()
// predicates.GeneralPredicates()
factory
.
RegisterFitPredicate
(
"PodFitsResources"
,
predicates
.
PodFitsResources
)
factory
.
RegisterFitPredicate
(
predicates
.
PodFitsResourcesPred
,
predicates
.
PodFitsResources
)
// Fit is determined by the presence of the Host parameter and a string match
// Fit is determined by the presence of the Host parameter and a string match
// This predicate is actually a default predicate, because it is invoked from
// This predicate is actually a default predicate, because it is invoked from
// predicates.GeneralPredicates()
// predicates.GeneralPredicates()
factory
.
RegisterFitPredicate
(
"HostName"
,
predicates
.
PodFitsHost
)
factory
.
RegisterFitPredicate
(
predicates
.
HostNamePred
,
predicates
.
PodFitsHost
)
// Fit is determined by node selector query.
// Fit is determined by node selector query.
factory
.
RegisterFitPredicate
(
"MatchNodeSelector"
,
predicates
.
PodMatchNodeSelector
)
factory
.
RegisterFitPredicate
(
predicates
.
MatchNodeSelectorPred
,
predicates
.
PodMatchNodeSelector
)
// Use equivalence class to speed up heavy predicates phase.
// Use equivalence class to speed up heavy predicates phase.
factory
.
RegisterGetEquivalencePodFunction
(
factory
.
RegisterGetEquivalencePodFunction
(
...
@@ -117,62 +117,62 @@ func defaultPredicates() sets.String {
...
@@ -117,62 +117,62 @@ func defaultPredicates() sets.String {
return
sets
.
NewString
(
return
sets
.
NewString
(
// Fit is determined by volume zone requirements.
// Fit is determined by volume zone requirements.
factory
.
RegisterFitPredicateFactory
(
factory
.
RegisterFitPredicateFactory
(
"NoVolumeZoneConflict"
,
predicates
.
NoVolumeZoneConflictPred
,
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
return
predicates
.
NewVolumeZonePredicate
(
args
.
PVInfo
,
args
.
PVCInfo
,
args
.
StorageClassInfo
)
return
predicates
.
NewVolumeZonePredicate
(
args
.
PVInfo
,
args
.
PVCInfo
,
args
.
StorageClassInfo
)
},
},
),
),
// Fit is determined by whether or not there would be too many AWS EBS volumes attached to the node
// Fit is determined by whether or not there would be too many AWS EBS volumes attached to the node
factory
.
RegisterFitPredicateFactory
(
factory
.
RegisterFitPredicateFactory
(
"MaxEBSVolumeCount"
,
predicates
.
MaxEBSVolumeCountPred
,
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
return
predicates
.
NewMaxPDVolumeCountPredicate
(
predicates
.
EBSVolumeFilterType
,
args
.
PVInfo
,
args
.
PVCInfo
)
return
predicates
.
NewMaxPDVolumeCountPredicate
(
predicates
.
EBSVolumeFilterType
,
args
.
PVInfo
,
args
.
PVCInfo
)
},
},
),
),
// Fit is determined by whether or not there would be too many GCE PD volumes attached to the node
// Fit is determined by whether or not there would be too many GCE PD volumes attached to the node
factory
.
RegisterFitPredicateFactory
(
factory
.
RegisterFitPredicateFactory
(
"MaxGCEPDVolumeCount"
,
predicates
.
MaxGCEPDVolumeCountPred
,
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
return
predicates
.
NewMaxPDVolumeCountPredicate
(
predicates
.
GCEPDVolumeFilterType
,
args
.
PVInfo
,
args
.
PVCInfo
)
return
predicates
.
NewMaxPDVolumeCountPredicate
(
predicates
.
GCEPDVolumeFilterType
,
args
.
PVInfo
,
args
.
PVCInfo
)
},
},
),
),
// Fit is determined by whether or not there would be too many Azure Disk volumes attached to the node
// Fit is determined by whether or not there would be too many Azure Disk volumes attached to the node
factory
.
RegisterFitPredicateFactory
(
factory
.
RegisterFitPredicateFactory
(
"MaxAzureDiskVolumeCount"
,
predicates
.
MaxAzureDiskVolumeCountPred
,
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
return
predicates
.
NewMaxPDVolumeCountPredicate
(
predicates
.
AzureDiskVolumeFilterType
,
args
.
PVInfo
,
args
.
PVCInfo
)
return
predicates
.
NewMaxPDVolumeCountPredicate
(
predicates
.
AzureDiskVolumeFilterType
,
args
.
PVInfo
,
args
.
PVCInfo
)
},
},
),
),
// Fit is determined by inter-pod affinity.
// Fit is determined by inter-pod affinity.
factory
.
RegisterFitPredicateFactory
(
factory
.
RegisterFitPredicateFactory
(
predicates
.
MatchInterPodAffinity
,
predicates
.
MatchInterPodAffinity
Pred
,
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
return
predicates
.
NewPodAffinityPredicate
(
args
.
NodeInfo
,
args
.
PodLister
)
return
predicates
.
NewPodAffinityPredicate
(
args
.
NodeInfo
,
args
.
PodLister
)
},
},
),
),
// Fit is determined by non-conflicting disk volumes.
// Fit is determined by non-conflicting disk volumes.
factory
.
RegisterFitPredicate
(
"NoDiskConflict"
,
predicates
.
NoDiskConflict
),
factory
.
RegisterFitPredicate
(
predicates
.
NoDiskConflictPred
,
predicates
.
NoDiskConflict
),
// GeneralPredicates are the predicates that are enforced by all Kubernetes components
// GeneralPredicates are the predicates that are enforced by all Kubernetes components
// (e.g. kubelet and all schedulers)
// (e.g. kubelet and all schedulers)
factory
.
RegisterFitPredicate
(
"GeneralPredicates"
,
predicates
.
GeneralPredicates
),
factory
.
RegisterFitPredicate
(
predicates
.
GeneralPred
,
predicates
.
GeneralPredicates
),
// Fit is determined by node memory pressure condition.
// Fit is determined by node memory pressure condition.
factory
.
RegisterFitPredicate
(
"CheckNodeMemoryPressure"
,
predicates
.
CheckNodeMemoryPressurePredicate
),
factory
.
RegisterFitPredicate
(
predicates
.
CheckNodeMemoryPressurePred
,
predicates
.
CheckNodeMemoryPressurePredicate
),
// Fit is determined by node disk pressure condition.
// Fit is determined by node disk pressure condition.
factory
.
RegisterFitPredicate
(
"CheckNodeDiskPressure"
,
predicates
.
CheckNodeDiskPressurePredicate
),
factory
.
RegisterFitPredicate
(
predicates
.
CheckNodeDiskPressurePred
,
predicates
.
CheckNodeDiskPressurePredicate
),
// Fit is determined by node conditions: not ready, network unavailable or out of disk.
// Fit is determined by node conditions: not ready, network unavailable or out of disk.
factory
.
RegisterMandatoryFitPredicate
(
"CheckNodeCondition"
,
predicates
.
CheckNodeConditionPredicate
),
factory
.
RegisterMandatoryFitPredicate
(
predicates
.
CheckNodeConditionPred
,
predicates
.
CheckNodeConditionPredicate
),
// Fit is determined based on whether a pod can tolerate all of the node's taints
// Fit is determined based on whether a pod can tolerate all of the node's taints
factory
.
RegisterFitPredicate
(
"PodToleratesNodeTaints"
,
predicates
.
PodToleratesNodeTaints
),
factory
.
RegisterFitPredicate
(
predicates
.
PodToleratesNodeTaintsPred
,
predicates
.
PodToleratesNodeTaints
),
// Fit is determined by volume topology requirements.
// Fit is determined by volume topology requirements.
factory
.
RegisterFitPredicateFactory
(
factory
.
RegisterFitPredicateFactory
(
predicates
.
CheckVolumeBinding
,
predicates
.
CheckVolumeBinding
Pred
,
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
return
predicates
.
NewVolumeBindingPredicate
(
args
.
VolumeBinder
)
return
predicates
.
NewVolumeBindingPredicate
(
args
.
VolumeBinder
)
},
},
...
@@ -185,18 +185,18 @@ func ApplyFeatureGates() {
...
@@ -185,18 +185,18 @@ func ApplyFeatureGates() {
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
TaintNodesByCondition
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
TaintNodesByCondition
)
{
// Remove "CheckNodeCondition" predicate
// Remove "CheckNodeCondition" predicate
factory
.
RemoveFitPredicate
(
"CheckNodeCondition"
)
factory
.
RemoveFitPredicate
(
predicates
.
CheckNodeConditionPred
)
// Remove Key "CheckNodeCondition" From All Algorithm Provider
// Remove Key "CheckNodeCondition" From All Algorithm Provider
// The key will be removed from all providers which in algorithmProviderMap[]
// The key will be removed from all providers which in algorithmProviderMap[]
// if you just want remove specific provider, call func RemovePredicateKeyFromAlgoProvider()
// if you just want remove specific provider, call func RemovePredicateKeyFromAlgoProvider()
factory
.
RemovePredicateKeyFromAlgorithmProviderMap
(
"CheckNodeCondition"
)
factory
.
RemovePredicateKeyFromAlgorithmProviderMap
(
predicates
.
CheckNodeConditionPred
)
// Fit is determined based on whether a pod can tolerate all of the node's taints
// Fit is determined based on whether a pod can tolerate all of the node's taints
factory
.
RegisterMandatoryFitPredicate
(
"PodToleratesNodeTaints"
,
predicates
.
PodToleratesNodeTaints
)
factory
.
RegisterMandatoryFitPredicate
(
predicates
.
PodToleratesNodeTaintsPred
,
predicates
.
PodToleratesNodeTaints
)
// Insert Key "PodToleratesNodeTaints" To All Algorithm Provider
// Insert Key "PodToleratesNodeTaints" To All Algorithm Provider
// The key will insert to all providers which in algorithmProviderMap[]
// The key will insert to all providers which in algorithmProviderMap[]
// if you just want insert to specific provider, call func InsertPredicateKeyToAlgoProvider()
// if you just want insert to specific provider, call func InsertPredicateKeyToAlgoProvider()
factory
.
InsertPredicateKeyToAlgorithmProviderMap
(
"PodToleratesNodeTaints"
)
factory
.
InsertPredicateKeyToAlgorithmProviderMap
(
predicates
.
PodToleratesNodeTaintsPred
)
glog
.
Warningf
(
"TaintNodesByCondition is enabled, PodToleratesNodeTaints predicate is mandatory"
)
glog
.
Warningf
(
"TaintNodesByCondition is enabled, PodToleratesNodeTaints predicate is mandatory"
)
}
}
...
...
plugin/pkg/scheduler/algorithmprovider/defaults/defaults_test.go
View file @
e62952d0
...
@@ -78,7 +78,7 @@ func TestDefaultPredicates(t *testing.T) {
...
@@ -78,7 +78,7 @@ func TestDefaultPredicates(t *testing.T) {
"CheckNodeDiskPressure"
,
"CheckNodeDiskPressure"
,
"CheckNodeCondition"
,
"CheckNodeCondition"
,
"PodToleratesNodeTaints"
,
"PodToleratesNodeTaints"
,
predicates
.
CheckVolumeBinding
,
predicates
.
CheckVolumeBinding
Pred
,
)
)
if
expected
:=
defaultPredicates
();
!
result
.
Equal
(
expected
)
{
if
expected
:=
defaultPredicates
();
!
result
.
Equal
(
expected
)
{
...
...
plugin/pkg/scheduler/core/generic_scheduler.go
View file @
e62952d0
...
@@ -444,7 +444,7 @@ func podFitsOnNode(
...
@@ -444,7 +444,7 @@ func podFitsOnNode(
// TODO(bsalamat): consider using eCache and adding proper eCache invalidations
// TODO(bsalamat): consider using eCache and adding proper eCache invalidations
// when pods are nominated or their nominations change.
// when pods are nominated or their nominations change.
eCacheAvailable
=
eCacheAvailable
&&
!
podsAdded
eCacheAvailable
=
eCacheAvailable
&&
!
podsAdded
for
_
,
predicateKey
:=
range
predicates
.
Get
PredicatesOrdering
()
{
for
_
,
predicateKey
:=
range
predicates
.
PredicatesOrdering
()
{
//TODO (yastij) : compute average predicate restrictiveness to export it as promethus metric
//TODO (yastij) : compute average predicate restrictiveness to export it as promethus metric
if
predicate
,
exist
:=
predicateFuncs
[
predicateKey
];
exist
{
if
predicate
,
exist
:=
predicateFuncs
[
predicateKey
];
exist
{
if
eCacheAvailable
{
if
eCacheAvailable
{
...
...
plugin/pkg/scheduler/core/generic_scheduler_test.go
View file @
e62952d0
...
@@ -43,7 +43,7 @@ import (
...
@@ -43,7 +43,7 @@ import (
)
)
var
(
var
(
order
=
[]
string
{
"false"
,
"true"
,
"matches"
,
"nopods"
,
predicates
.
MatchInterPodAffinity
}
order
=
[]
string
{
"false"
,
"true"
,
"matches"
,
"nopods"
,
predicates
.
MatchInterPodAffinity
Pred
}
)
)
func
falsePredicate
(
pod
*
v1
.
Pod
,
meta
algorithm
.
PredicateMetadata
,
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
func
falsePredicate
(
pod
*
v1
.
Pod
,
meta
algorithm
.
PredicateMetadata
,
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
...
@@ -872,7 +872,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
...
@@ -872,7 +872,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
nodes
=
append
(
nodes
,
node
)
nodes
=
append
(
nodes
,
node
)
}
}
if
test
.
addAffinityPredicate
{
if
test
.
addAffinityPredicate
{
test
.
predicates
[
predicates
.
MatchInterPodAffinity
]
=
algorithmpredicates
.
NewPodAffinityPredicate
(
FakeNodeInfo
(
*
nodes
[
0
]),
schedulertesting
.
FakePodLister
(
test
.
pods
))
test
.
predicates
[
predicates
.
MatchInterPodAffinity
Pred
]
=
algorithmpredicates
.
NewPodAffinityPredicate
(
FakeNodeInfo
(
*
nodes
[
0
]),
schedulertesting
.
FakePodLister
(
test
.
pods
))
}
}
nodeNameToInfo
:=
schedulercache
.
CreateNodeNameToInfoMap
(
test
.
pods
,
nodes
)
nodeNameToInfo
:=
schedulercache
.
CreateNodeNameToInfoMap
(
test
.
pods
,
nodes
)
nodeToPods
,
err
:=
selectNodesForPreemption
(
test
.
pod
,
nodeNameToInfo
,
nodes
,
test
.
predicates
,
PredicateMetadata
,
nil
,
nil
)
nodeToPods
,
err
:=
selectNodesForPreemption
(
test
.
pod
,
nodeNameToInfo
,
nodes
,
test
.
predicates
,
PredicateMetadata
,
nil
,
nil
)
...
...
plugin/pkg/scheduler/factory/factory.go
View file @
e62952d0
...
@@ -409,7 +409,7 @@ func (c *configFactory) invalidatePredicatesForPv(pv *v1.PersistentVolume) {
...
@@ -409,7 +409,7 @@ func (c *configFactory) invalidatePredicatesForPv(pv *v1.PersistentVolume) {
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
// Add/delete impacts the available PVs to choose from
// Add/delete impacts the available PVs to choose from
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
)
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
Pred
)
}
}
c
.
equivalencePodCache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
c
.
equivalencePodCache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
...
@@ -480,7 +480,7 @@ func (c *configFactory) invalidatePredicatesForPvc(pvc *v1.PersistentVolumeClaim
...
@@ -480,7 +480,7 @@ func (c *configFactory) invalidatePredicatesForPvc(pvc *v1.PersistentVolumeClaim
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
// Add/delete impacts the available PVs to choose from
// Add/delete impacts the available PVs to choose from
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
)
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
Pred
)
}
}
c
.
equivalencePodCache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
c
.
equivalencePodCache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
}
}
...
@@ -491,7 +491,7 @@ func (c *configFactory) invalidatePredicatesForPvcUpdate(old, new *v1.Persistent
...
@@ -491,7 +491,7 @@ func (c *configFactory) invalidatePredicatesForPvcUpdate(old, new *v1.Persistent
if
old
.
Spec
.
VolumeName
!=
new
.
Spec
.
VolumeName
{
if
old
.
Spec
.
VolumeName
!=
new
.
Spec
.
VolumeName
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
// PVC volume binding has changed
// PVC volume binding has changed
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
)
invalidPredicates
.
Insert
(
predicates
.
CheckVolumeBinding
Pred
)
}
}
// The bound volume type may change
// The bound volume type may change
invalidPredicates
.
Insert
(
maxPDVolumeCountPredicateKeys
...
)
invalidPredicates
.
Insert
(
maxPDVolumeCountPredicateKeys
...
)
...
...
plugin/pkg/scheduler/scheduler.go
View file @
e62952d0
...
@@ -278,7 +278,7 @@ func (sched *Scheduler) assumeAndBindVolumes(assumed *v1.Pod, host string) error
...
@@ -278,7 +278,7 @@ func (sched *Scheduler) assumeAndBindVolumes(assumed *v1.Pod, host string) error
err
=
fmt
.
Errorf
(
"Volume binding started, waiting for completion"
)
err
=
fmt
.
Errorf
(
"Volume binding started, waiting for completion"
)
if
bindingRequired
{
if
bindingRequired
{
if
sched
.
config
.
Ecache
!=
nil
{
if
sched
.
config
.
Ecache
!=
nil
{
invalidPredicates
:=
sets
.
NewString
(
predicates
.
CheckVolumeBinding
)
invalidPredicates
:=
sets
.
NewString
(
predicates
.
CheckVolumeBinding
Pred
)
sched
.
config
.
Ecache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
sched
.
config
.
Ecache
.
InvalidateCachedPredicateItemOfAllNodes
(
invalidPredicates
)
}
}
...
...
plugin/pkg/scheduler/scheduler_test.go
View file @
e62952d0
...
@@ -43,8 +43,6 @@ import (
...
@@ -43,8 +43,6 @@ import (
"k8s.io/kubernetes/plugin/pkg/scheduler/volumebinder"
"k8s.io/kubernetes/plugin/pkg/scheduler/volumebinder"
)
)
var
order
=
[]
string
{
"VolumeBindingChecker"
}
type
fakeBinder
struct
{
type
fakeBinder
struct
{
b
func
(
binding
*
v1
.
Binding
)
error
b
func
(
binding
*
v1
.
Binding
)
error
}
}
...
@@ -621,7 +619,7 @@ func setupTestSchedulerWithVolumeBinding(fakeVolumeBinder *volumebinder.VolumeBi
...
@@ -621,7 +619,7 @@ func setupTestSchedulerWithVolumeBinding(fakeVolumeBinder *volumebinder.VolumeBi
scache
.
AddNode
(
&
testNode
)
scache
.
AddNode
(
&
testNode
)
predicateMap
:=
map
[
string
]
algorithm
.
FitPredicate
{
predicateMap
:=
map
[
string
]
algorithm
.
FitPredicate
{
"VolumeBindingChecker"
:
predicates
.
NewVolumeBindingPredicate
(
fakeVolumeBinder
),
predicates
.
CheckVolumeBindingPred
:
predicates
.
NewVolumeBindingPredicate
(
fakeVolumeBinder
),
}
}
recorder
:=
broadcaster
.
NewRecorder
(
legacyscheme
.
Scheme
,
v1
.
EventSource
{
Component
:
"scheduler"
})
recorder
:=
broadcaster
.
NewRecorder
(
legacyscheme
.
Scheme
,
v1
.
EventSource
{
Component
:
"scheduler"
})
...
@@ -639,6 +637,7 @@ func makePredicateError(failReason string) error {
...
@@ -639,6 +637,7 @@ func makePredicateError(failReason string) error {
}
}
func
TestSchedulerWithVolumeBinding
(
t
*
testing
.
T
)
{
func
TestSchedulerWithVolumeBinding
(
t
*
testing
.
T
)
{
order
:=
[]
string
{
predicates
.
CheckVolumeBindingPred
,
predicates
.
GeneralPred
}
predicates
.
SetPredicatesOrdering
(
order
)
predicates
.
SetPredicatesOrdering
(
order
)
findErr
:=
fmt
.
Errorf
(
"find err"
)
findErr
:=
fmt
.
Errorf
(
"find err"
)
assumeErr
:=
fmt
.
Errorf
(
"assume err"
)
assumeErr
:=
fmt
.
Errorf
(
"assume err"
)
...
...
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