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
fad6b326
Commit
fad6b326
authored
Oct 24, 2018
by
ravisantoshgudimetla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix default algorithm provider priority insertion
parent
04d39490
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
13 deletions
+34
-13
defaults.go
pkg/scheduler/algorithmprovider/defaults/defaults.go
+4
-2
factory.go
pkg/scheduler/factory/factory.go
+0
-1
plugins.go
pkg/scheduler/factory/plugins.go
+11
-0
priorities.go
test/e2e/scheduling/priorities.go
+19
-10
No files found.
pkg/scheduler/algorithmprovider/defaults/defaults.go
View file @
fad6b326
...
@@ -207,14 +207,16 @@ func ApplyFeatureGates() {
...
@@ -207,14 +207,16 @@ func ApplyFeatureGates() {
factory
.
InsertPredicateKeyToAlgorithmProviderMap
(
predicates
.
PodToleratesNodeTaintsPred
)
factory
.
InsertPredicateKeyToAlgorithmProviderMap
(
predicates
.
PodToleratesNodeTaintsPred
)
factory
.
InsertPredicateKeyToAlgorithmProviderMap
(
predicates
.
CheckNodeUnschedulablePred
)
factory
.
InsertPredicateKeyToAlgorithmProviderMap
(
predicates
.
CheckNodeUnschedulablePred
)
glog
.
Warning
f
(
"TaintNodesByCondition is enabled, PodToleratesNodeTaints predicate is mandatory"
)
glog
.
Info
f
(
"TaintNodesByCondition is enabled, PodToleratesNodeTaints predicate is mandatory"
)
}
}
// Prioritizes nodes that satisfy pod's resource limits
// Prioritizes nodes that satisfy pod's resource limits
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
ResourceLimitsPriorityFunction
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
ResourceLimitsPriorityFunction
)
{
glog
.
Infof
(
"Registering resourcelimits priority function"
)
factory
.
RegisterPriorityFunction2
(
"ResourceLimitsPriority"
,
priorities
.
ResourceLimitsPriorityMap
,
nil
,
1
)
factory
.
RegisterPriorityFunction2
(
"ResourceLimitsPriority"
,
priorities
.
ResourceLimitsPriorityMap
,
nil
,
1
)
// Register the priority function to specific provider too.
factory
.
InsertPriorityKeyToAlgorithmProviderMap
(
factory
.
RegisterPriorityFunction2
(
"ResourceLimitsPriority"
,
priorities
.
ResourceLimitsPriorityMap
,
nil
,
1
))
}
}
}
}
func
registerAlgorithmProvider
(
predSet
,
priSet
sets
.
String
)
{
func
registerAlgorithmProvider
(
predSet
,
priSet
sets
.
String
)
{
...
...
pkg/scheduler/factory/factory.go
View file @
fad6b326
...
@@ -1096,7 +1096,6 @@ func (c *configFactory) CreateFromProvider(providerName string) (*Config, error)
...
@@ -1096,7 +1096,6 @@ func (c *configFactory) CreateFromProvider(providerName string) (*Config, error)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
c
.
CreateFromKeys
(
provider
.
FitPredicateKeys
,
provider
.
PriorityFunctionKeys
,
[]
algorithm
.
SchedulerExtender
{})
return
c
.
CreateFromKeys
(
provider
.
FitPredicateKeys
,
provider
.
PriorityFunctionKeys
,
[]
algorithm
.
SchedulerExtender
{})
}
}
...
...
pkg/scheduler/factory/plugins.go
View file @
fad6b326
...
@@ -167,6 +167,17 @@ func InsertPredicateKeyToAlgorithmProviderMap(key string) {
...
@@ -167,6 +167,17 @@ func InsertPredicateKeyToAlgorithmProviderMap(key string) {
return
return
}
}
// InsertPriorityKeyToAlgorithmProviderMap inserts a priority function to all algorithmProviders which are in algorithmProviderMap.
func
InsertPriorityKeyToAlgorithmProviderMap
(
key
string
)
{
schedulerFactoryMutex
.
Lock
()
defer
schedulerFactoryMutex
.
Unlock
()
for
_
,
provider
:=
range
algorithmProviderMap
{
provider
.
PriorityFunctionKeys
.
Insert
(
key
)
}
return
}
// RegisterMandatoryFitPredicate registers a fit predicate with the algorithm registry, the predicate is used by
// RegisterMandatoryFitPredicate registers a fit predicate with the algorithm registry, the predicate is used by
// kubelet, DaemonSet; it is always included in configuration. Returns the name with which the predicate was
// kubelet, DaemonSet; it is always included in configuration. Returns the name with which the predicate was
// registered.
// registered.
...
...
test/e2e/scheduling/priorities.go
View file @
fad6b326
...
@@ -32,7 +32,9 @@ import (
...
@@ -32,7 +32,9 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/uuid"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
clientset
"k8s.io/client-go/kubernetes"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/features"
priorityutil
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util"
priorityutil
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util"
"k8s.io/kubernetes/test/e2e/common"
"k8s.io/kubernetes/test/e2e/common"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
...
@@ -83,7 +85,7 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -83,7 +85,7 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
})
It
(
"Pod should be schedule to node that don't match the PodAntiAffinity terms"
,
func
()
{
It
(
"Pod should be schedule
d
to node that don't match the PodAntiAffinity terms"
,
func
()
{
By
(
"Trying to launch a pod with a label to get a node which can launch it."
)
By
(
"Trying to launch a pod with a label to get a node which can launch it."
)
pod
:=
runPausePod
(
f
,
pausePodConfig
{
pod
:=
runPausePod
(
f
,
pausePodConfig
{
Name
:
"pod-with-label-security-s1"
,
Name
:
"pod-with-label-security-s1"
,
...
@@ -144,7 +146,7 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -144,7 +146,7 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
Expect
(
labelPod
.
Spec
.
NodeName
)
.
NotTo
(
Equal
(
nodeName
))
Expect
(
labelPod
.
Spec
.
NodeName
)
.
NotTo
(
Equal
(
nodeName
))
})
})
It
(
"Pod should avoid
to schedule to node
that have avoidPod annotation"
,
func
()
{
It
(
"Pod should avoid
nodes
that have avoidPod annotation"
,
func
()
{
nodeName
:=
nodeList
.
Items
[
0
]
.
Name
nodeName
:=
nodeList
.
Items
[
0
]
.
Name
// make the nodes have balanced cpu,mem usage
// make the nodes have balanced cpu,mem usage
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
...
@@ -207,7 +209,8 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -207,7 +209,8 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
}
}
})
})
It
(
"Pod should perfer to scheduled to nodes pod can tolerate"
,
func
()
{
It
(
"Pod should be preferably scheduled to nodes pod can tolerate"
,
func
()
{
// make the nodes have balanced cpu,mem usage ratio
// make the nodes have balanced cpu,mem usage ratio
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
...
@@ -257,6 +260,9 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -257,6 +260,9 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
Expect
(
tolePod
.
Spec
.
NodeName
)
.
To
(
Equal
(
nodeName
))
Expect
(
tolePod
.
Spec
.
NodeName
)
.
To
(
Equal
(
nodeName
))
})
})
It
(
"Pod should be preferably scheduled to nodes which satisfy its limits"
,
func
()
{
It
(
"Pod should be preferably scheduled to nodes which satisfy its limits"
,
func
()
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
ResourceLimitsPriorityFunction
)
{
framework
.
Skipf
(
"ResourceLimits Priority function is not enabled, so skipping this test"
)
}
var
podwithLargeRequestedResource
*
v1
.
ResourceRequirements
=
&
v1
.
ResourceRequirements
{
var
podwithLargeRequestedResource
*
v1
.
ResourceRequirements
=
&
v1
.
ResourceRequirements
{
Requests
:
v1
.
ResourceList
{
Requests
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
resource
.
MustParse
(
"100Mi"
),
v1
.
ResourceMemory
:
resource
.
MustParse
(
"100Mi"
),
...
@@ -264,26 +270,28 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -264,26 +270,28 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
},
},
Limits
:
v1
.
ResourceList
{
Limits
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
resource
.
MustParse
(
"3000Mi"
),
v1
.
ResourceMemory
:
resource
.
MustParse
(
"3000Mi"
),
v1
.
ResourceCPU
:
resource
.
MustParse
(
"
1
00m"
),
v1
.
ResourceCPU
:
resource
.
MustParse
(
"
50
00m"
),
},
},
}
}
// Update one node to have large allocatable.
// Update one node to have large allocatable.
lastNode
:=
nodeList
.
Items
[
len
(
nodeList
.
Items
)
-
1
]
lastNode
:=
nodeList
.
Items
[
len
(
nodeList
.
Items
)
-
1
]
nodeName
:=
lastNode
.
Name
nodeName
:=
lastNode
.
Name
nodeOriginalMemory
,
found
:=
lastNode
.
Status
.
Allocatable
[
v1
.
ResourceMemory
]
nodeOriginalMemory
,
found
:=
lastNode
.
Status
.
Allocatable
[
v1
.
ResourceMemory
]
nodeOriginalCPU
,
found
:=
lastNode
.
Status
.
Allocatable
[
v1
.
ResourceCPU
]
Expect
(
found
)
.
To
(
Equal
(
true
))
Expect
(
found
)
.
To
(
Equal
(
true
))
nodeOriginalMemoryVal
:=
nodeOriginalMemory
.
Value
()
nodeOriginalMemoryVal
:=
nodeOriginalMemory
.
Value
()
err
:=
updateMemoryOfNode
(
cs
,
nodeName
,
int64
(
10000
))
nodeOriginalCPUVal
:=
nodeOriginalCPU
.
MilliValue
()
err
:=
updateNodeAllocatable
(
cs
,
nodeName
,
int64
(
10000
),
int64
(
12000
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
defer
func
()
{
defer
func
()
{
// Resize the node back to its original
memory
.
// Resize the node back to its original
allocatable values
.
if
err
:=
update
MemoryOfNode
(
cs
,
nodeName
,
nodeOriginalMemory
Val
);
err
!=
nil
{
if
err
:=
update
NodeAllocatable
(
cs
,
nodeName
,
nodeOriginalMemoryVal
,
nodeOriginalCPU
Val
);
err
!=
nil
{
framework
.
Logf
(
"Failed to revert node memory with %v"
,
err
)
framework
.
Logf
(
"Failed to revert node memory with %v"
,
err
)
}
}
}()
}()
err
=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
err
=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
// After the above we should see 50% of node to be available which is 5000MiB for large node.
// After the above we should see 50% of node to be available which is 5000MiB
memory, 6000m cpu
for large node.
By
(
"Create a pod with unusual large limits"
)
By
(
"Create a pod with unusual large limits"
)
podWithLargeLimits
:=
"with-large-limits"
podWithLargeLimits
:=
"with-large-limits"
...
@@ -445,8 +453,8 @@ func addRandomTaitToNode(cs clientset.Interface, nodeName string) *v1.Taint {
...
@@ -445,8 +453,8 @@ func addRandomTaitToNode(cs clientset.Interface, nodeName string) *v1.Taint {
return
&
testTaint
return
&
testTaint
}
}
// update
MemoryOfNode updates the memory of given node with the given value
// update
NodeAllocatable updates the allocatable values of given node with the given values.
func
update
MemoryOfNode
(
c
clientset
.
Interface
,
nodeName
string
,
memory
int64
)
error
{
func
update
NodeAllocatable
(
c
clientset
.
Interface
,
nodeName
string
,
memory
,
cpu
int64
)
error
{
node
,
err
:=
c
.
CoreV1
()
.
Nodes
()
.
Get
(
nodeName
,
metav1
.
GetOptions
{})
node
,
err
:=
c
.
CoreV1
()
.
Nodes
()
.
Get
(
nodeName
,
metav1
.
GetOptions
{})
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
oldData
,
err
:=
json
.
Marshal
(
node
)
oldData
,
err
:=
json
.
Marshal
(
node
)
...
@@ -454,6 +462,7 @@ func updateMemoryOfNode(c clientset.Interface, nodeName string, memory int64) er
...
@@ -454,6 +462,7 @@ func updateMemoryOfNode(c clientset.Interface, nodeName string, memory int64) er
return
err
return
err
}
}
node
.
Status
.
Allocatable
[
v1
.
ResourceMemory
]
=
*
resource
.
NewQuantity
(
memory
,
resource
.
BinarySI
)
node
.
Status
.
Allocatable
[
v1
.
ResourceMemory
]
=
*
resource
.
NewQuantity
(
memory
,
resource
.
BinarySI
)
node
.
Status
.
Allocatable
[
v1
.
ResourceCPU
]
=
*
resource
.
NewMilliQuantity
(
cpu
,
resource
.
DecimalSI
)
newData
,
err
:=
json
.
Marshal
(
node
)
newData
,
err
:=
json
.
Marshal
(
node
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
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