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
136e5398
Commit
136e5398
authored
Feb 15, 2018
by
Harry Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use consts as predicate name in handlers
parent
c03edcc5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
23 deletions
+23
-23
predicates.go
pkg/scheduler/algorithm/predicates/predicates.go
+3
-3
factory.go
pkg/scheduler/factory/factory.go
+20
-20
No files found.
pkg/scheduler/algorithm/predicates/predicates.go
View file @
136e5398
...
...
@@ -72,8 +72,8 @@ const (
PodToleratesNodeNoExecuteTaintsPred
=
"PodToleratesNodeNoExecuteTaints"
// CheckNodeLabelPresencePred defines the name of predicate CheckNodeLabelPresence.
CheckNodeLabelPresencePred
=
"CheckNodeLabelPresence"
//
c
heckServiceAffinityPred defines the name of predicate checkServiceAffinity.
checkServiceAffinityPred
=
"c
heckServiceAffinity"
//
C
heckServiceAffinityPred defines the name of predicate checkServiceAffinity.
CheckServiceAffinityPred
=
"C
heckServiceAffinity"
// MaxEBSVolumeCountPred defines the name of predicate MaxEBSVolumeCount.
MaxEBSVolumeCountPred
=
"MaxEBSVolumeCount"
// MaxGCEPDVolumeCountPred defines the name of predicate MaxGCEPDVolumeCount.
...
...
@@ -128,7 +128,7 @@ var (
GeneralPred
,
HostNamePred
,
PodFitsHostPortsPred
,
MatchNodeSelectorPred
,
PodFitsResourcesPred
,
NoDiskConflictPred
,
PodToleratesNodeTaintsPred
,
PodToleratesNodeNoExecuteTaintsPred
,
CheckNodeLabelPresencePred
,
c
heckServiceAffinityPred
,
MaxEBSVolumeCountPred
,
MaxGCEPDVolumeCountPred
,
C
heckServiceAffinityPred
,
MaxEBSVolumeCountPred
,
MaxGCEPDVolumeCountPred
,
MaxAzureDiskVolumeCountPred
,
CheckVolumeBindingPred
,
NoVolumeZoneConflictPred
,
CheckNodeMemoryPressurePred
,
CheckNodeDiskPressurePred
,
MatchInterPodAffinityPred
}
)
...
...
pkg/scheduler/factory/factory.go
View file @
136e5398
...
...
@@ -70,11 +70,11 @@ const (
)
var
(
serviceAffinitySet
=
sets
.
NewString
(
"ServiceAffinity"
)
matchInterPodAffinitySet
=
sets
.
NewString
(
"MatchInterPodAffinity"
)
generalPredicatesSets
=
sets
.
NewString
(
"GeneralPredicates"
)
noDiskConflictSet
=
sets
.
NewString
(
"NoDiskConflict"
)
maxPDVolumeCountPredicateKeys
=
[]
string
{
"MaxGCEPDVolumeCount"
,
"MaxAzureDiskVolumeCount"
,
"MaxEBSVolumeCount"
}
serviceAffinitySet
=
sets
.
NewString
(
predicates
.
CheckServiceAffinityPred
)
matchInterPodAffinitySet
=
sets
.
NewString
(
predicates
.
MatchInterPodAffinityPred
)
generalPredicatesSets
=
sets
.
NewString
(
predicates
.
GeneralPred
)
noDiskConflictSet
=
sets
.
NewString
(
predicates
.
NoDiskConflictPred
)
maxPDVolumeCountPredicateKeys
=
[]
string
{
predicates
.
MaxGCEPDVolumeCountPred
,
predicates
.
MaxAzureDiskVolumeCountPred
,
predicates
.
MaxEBSVolumeCountPred
}
)
// configFactory is the default implementation of the scheduler.Configurator interface.
...
...
@@ -377,7 +377,7 @@ func (c *configFactory) invalidatePredicatesForPvUpdate(oldPV, newPV *v1.Persist
for
k
,
v
:=
range
newPV
.
Labels
{
// If PV update modifies the zone/region labels.
if
isZoneRegionLabel
(
k
)
&&
!
reflect
.
DeepEqual
(
v
,
oldPV
.
Labels
[
k
])
{
invalidPredicates
.
Insert
(
"NoVolumeZoneConflict"
)
invalidPredicates
.
Insert
(
predicates
.
NoVolumeZoneConflictPred
)
break
}
}
...
...
@@ -434,19 +434,19 @@ func (c *configFactory) invalidatePredicatesForPv(pv *v1.PersistentVolume) {
// PV types which impact MaxPDVolumeCountPredicate
if
pv
.
Spec
.
AWSElasticBlockStore
!=
nil
{
invalidPredicates
.
Insert
(
"MaxEBSVolumeCount"
)
invalidPredicates
.
Insert
(
predicates
.
MaxEBSVolumeCountPred
)
}
if
pv
.
Spec
.
GCEPersistentDisk
!=
nil
{
invalidPredicates
.
Insert
(
"MaxGCEPDVolumeCount"
)
invalidPredicates
.
Insert
(
predicates
.
MaxGCEPDVolumeCountPred
)
}
if
pv
.
Spec
.
AzureDisk
!=
nil
{
invalidPredicates
.
Insert
(
"MaxAzureDiskVolumeCount"
)
invalidPredicates
.
Insert
(
predicates
.
MaxAzureDiskVolumeCountPred
)
}
// If PV contains zone related label, it may impact cached NoVolumeZoneConflict
for
k
:=
range
pv
.
Labels
{
if
isZoneRegionLabel
(
k
)
{
invalidPredicates
.
Insert
(
"NoVolumeZoneConflict"
)
invalidPredicates
.
Insert
(
predicates
.
NoVolumeZoneConflictPred
)
break
}
}
...
...
@@ -520,7 +520,7 @@ func (c *configFactory) invalidatePredicatesForPvc(pvc *v1.PersistentVolumeClaim
invalidPredicates
:=
sets
.
NewString
(
maxPDVolumeCountPredicateKeys
...
)
// The bound volume's label may change
invalidPredicates
.
Insert
(
"NoVolumeZoneConflict"
)
invalidPredicates
.
Insert
(
predicates
.
NoVolumeZoneConflictPred
)
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
// Add/delete impacts the available PVs to choose from
...
...
@@ -779,19 +779,19 @@ func (c *configFactory) invalidateCachedPredicatesOnNodeUpdate(newNode *v1.Node,
invalidPredicates
:=
sets
.
NewString
()
if
!
reflect
.
DeepEqual
(
oldNode
.
Status
.
Allocatable
,
newNode
.
Status
.
Allocatable
)
{
invalidPredicates
.
Insert
(
"GeneralPredicates"
)
// "PodFitsResources"
invalidPredicates
.
Insert
(
predicates
.
GeneralPred
)
// "PodFitsResources"
}
if
!
reflect
.
DeepEqual
(
oldNode
.
GetLabels
(),
newNode
.
GetLabels
())
{
invalidPredicates
.
Insert
(
"GeneralPredicates"
,
"ServiceAffinity"
)
// "PodSelectorMatches"
invalidPredicates
.
Insert
(
predicates
.
GeneralPred
,
predicates
.
CheckServiceAffinityPred
)
// "PodSelectorMatches"
for
k
,
v
:=
range
oldNode
.
GetLabels
()
{
// any label can be topology key of pod, we have to invalidate in all cases
if
v
!=
newNode
.
GetLabels
()[
k
]
{
invalidPredicates
.
Insert
(
"MatchInterPodAffinity"
)
invalidPredicates
.
Insert
(
predicates
.
MatchInterPodAffinityPred
)
}
// NoVolumeZoneConflict will only be affected by zone related label change
if
isZoneRegionLabel
(
k
)
{
if
v
!=
newNode
.
GetLabels
()[
k
]
{
invalidPredicates
.
Insert
(
"NoVolumeZoneConflict"
)
invalidPredicates
.
Insert
(
predicates
.
NoVolumeZoneConflictPred
)
}
}
}
...
...
@@ -807,7 +807,7 @@ func (c *configFactory) invalidateCachedPredicatesOnNodeUpdate(newNode *v1.Node,
}
if
!
reflect
.
DeepEqual
(
oldTaints
,
newTaints
)
||
!
reflect
.
DeepEqual
(
oldNode
.
Spec
.
Taints
,
newNode
.
Spec
.
Taints
)
{
invalidPredicates
.
Insert
(
"PodToleratesNodeTaints"
)
invalidPredicates
.
Insert
(
predicates
.
PodToleratesNodeTaintsPred
)
}
if
!
reflect
.
DeepEqual
(
oldNode
.
Status
.
Conditions
,
newNode
.
Status
.
Conditions
)
{
...
...
@@ -820,19 +820,19 @@ func (c *configFactory) invalidateCachedPredicatesOnNodeUpdate(newNode *v1.Node,
newConditions
[
cond
.
Type
]
=
cond
.
Status
}
if
oldConditions
[
v1
.
NodeMemoryPressure
]
!=
newConditions
[
v1
.
NodeMemoryPressure
]
{
invalidPredicates
.
Insert
(
"CheckNodeMemoryPressure"
)
invalidPredicates
.
Insert
(
predicates
.
CheckNodeMemoryPressurePred
)
}
if
oldConditions
[
v1
.
NodeDiskPressure
]
!=
newConditions
[
v1
.
NodeDiskPressure
]
{
invalidPredicates
.
Insert
(
"CheckNodeDiskPressure"
)
invalidPredicates
.
Insert
(
predicates
.
CheckNodeDiskPressurePred
)
}
if
oldConditions
[
v1
.
NodeReady
]
!=
newConditions
[
v1
.
NodeReady
]
||
oldConditions
[
v1
.
NodeOutOfDisk
]
!=
newConditions
[
v1
.
NodeOutOfDisk
]
||
oldConditions
[
v1
.
NodeNetworkUnavailable
]
!=
newConditions
[
v1
.
NodeNetworkUnavailable
]
{
invalidPredicates
.
Insert
(
"CheckNodeCondition"
)
invalidPredicates
.
Insert
(
predicates
.
CheckNodeConditionPred
)
}
}
if
newNode
.
Spec
.
Unschedulable
!=
oldNode
.
Spec
.
Unschedulable
{
invalidPredicates
.
Insert
(
"CheckNodeCondition"
)
invalidPredicates
.
Insert
(
predicates
.
CheckNodeConditionPred
)
}
c
.
equivalencePodCache
.
InvalidateCachedPredicateItem
(
newNode
.
GetName
(),
invalidPredicates
)
}
...
...
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