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
e8e8e2d0
Commit
e8e8e2d0
authored
Jul 08, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unneeded factories
parent
d6e84cc2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
12 additions
and
68 deletions
+12
-68
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+4
-12
predicates_test.go
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
+1
-2
node_affinity.go
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
+1
-12
node_affinity_test.go
.../pkg/scheduler/algorithm/priorities/node_affinity_test.go
+1
-2
taint_toleration.go
...in/pkg/scheduler/algorithm/priorities/taint_toleration.go
+1
-14
taint_toleration_test.go
...g/scheduler/algorithm/priorities/taint_toleration_test.go
+1
-2
defaults.go
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
+3
-24
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
e8e8e2d0
...
@@ -999,19 +999,11 @@ func (checker *PodAffinityChecker) NodeMatchPodAffinityAntiAffinity(pod *api.Pod
...
@@ -999,19 +999,11 @@ func (checker *PodAffinityChecker) NodeMatchPodAffinityAntiAffinity(pod *api.Pod
return
true
return
true
}
}
type
TolerationMatch
struct
{
func
PodToleratesNodeTaints
(
pod
*
api
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
error
)
{
info
NodeInfo
}
func
NewTolerationMatchPredicate
(
info
NodeInfo
)
algorithm
.
FitPredicate
{
tolerationMatch
:=
&
TolerationMatch
{
info
:
info
,
}
return
tolerationMatch
.
PodToleratesNodeTaints
}
func
(
t
*
TolerationMatch
)
PodToleratesNodeTaints
(
pod
*
api
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
error
)
{
node
:=
nodeInfo
.
Node
()
node
:=
nodeInfo
.
Node
()
if
node
==
nil
{
return
false
,
fmt
.
Errorf
(
"node not found"
)
}
taints
,
err
:=
api
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
taints
,
err
:=
api
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
View file @
e8e8e2d0
...
@@ -2724,10 +2724,9 @@ func TestPodToleratesTaints(t *testing.T) {
...
@@ -2724,10 +2724,9 @@ func TestPodToleratesTaints(t *testing.T) {
}
}
for
_
,
test
:=
range
podTolerateTaintsTests
{
for
_
,
test
:=
range
podTolerateTaintsTests
{
tolerationMatch
:=
TolerationMatch
{
FakeNodeInfo
(
test
.
node
)}
nodeInfo
:=
schedulercache
.
NewNodeInfo
()
nodeInfo
:=
schedulercache
.
NewNodeInfo
()
nodeInfo
.
SetNode
(
&
test
.
node
)
nodeInfo
.
SetNode
(
&
test
.
node
)
fits
,
err
:=
tolerationMatch
.
PodToleratesNodeTaints
(
test
.
pod
,
PredicateMetadata
(
test
.
pod
),
nodeInfo
)
fits
,
err
:=
PodToleratesNodeTaints
(
test
.
pod
,
PredicateMetadata
(
test
.
pod
),
nodeInfo
)
if
fits
==
false
&&
!
reflect
.
DeepEqual
(
err
,
ErrTaintsTolerationsNotMatch
)
{
if
fits
==
false
&&
!
reflect
.
DeepEqual
(
err
,
ErrTaintsTolerationsNotMatch
)
{
t
.
Errorf
(
"%s, unexpected error: %v"
,
test
.
test
,
err
)
t
.
Errorf
(
"%s, unexpected error: %v"
,
test
.
test
,
err
)
}
}
...
...
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
View file @
e8e8e2d0
...
@@ -25,23 +25,12 @@ import (
...
@@ -25,23 +25,12 @@ import (
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
)
)
type
NodeAffinity
struct
{
nodeLister
algorithm
.
NodeLister
}
func
NewNodeAffinityPriority
(
nodeLister
algorithm
.
NodeLister
)
algorithm
.
PriorityFunction
{
nodeAffinity
:=
&
NodeAffinity
{
nodeLister
:
nodeLister
,
}
return
nodeAffinity
.
CalculateNodeAffinityPriority
}
// CalculateNodeAffinityPriority prioritizes nodes according to node affinity scheduling preferences
// CalculateNodeAffinityPriority prioritizes nodes according to node affinity scheduling preferences
// indicated in PreferredDuringSchedulingIgnoredDuringExecution. Each time a node match a preferredSchedulingTerm,
// indicated in PreferredDuringSchedulingIgnoredDuringExecution. Each time a node match a preferredSchedulingTerm,
// it will a get an add of preferredSchedulingTerm.Weight. Thus, the more preferredSchedulingTerms
// it will a get an add of preferredSchedulingTerm.Weight. Thus, the more preferredSchedulingTerms
// the node satisfies and the more the preferredSchedulingTerm that is satisfied weights, the higher
// the node satisfies and the more the preferredSchedulingTerm that is satisfied weights, the higher
// score the node gets.
// score the node gets.
func
(
s
*
NodeAffinity
)
CalculateNodeAffinityPriority
(
pod
*
api
.
Pod
,
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
nodeLister
algorithm
.
NodeLister
)
(
schedulerapi
.
HostPriorityList
,
error
)
{
func
CalculateNodeAffinityPriority
(
pod
*
api
.
Pod
,
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
nodeLister
algorithm
.
NodeLister
)
(
schedulerapi
.
HostPriorityList
,
error
)
{
var
maxCount
int
var
maxCount
int
counts
:=
map
[
string
]
int
{}
counts
:=
map
[
string
]
int
{}
...
...
plugin/pkg/scheduler/algorithm/priorities/node_affinity_test.go
View file @
e8e8e2d0
...
@@ -156,8 +156,7 @@ func TestNodeAffinityPriority(t *testing.T) {
...
@@ -156,8 +156,7 @@ func TestNodeAffinityPriority(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
nodeAffinity
:=
NodeAffinity
{
nodeLister
:
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
test
.
nodes
})}
list
,
err
:=
CalculateNodeAffinityPriority
(
test
.
pod
,
schedulercache
.
CreateNodeNameToInfoMap
(
nil
),
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
test
.
nodes
}))
list
,
err
:=
nodeAffinity
.
CalculateNodeAffinityPriority
(
test
.
pod
,
schedulercache
.
CreateNodeNameToInfoMap
(
nil
),
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
test
.
nodes
}))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
...
plugin/pkg/scheduler/algorithm/priorities/taint_toleration.go
View file @
e8e8e2d0
...
@@ -24,19 +24,6 @@ import (
...
@@ -24,19 +24,6 @@ import (
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
)
)
// NodeTaints hold the node lister
type
TaintToleration
struct
{
nodeLister
algorithm
.
NodeLister
}
// NewTaintTolerationPriority
func
NewTaintTolerationPriority
(
nodeLister
algorithm
.
NodeLister
)
algorithm
.
PriorityFunction
{
taintToleration
:=
&
TaintToleration
{
nodeLister
:
nodeLister
,
}
return
taintToleration
.
ComputeTaintTolerationPriority
}
// CountIntolerableTaintsPreferNoSchedule gives the count of intolerable taints of a pod with effect PreferNoSchedule
// CountIntolerableTaintsPreferNoSchedule gives the count of intolerable taints of a pod with effect PreferNoSchedule
func
countIntolerableTaintsPreferNoSchedule
(
taints
[]
api
.
Taint
,
tolerations
[]
api
.
Toleration
)
(
intolerableTaints
int
)
{
func
countIntolerableTaintsPreferNoSchedule
(
taints
[]
api
.
Taint
,
tolerations
[]
api
.
Toleration
)
(
intolerableTaints
int
)
{
for
_
,
taint
:=
range
taints
{
for
_
,
taint
:=
range
taints
{
...
@@ -63,7 +50,7 @@ func getAllTolerationPreferNoSchedule(tolerations []api.Toleration) (tolerationL
...
@@ -63,7 +50,7 @@ func getAllTolerationPreferNoSchedule(tolerations []api.Toleration) (tolerationL
}
}
// ComputeTaintTolerationPriority prepares the priority list for all the nodes based on the number of intolerable taints on the node
// ComputeTaintTolerationPriority prepares the priority list for all the nodes based on the number of intolerable taints on the node
func
(
s
*
TaintToleration
)
ComputeTaintTolerationPriority
(
pod
*
api
.
Pod
,
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
nodeLister
algorithm
.
NodeLister
)
(
schedulerapi
.
HostPriorityList
,
error
)
{
func
ComputeTaintTolerationPriority
(
pod
*
api
.
Pod
,
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
nodeLister
algorithm
.
NodeLister
)
(
schedulerapi
.
HostPriorityList
,
error
)
{
// counts hold the count of intolerable taints of a pod for a given node
// counts hold the count of intolerable taints of a pod for a given node
counts
:=
make
(
map
[
string
]
int
)
counts
:=
make
(
map
[
string
]
int
)
...
...
plugin/pkg/scheduler/algorithm/priorities/taint_toleration_test.go
View file @
e8e8e2d0
...
@@ -212,8 +212,7 @@ func TestTaintAndToleration(t *testing.T) {
...
@@ -212,8 +212,7 @@ func TestTaintAndToleration(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
nodeNameToInfo
:=
schedulercache
.
CreateNodeNameToInfoMap
([]
*
api
.
Pod
{{}})
nodeNameToInfo
:=
schedulercache
.
CreateNodeNameToInfoMap
([]
*
api
.
Pod
{{}})
taintToleration
:=
TaintToleration
{
nodeLister
:
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
test
.
nodes
})}
list
,
err
:=
ComputeTaintTolerationPriority
(
list
,
err
:=
taintToleration
.
ComputeTaintTolerationPriority
(
test
.
pod
,
test
.
pod
,
nodeNameToInfo
,
nodeNameToInfo
,
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
test
.
nodes
}))
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
test
.
nodes
}))
...
...
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
View file @
e8e8e2d0
...
@@ -147,12 +147,7 @@ func defaultPredicates() sets.String {
...
@@ -147,12 +147,7 @@ func defaultPredicates() sets.String {
factory
.
RegisterFitPredicate
(
"GeneralPredicates"
,
predicates
.
GeneralPredicates
),
factory
.
RegisterFitPredicate
(
"GeneralPredicates"
,
predicates
.
GeneralPredicates
),
// 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
.
RegisterFitPredicateFactory
(
factory
.
RegisterFitPredicate
(
"PodToleratesNodeTaints"
,
predicates
.
PodToleratesNodeTaints
),
"PodToleratesNodeTaints"
,
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
FitPredicate
{
return
predicates
.
NewTolerationMatchPredicate
(
args
.
NodeInfo
)
},
),
// Fit is determined by node memory pressure condition.
// Fit is determined by node memory pressure condition.
factory
.
RegisterFitPredicate
(
"CheckNodeMemoryPressure"
,
predicates
.
CheckNodeMemoryPressurePredicate
),
factory
.
RegisterFitPredicate
(
"CheckNodeMemoryPressure"
,
predicates
.
CheckNodeMemoryPressurePredicate
),
...
@@ -175,23 +170,7 @@ func defaultPriorities() sets.String {
...
@@ -175,23 +170,7 @@ func defaultPriorities() sets.String {
Weight
:
1
,
Weight
:
1
,
},
},
),
),
factory
.
RegisterPriorityConfigFactory
(
factory
.
RegisterPriorityFunction
(
"NodeAffinityPriority"
,
priorities
.
CalculateNodeAffinityPriority
,
1
),
"NodeAffinityPriority"
,
factory
.
RegisterPriorityFunction
(
"TaintTolerationPriority"
,
priorities
.
ComputeTaintTolerationPriority
,
1
),
factory
.
PriorityConfigFactory
{
Function
:
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
PriorityFunction
{
return
priorities
.
NewNodeAffinityPriority
(
args
.
NodeLister
)
},
Weight
:
1
,
},
),
factory
.
RegisterPriorityConfigFactory
(
"TaintTolerationPriority"
,
factory
.
PriorityConfigFactory
{
Function
:
func
(
args
factory
.
PluginFactoryArgs
)
algorithm
.
PriorityFunction
{
return
priorities
.
NewTaintTolerationPriority
(
args
.
NodeLister
)
},
Weight
:
1
,
},
),
)
)
}
}
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