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
e0a7d966
Commit
e0a7d966
authored
Oct 01, 2018
by
Mayank Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move informer event handlers to Scheduler
parent
d57d6062
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
368 additions
and
260 deletions
+368
-260
BUILD
pkg/scheduler/BUILD
+11
-1
BUILD
pkg/scheduler/equivalence/BUILD
+13
-0
eventhandlers.go
pkg/scheduler/eventhandlers.go
+0
-0
eventhandlers_test.go
pkg/scheduler/eventhandlers_test.go
+265
-0
BUILD
pkg/scheduler/factory/BUILD
+0
-4
factory.go
pkg/scheduler/factory/factory.go
+0
-0
factory_test.go
pkg/scheduler/factory/factory_test.go
+0
-237
scheduler.go
pkg/scheduler/scheduler.go
+3
-1
scheduler_test.go
pkg/scheduler/scheduler_test.go
+7
-4
daemonset_test.go
test/integration/daemonset/daemonset_test.go
+23
-10
scheduler_test.go
test/integration/scheduler/scheduler_test.go
+16
-2
util.go
test/integration/scheduler/util.go
+16
-1
util.go
test/integration/util/util.go
+14
-0
No files found.
pkg/scheduler/BUILD
View file @
e0a7d966
...
@@ -3,12 +3,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
...
@@ -3,12 +3,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
go_library(
name = "go_default_library",
name = "go_default_library",
srcs = [
srcs = [
"eventhandlers.go",
"scheduler.go",
"scheduler.go",
"testutil.go",
"testutil.go",
],
],
importpath = "k8s.io/kubernetes/pkg/scheduler",
importpath = "k8s.io/kubernetes/pkg/scheduler",
visibility = ["//visibility:public"],
visibility = ["//visibility:public"],
deps = [
deps = [
"//pkg/kubelet/apis:go_default_library",
"//pkg/scheduler/algorithm:go_default_library",
"//pkg/scheduler/algorithm:go_default_library",
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/api:go_default_library",
"//pkg/scheduler/api:go_default_library",
...
@@ -22,8 +24,10 @@ go_library(
...
@@ -22,8 +24,10 @@ go_library(
"//pkg/scheduler/plugins/v1alpha1:go_default_library",
"//pkg/scheduler/plugins/v1alpha1:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/storage/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/client-go/informers/apps/v1:go_default_library",
"//staging/src/k8s.io/client-go/informers/apps/v1:go_default_library",
...
@@ -32,6 +36,7 @@ go_library(
...
@@ -32,6 +36,7 @@ go_library(
"//staging/src/k8s.io/client-go/informers/storage/v1:go_default_library",
"//staging/src/k8s.io/client-go/informers/storage/v1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
"//staging/src/k8s.io/client-go/tools/record:go_default_library",
"//staging/src/k8s.io/client-go/tools/record:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
],
...
@@ -39,7 +44,10 @@ go_library(
...
@@ -39,7 +44,10 @@ go_library(
go_test(
go_test(
name = "go_default_test",
name = "go_default_test",
srcs = ["scheduler_test.go"],
srcs = [
"eventhandlers_test.go",
"scheduler_test.go",
],
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = [
"//pkg/api/legacyscheme:go_default_library",
"//pkg/api/legacyscheme:go_default_library",
...
@@ -53,6 +61,7 @@ go_test(
...
@@ -53,6 +61,7 @@ go_test(
"//pkg/scheduler/factory:go_default_library",
"//pkg/scheduler/factory:go_default_library",
"//pkg/scheduler/internal/cache:go_default_library",
"//pkg/scheduler/internal/cache:go_default_library",
"//pkg/scheduler/internal/cache/fake:go_default_library",
"//pkg/scheduler/internal/cache/fake:go_default_library",
"//pkg/scheduler/internal/queue:go_default_library",
"//pkg/scheduler/nodeinfo:go_default_library",
"//pkg/scheduler/nodeinfo:go_default_library",
"//pkg/scheduler/volumebinder:go_default_library",
"//pkg/scheduler/volumebinder:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
...
@@ -88,6 +97,7 @@ filegroup(
...
@@ -88,6 +97,7 @@ filegroup(
"//pkg/scheduler/api:all-srcs",
"//pkg/scheduler/api:all-srcs",
"//pkg/scheduler/apis/config:all-srcs",
"//pkg/scheduler/apis/config:all-srcs",
"//pkg/scheduler/core:all-srcs",
"//pkg/scheduler/core:all-srcs",
"//pkg/scheduler/equivalence:all-srcs",
"//pkg/scheduler/factory:all-srcs",
"//pkg/scheduler/factory:all-srcs",
"//pkg/scheduler/internal/cache:all-srcs",
"//pkg/scheduler/internal/cache:all-srcs",
"//pkg/scheduler/internal/queue:all-srcs",
"//pkg/scheduler/internal/queue:all-srcs",
...
...
pkg/scheduler/equivalence/BUILD
0 → 100644
View file @
e0a7d966
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
pkg/scheduler/eventhandlers.go
0 → 100644
View file @
e0a7d966
This diff is collapsed.
Click to expand it.
pkg/scheduler/eventhandlers_test.go
0 → 100644
View file @
e0a7d966
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
scheduler
import
(
"reflect"
"testing"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/scheduler/factory"
fakecache
"k8s.io/kubernetes/pkg/scheduler/internal/cache/fake"
)
func
TestSkipPodUpdate
(
t
*
testing
.
T
)
{
table
:=
[]
struct
{
pod
*
v1
.
Pod
isAssumedPodFunc
func
(
*
v1
.
Pod
)
bool
getPodFunc
func
(
*
v1
.
Pod
)
*
v1
.
Pod
expected
bool
name
string
}{
{
name
:
"Non-assumed pod"
,
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
},
},
isAssumedPodFunc
:
func
(
*
v1
.
Pod
)
bool
{
return
false
},
getPodFunc
:
func
(
*
v1
.
Pod
)
*
v1
.
Pod
{
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
},
}
},
expected
:
false
,
},
{
name
:
"with changes on ResourceVersion, Spec.NodeName and/or Annotations"
,
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
Annotations
:
map
[
string
]
string
{
"a"
:
"b"
},
ResourceVersion
:
"0"
,
},
Spec
:
v1
.
PodSpec
{
NodeName
:
"node-0"
,
},
},
isAssumedPodFunc
:
func
(
*
v1
.
Pod
)
bool
{
return
true
},
getPodFunc
:
func
(
*
v1
.
Pod
)
*
v1
.
Pod
{
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
Annotations
:
map
[
string
]
string
{
"c"
:
"d"
},
ResourceVersion
:
"1"
,
},
Spec
:
v1
.
PodSpec
{
NodeName
:
"node-1"
,
},
}
},
expected
:
true
,
},
{
name
:
"with changes on Labels"
,
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
},
},
isAssumedPodFunc
:
func
(
*
v1
.
Pod
)
bool
{
return
true
},
getPodFunc
:
func
(
*
v1
.
Pod
)
*
v1
.
Pod
{
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
Labels
:
map
[
string
]
string
{
"c"
:
"d"
},
},
}
},
expected
:
false
,
},
}
for
_
,
test
:=
range
table
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
c
:=
NewFromConfig
(
&
factory
.
Config
{
SchedulerCache
:
&
fakecache
.
Cache
{
IsAssumedPodFunc
:
test
.
isAssumedPodFunc
,
GetPodFunc
:
test
.
getPodFunc
,
},
},
)
got
:=
c
.
skipPodUpdate
(
test
.
pod
)
if
got
!=
test
.
expected
{
t
.
Errorf
(
"skipPodUpdate() = %t, expected = %t"
,
got
,
test
.
expected
)
}
})
}
}
func
TestNodeAllocatableChanged
(
t
*
testing
.
T
)
{
newQuantity
:=
func
(
value
int64
)
resource
.
Quantity
{
return
*
resource
.
NewQuantity
(
value
,
resource
.
BinarySI
)
}
for
_
,
c
:=
range
[]
struct
{
Name
string
Changed
bool
OldAllocatable
v1
.
ResourceList
NewAllocatable
v1
.
ResourceList
}{
{
Name
:
"no allocatable resources changed"
,
Changed
:
false
,
OldAllocatable
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
newQuantity
(
1024
)},
NewAllocatable
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
newQuantity
(
1024
)},
},
{
Name
:
"new node has more allocatable resources"
,
Changed
:
true
,
OldAllocatable
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
newQuantity
(
1024
)},
NewAllocatable
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
newQuantity
(
1024
),
v1
.
ResourceStorage
:
newQuantity
(
1024
)},
},
}
{
oldNode
:=
&
v1
.
Node
{
Status
:
v1
.
NodeStatus
{
Allocatable
:
c
.
OldAllocatable
}}
newNode
:=
&
v1
.
Node
{
Status
:
v1
.
NodeStatus
{
Allocatable
:
c
.
NewAllocatable
}}
changed
:=
nodeAllocatableChanged
(
newNode
,
oldNode
)
if
changed
!=
c
.
Changed
{
t
.
Errorf
(
"nodeAllocatableChanged should be %t, got %t"
,
c
.
Changed
,
changed
)
}
}
}
func
TestNodeLabelsChanged
(
t
*
testing
.
T
)
{
for
_
,
c
:=
range
[]
struct
{
Name
string
Changed
bool
OldLabels
map
[
string
]
string
NewLabels
map
[
string
]
string
}{
{
Name
:
"no labels changed"
,
Changed
:
false
,
OldLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
NewLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
// Labels changed.
{
Name
:
"new node has more labels"
,
Changed
:
true
,
OldLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
NewLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"test"
:
"value"
},
},
}
{
oldNode
:=
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
c
.
OldLabels
}}
newNode
:=
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
c
.
NewLabels
}}
changed
:=
nodeLabelsChanged
(
newNode
,
oldNode
)
if
changed
!=
c
.
Changed
{
t
.
Errorf
(
"Test case %q failed: should be %t, got %t"
,
c
.
Name
,
c
.
Changed
,
changed
)
}
}
}
func
TestNodeTaintsChanged
(
t
*
testing
.
T
)
{
for
_
,
c
:=
range
[]
struct
{
Name
string
Changed
bool
OldTaints
[]
v1
.
Taint
NewTaints
[]
v1
.
Taint
}{
{
Name
:
"no taint changed"
,
Changed
:
false
,
OldTaints
:
[]
v1
.
Taint
{{
Key
:
"key"
,
Value
:
"value"
}},
NewTaints
:
[]
v1
.
Taint
{{
Key
:
"key"
,
Value
:
"value"
}},
},
{
Name
:
"taint value changed"
,
Changed
:
true
,
OldTaints
:
[]
v1
.
Taint
{{
Key
:
"key"
,
Value
:
"value1"
}},
NewTaints
:
[]
v1
.
Taint
{{
Key
:
"key"
,
Value
:
"value2"
}},
},
}
{
oldNode
:=
&
v1
.
Node
{
Spec
:
v1
.
NodeSpec
{
Taints
:
c
.
OldTaints
}}
newNode
:=
&
v1
.
Node
{
Spec
:
v1
.
NodeSpec
{
Taints
:
c
.
NewTaints
}}
changed
:=
nodeTaintsChanged
(
newNode
,
oldNode
)
if
changed
!=
c
.
Changed
{
t
.
Errorf
(
"Test case %q failed: should be %t, not %t"
,
c
.
Name
,
c
.
Changed
,
changed
)
}
}
}
func
TestNodeConditionsChanged
(
t
*
testing
.
T
)
{
nodeConditionType
:=
reflect
.
TypeOf
(
v1
.
NodeCondition
{})
if
nodeConditionType
.
NumField
()
!=
6
{
t
.
Errorf
(
"NodeCondition type has changed. The nodeConditionsChanged() function must be reevaluated."
)
}
for
_
,
c
:=
range
[]
struct
{
Name
string
Changed
bool
OldConditions
[]
v1
.
NodeCondition
NewConditions
[]
v1
.
NodeCondition
}{
{
Name
:
"no condition changed"
,
Changed
:
false
,
OldConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
}},
NewConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
}},
},
{
Name
:
"only LastHeartbeatTime changed"
,
Changed
:
false
,
OldConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
,
LastHeartbeatTime
:
metav1
.
Unix
(
1
,
0
)}},
NewConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
,
LastHeartbeatTime
:
metav1
.
Unix
(
2
,
0
)}},
},
{
Name
:
"new node has more healthy conditions"
,
Changed
:
true
,
OldConditions
:
[]
v1
.
NodeCondition
{},
NewConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeReady
,
Status
:
v1
.
ConditionTrue
}},
},
{
Name
:
"new node has less unhealthy conditions"
,
Changed
:
true
,
OldConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
}},
NewConditions
:
[]
v1
.
NodeCondition
{},
},
{
Name
:
"condition status changed"
,
Changed
:
true
,
OldConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeReady
,
Status
:
v1
.
ConditionFalse
}},
NewConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeReady
,
Status
:
v1
.
ConditionTrue
}},
},
}
{
oldNode
:=
&
v1
.
Node
{
Status
:
v1
.
NodeStatus
{
Conditions
:
c
.
OldConditions
}}
newNode
:=
&
v1
.
Node
{
Status
:
v1
.
NodeStatus
{
Conditions
:
c
.
NewConditions
}}
changed
:=
nodeConditionsChanged
(
newNode
,
oldNode
)
if
changed
!=
c
.
Changed
{
t
.
Errorf
(
"Test case %q failed: should be %t, got %t"
,
c
.
Name
,
c
.
Changed
,
changed
)
}
}
}
pkg/scheduler/factory/BUILD
View file @
e0a7d966
...
@@ -10,7 +10,6 @@ go_library(
...
@@ -10,7 +10,6 @@ go_library(
visibility = ["//visibility:public"],
visibility = ["//visibility:public"],
deps = [
deps = [
"//pkg/api/v1/pod:go_default_library",
"//pkg/api/v1/pod:go_default_library",
"//pkg/kubelet/apis:go_default_library",
"//pkg/scheduler/algorithm:go_default_library",
"//pkg/scheduler/algorithm:go_default_library",
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/algorithm/priorities:go_default_library",
"//pkg/scheduler/algorithm/priorities:go_default_library",
...
@@ -25,7 +24,6 @@ go_library(
...
@@ -25,7 +24,6 @@ go_library(
"//pkg/scheduler/util:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//pkg/scheduler/volumebinder:go_default_library",
"//pkg/scheduler/volumebinder:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/storage/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library",
...
@@ -65,12 +63,10 @@ go_test(
...
@@ -65,12 +63,10 @@ go_test(
"//pkg/scheduler/api:go_default_library",
"//pkg/scheduler/api:go_default_library",
"//pkg/scheduler/api/latest:go_default_library",
"//pkg/scheduler/api/latest:go_default_library",
"//pkg/scheduler/internal/cache:go_default_library",
"//pkg/scheduler/internal/cache:go_default_library",
"//pkg/scheduler/internal/cache/fake:go_default_library",
"//pkg/scheduler/internal/queue:go_default_library",
"//pkg/scheduler/internal/queue:go_default_library",
"//pkg/scheduler/nodeinfo:go_default_library",
"//pkg/scheduler/nodeinfo:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
...
...
pkg/scheduler/factory/factory.go
View file @
e0a7d966
This diff is collapsed.
Click to expand it.
pkg/scheduler/factory/factory_test.go
View file @
e0a7d966
...
@@ -24,7 +24,6 @@ import (
...
@@ -24,7 +24,6 @@ import (
"time"
"time"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -40,7 +39,6 @@ import (
...
@@ -40,7 +39,6 @@ import (
schedulerapi
"k8s.io/kubernetes/pkg/scheduler/api"
schedulerapi
"k8s.io/kubernetes/pkg/scheduler/api"
latestschedulerapi
"k8s.io/kubernetes/pkg/scheduler/api/latest"
latestschedulerapi
"k8s.io/kubernetes/pkg/scheduler/api/latest"
schedulerinternalcache
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
schedulerinternalcache
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
fakecache
"k8s.io/kubernetes/pkg/scheduler/internal/cache/fake"
internalqueue
"k8s.io/kubernetes/pkg/scheduler/internal/queue"
internalqueue
"k8s.io/kubernetes/pkg/scheduler/internal/queue"
schedulernodeinfo
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
schedulernodeinfo
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
"k8s.io/kubernetes/pkg/scheduler/util"
"k8s.io/kubernetes/pkg/scheduler/util"
...
@@ -425,98 +423,6 @@ func TestInvalidFactoryArgs(t *testing.T) {
...
@@ -425,98 +423,6 @@ func TestInvalidFactoryArgs(t *testing.T) {
}
}
func
TestSkipPodUpdate
(
t
*
testing
.
T
)
{
table
:=
[]
struct
{
pod
*
v1
.
Pod
isAssumedPodFunc
func
(
*
v1
.
Pod
)
bool
getPodFunc
func
(
*
v1
.
Pod
)
*
v1
.
Pod
expected
bool
name
string
}{
{
name
:
"Non-assumed pod"
,
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
},
},
isAssumedPodFunc
:
func
(
*
v1
.
Pod
)
bool
{
return
false
},
getPodFunc
:
func
(
*
v1
.
Pod
)
*
v1
.
Pod
{
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
},
}
},
expected
:
false
,
},
{
name
:
"with changes on ResourceVersion, Spec.NodeName and/or Annotations"
,
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
Annotations
:
map
[
string
]
string
{
"a"
:
"b"
},
ResourceVersion
:
"0"
,
},
Spec
:
v1
.
PodSpec
{
NodeName
:
"node-0"
,
},
},
isAssumedPodFunc
:
func
(
*
v1
.
Pod
)
bool
{
return
true
},
getPodFunc
:
func
(
*
v1
.
Pod
)
*
v1
.
Pod
{
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
Annotations
:
map
[
string
]
string
{
"c"
:
"d"
},
ResourceVersion
:
"1"
,
},
Spec
:
v1
.
PodSpec
{
NodeName
:
"node-1"
,
},
}
},
expected
:
true
,
},
{
name
:
"with changes on Labels"
,
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
},
},
isAssumedPodFunc
:
func
(
*
v1
.
Pod
)
bool
{
return
true
},
getPodFunc
:
func
(
*
v1
.
Pod
)
*
v1
.
Pod
{
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod-0"
,
Labels
:
map
[
string
]
string
{
"c"
:
"d"
},
},
}
},
expected
:
false
,
},
}
for
_
,
test
:=
range
table
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
c
:=
&
configFactory
{
schedulerCache
:
&
fakecache
.
Cache
{
IsAssumedPodFunc
:
test
.
isAssumedPodFunc
,
GetPodFunc
:
test
.
getPodFunc
,
},
}
got
:=
c
.
skipPodUpdate
(
test
.
pod
)
if
got
!=
test
.
expected
{
t
.
Errorf
(
"skipPodUpdate() = %t, expected = %t"
,
got
,
test
.
expected
)
}
})
}
}
func
newConfigFactory
(
client
clientset
.
Interface
,
hardPodAffinitySymmetricWeight
int32
,
stopCh
<-
chan
struct
{})
Configurator
{
func
newConfigFactory
(
client
clientset
.
Interface
,
hardPodAffinitySymmetricWeight
int32
,
stopCh
<-
chan
struct
{})
Configurator
{
informerFactory
:=
informers
.
NewSharedInformerFactory
(
client
,
0
)
informerFactory
:=
informers
.
NewSharedInformerFactory
(
client
,
0
)
return
NewConfigFactory
(
&
ConfigFactoryArgs
{
return
NewConfigFactory
(
&
ConfigFactoryArgs
{
...
@@ -654,146 +560,3 @@ func testGetBinderFunc(expectedBinderType, podName string, extenders []algorithm
...
@@ -654,146 +560,3 @@ func testGetBinderFunc(expectedBinderType, podName string, extenders []algorithm
t
.
Errorf
(
"Expected binder %q but got %q"
,
expectedBinderType
,
binderType
)
t
.
Errorf
(
"Expected binder %q but got %q"
,
expectedBinderType
,
binderType
)
}
}
}
}
func
TestNodeAllocatableChanged
(
t
*
testing
.
T
)
{
newQuantity
:=
func
(
value
int64
)
resource
.
Quantity
{
return
*
resource
.
NewQuantity
(
value
,
resource
.
BinarySI
)
}
for
_
,
c
:=
range
[]
struct
{
Name
string
Changed
bool
OldAllocatable
v1
.
ResourceList
NewAllocatable
v1
.
ResourceList
}{
{
Name
:
"no allocatable resources changed"
,
Changed
:
false
,
OldAllocatable
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
newQuantity
(
1024
)},
NewAllocatable
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
newQuantity
(
1024
)},
},
{
Name
:
"new node has more allocatable resources"
,
Changed
:
true
,
OldAllocatable
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
newQuantity
(
1024
)},
NewAllocatable
:
v1
.
ResourceList
{
v1
.
ResourceMemory
:
newQuantity
(
1024
),
v1
.
ResourceStorage
:
newQuantity
(
1024
)},
},
}
{
oldNode
:=
&
v1
.
Node
{
Status
:
v1
.
NodeStatus
{
Allocatable
:
c
.
OldAllocatable
}}
newNode
:=
&
v1
.
Node
{
Status
:
v1
.
NodeStatus
{
Allocatable
:
c
.
NewAllocatable
}}
changed
:=
nodeAllocatableChanged
(
newNode
,
oldNode
)
if
changed
!=
c
.
Changed
{
t
.
Errorf
(
"nodeAllocatableChanged should be %t, got %t"
,
c
.
Changed
,
changed
)
}
}
}
func
TestNodeLabelsChanged
(
t
*
testing
.
T
)
{
for
_
,
c
:=
range
[]
struct
{
Name
string
Changed
bool
OldLabels
map
[
string
]
string
NewLabels
map
[
string
]
string
}{
{
Name
:
"no labels changed"
,
Changed
:
false
,
OldLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
NewLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
// Labels changed.
{
Name
:
"new node has more labels"
,
Changed
:
true
,
OldLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
NewLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"test"
:
"value"
},
},
}
{
oldNode
:=
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
c
.
OldLabels
}}
newNode
:=
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
c
.
NewLabels
}}
changed
:=
nodeLabelsChanged
(
newNode
,
oldNode
)
if
changed
!=
c
.
Changed
{
t
.
Errorf
(
"Test case %q failed: should be %t, got %t"
,
c
.
Name
,
c
.
Changed
,
changed
)
}
}
}
func
TestNodeTaintsChanged
(
t
*
testing
.
T
)
{
for
_
,
c
:=
range
[]
struct
{
Name
string
Changed
bool
OldTaints
[]
v1
.
Taint
NewTaints
[]
v1
.
Taint
}{
{
Name
:
"no taint changed"
,
Changed
:
false
,
OldTaints
:
[]
v1
.
Taint
{{
Key
:
"key"
,
Value
:
"value"
}},
NewTaints
:
[]
v1
.
Taint
{{
Key
:
"key"
,
Value
:
"value"
}},
},
{
Name
:
"taint value changed"
,
Changed
:
true
,
OldTaints
:
[]
v1
.
Taint
{{
Key
:
"key"
,
Value
:
"value1"
}},
NewTaints
:
[]
v1
.
Taint
{{
Key
:
"key"
,
Value
:
"value2"
}},
},
}
{
oldNode
:=
&
v1
.
Node
{
Spec
:
v1
.
NodeSpec
{
Taints
:
c
.
OldTaints
}}
newNode
:=
&
v1
.
Node
{
Spec
:
v1
.
NodeSpec
{
Taints
:
c
.
NewTaints
}}
changed
:=
nodeTaintsChanged
(
newNode
,
oldNode
)
if
changed
!=
c
.
Changed
{
t
.
Errorf
(
"Test case %q failed: should be %t, not %t"
,
c
.
Name
,
c
.
Changed
,
changed
)
}
}
}
func
TestNodeConditionsChanged
(
t
*
testing
.
T
)
{
nodeConditionType
:=
reflect
.
TypeOf
(
v1
.
NodeCondition
{})
if
nodeConditionType
.
NumField
()
!=
6
{
t
.
Errorf
(
"NodeCondition type has changed. The nodeConditionsChanged() function must be reevaluated."
)
}
for
_
,
c
:=
range
[]
struct
{
Name
string
Changed
bool
OldConditions
[]
v1
.
NodeCondition
NewConditions
[]
v1
.
NodeCondition
}{
{
Name
:
"no condition changed"
,
Changed
:
false
,
OldConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
}},
NewConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
}},
},
{
Name
:
"only LastHeartbeatTime changed"
,
Changed
:
false
,
OldConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
,
LastHeartbeatTime
:
metav1
.
Unix
(
1
,
0
)}},
NewConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
,
LastHeartbeatTime
:
metav1
.
Unix
(
2
,
0
)}},
},
{
Name
:
"new node has more healthy conditions"
,
Changed
:
true
,
OldConditions
:
[]
v1
.
NodeCondition
{},
NewConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeReady
,
Status
:
v1
.
ConditionTrue
}},
},
{
Name
:
"new node has less unhealthy conditions"
,
Changed
:
true
,
OldConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
}},
NewConditions
:
[]
v1
.
NodeCondition
{},
},
{
Name
:
"condition status changed"
,
Changed
:
true
,
OldConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeReady
,
Status
:
v1
.
ConditionFalse
}},
NewConditions
:
[]
v1
.
NodeCondition
{{
Type
:
v1
.
NodeReady
,
Status
:
v1
.
ConditionTrue
}},
},
}
{
oldNode
:=
&
v1
.
Node
{
Status
:
v1
.
NodeStatus
{
Conditions
:
c
.
OldConditions
}}
newNode
:=
&
v1
.
Node
{
Status
:
v1
.
NodeStatus
{
Conditions
:
c
.
NewConditions
}}
changed
:=
nodeConditionsChanged
(
newNode
,
oldNode
)
if
changed
!=
c
.
Changed
{
t
.
Errorf
(
"Test case %q failed: should be %t, got %t"
,
c
.
Name
,
c
.
Changed
,
changed
)
}
}
}
pkg/scheduler/scheduler.go
View file @
e0a7d966
...
@@ -138,7 +138,6 @@ func New(client clientset.Interface,
...
@@ -138,7 +138,6 @@ func New(client clientset.Interface,
for
_
,
opt
:=
range
opts
{
for
_
,
opt
:=
range
opts
{
opt
(
&
options
)
opt
(
&
options
)
}
}
// Set up the configurator which can create schedulers from configs.
// Set up the configurator which can create schedulers from configs.
configurator
:=
factory
.
NewConfigFactory
(
&
factory
.
ConfigFactoryArgs
{
configurator
:=
factory
.
NewConfigFactory
(
&
factory
.
ConfigFactoryArgs
{
SchedulerName
:
options
.
schedulerName
,
SchedulerName
:
options
.
schedulerName
,
...
@@ -193,8 +192,11 @@ func New(client clientset.Interface,
...
@@ -193,8 +192,11 @@ func New(client clientset.Interface,
config
.
Recorder
=
recorder
config
.
Recorder
=
recorder
config
.
DisablePreemption
=
options
.
disablePreemption
config
.
DisablePreemption
=
options
.
disablePreemption
config
.
StopEverything
=
stopCh
config
.
StopEverything
=
stopCh
// Create the scheduler.
// Create the scheduler.
sched
:=
NewFromConfig
(
config
)
sched
:=
NewFromConfig
(
config
)
AddAllEventHandlers
(
sched
,
options
.
schedulerName
,
nodeInformer
,
podInformer
,
pvInformer
,
pvcInformer
,
replicationControllerInformer
,
replicaSetInformer
,
statefulSetInformer
,
serviceInformer
,
pdbInformer
,
storageClassInformer
)
return
sched
,
nil
return
sched
,
nil
}
}
...
...
pkg/scheduler/scheduler_test.go
View file @
e0a7d966
...
@@ -48,6 +48,7 @@ import (
...
@@ -48,6 +48,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/factory"
"k8s.io/kubernetes/pkg/scheduler/factory"
schedulerinternalcache
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
schedulerinternalcache
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
fakecache
"k8s.io/kubernetes/pkg/scheduler/internal/cache/fake"
fakecache
"k8s.io/kubernetes/pkg/scheduler/internal/cache/fake"
internalqueue
"k8s.io/kubernetes/pkg/scheduler/internal/queue"
schedulernodeinfo
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
schedulernodeinfo
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
"k8s.io/kubernetes/pkg/scheduler/volumebinder"
"k8s.io/kubernetes/pkg/scheduler/volumebinder"
)
)
...
@@ -633,7 +634,7 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {
...
@@ -633,7 +634,7 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {
func
setupTestScheduler
(
queuedPodStore
*
clientcache
.
FIFO
,
scache
schedulerinternalcache
.
Cache
,
informerFactory
informers
.
SharedInformerFactory
,
predicateMap
map
[
string
]
predicates
.
FitPredicate
,
recorder
record
.
EventRecorder
)
(
*
Scheduler
,
chan
*
v1
.
Binding
,
chan
error
)
{
func
setupTestScheduler
(
queuedPodStore
*
clientcache
.
FIFO
,
scache
schedulerinternalcache
.
Cache
,
informerFactory
informers
.
SharedInformerFactory
,
predicateMap
map
[
string
]
predicates
.
FitPredicate
,
recorder
record
.
EventRecorder
)
(
*
Scheduler
,
chan
*
v1
.
Binding
,
chan
error
)
{
algo
:=
core
.
NewGenericScheduler
(
algo
:=
core
.
NewGenericScheduler
(
scache
,
scache
,
nil
,
internalqueue
.
NewSchedulingQueue
(
nil
)
,
predicateMap
,
predicateMap
,
predicates
.
EmptyPredicateMetadataProducer
,
predicates
.
EmptyPredicateMetadataProducer
,
[]
priorities
.
PriorityConfig
{},
[]
priorities
.
PriorityConfig
{},
...
@@ -645,7 +646,8 @@ func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache schedulerintern
...
@@ -645,7 +646,8 @@ func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache schedulerintern
informerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
()
.
Lister
(),
informerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
()
.
Lister
(),
false
,
false
,
false
,
false
,
api
.
DefaultPercentageOfNodesToScore
)
api
.
DefaultPercentageOfNodesToScore
,
)
bindingChan
:=
make
(
chan
*
v1
.
Binding
,
1
)
bindingChan
:=
make
(
chan
*
v1
.
Binding
,
1
)
errChan
:=
make
(
chan
error
,
1
)
errChan
:=
make
(
chan
error
,
1
)
...
@@ -684,7 +686,7 @@ func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache schedulerintern
...
@@ -684,7 +686,7 @@ func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache schedulerintern
func
setupTestSchedulerLongBindingWithRetry
(
queuedPodStore
*
clientcache
.
FIFO
,
scache
schedulerinternalcache
.
Cache
,
informerFactory
informers
.
SharedInformerFactory
,
predicateMap
map
[
string
]
predicates
.
FitPredicate
,
stop
chan
struct
{},
bindingTime
time
.
Duration
)
(
*
Scheduler
,
chan
*
v1
.
Binding
)
{
func
setupTestSchedulerLongBindingWithRetry
(
queuedPodStore
*
clientcache
.
FIFO
,
scache
schedulerinternalcache
.
Cache
,
informerFactory
informers
.
SharedInformerFactory
,
predicateMap
map
[
string
]
predicates
.
FitPredicate
,
stop
chan
struct
{},
bindingTime
time
.
Duration
)
(
*
Scheduler
,
chan
*
v1
.
Binding
)
{
algo
:=
core
.
NewGenericScheduler
(
algo
:=
core
.
NewGenericScheduler
(
scache
,
scache
,
nil
,
internalqueue
.
NewSchedulingQueue
(
nil
)
,
predicateMap
,
predicateMap
,
predicates
.
EmptyPredicateMetadataProducer
,
predicates
.
EmptyPredicateMetadataProducer
,
[]
priorities
.
PriorityConfig
{},
[]
priorities
.
PriorityConfig
{},
...
@@ -696,7 +698,8 @@ func setupTestSchedulerLongBindingWithRetry(queuedPodStore *clientcache.FIFO, sc
...
@@ -696,7 +698,8 @@ func setupTestSchedulerLongBindingWithRetry(queuedPodStore *clientcache.FIFO, sc
informerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
()
.
Lister
(),
informerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
()
.
Lister
(),
false
,
false
,
false
,
false
,
api
.
DefaultPercentageOfNodesToScore
)
api
.
DefaultPercentageOfNodesToScore
,
)
bindingChan
:=
make
(
chan
*
v1
.
Binding
,
2
)
bindingChan
:=
make
(
chan
*
v1
.
Binding
,
2
)
sched
:=
NewFromConfig
(
&
factory
.
Config
{
sched
:=
NewFromConfig
(
&
factory
.
Config
{
...
...
test/integration/daemonset/daemonset_test.go
View file @
e0a7d966
...
@@ -114,14 +114,29 @@ func setupScheduler(
...
@@ -114,14 +114,29 @@ func setupScheduler(
HardPodAffinitySymmetricWeight
:
v1
.
DefaultHardPodAffinitySymmetricWeight
,
HardPodAffinitySymmetricWeight
:
v1
.
DefaultHardPodAffinitySymmetricWeight
,
DisablePreemption
:
false
,
DisablePreemption
:
false
,
PercentageOfNodesToScore
:
100
,
PercentageOfNodesToScore
:
100
,
StopCh
:
stopCh
,
})
})
schedulerConfig
,
err
:=
schedulerConfigFactory
.
Create
()
schedulerConfig
,
err
:=
schedulerConfigFactory
.
Create
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Couldn't create scheduler config: %v"
,
err
)
t
.
Fatalf
(
"Couldn't create scheduler config: %v"
,
err
)
}
}
schedulerConfig
.
StopEverything
=
stopCh
// TODO: Replace NewFromConfig and AddAllEventHandlers with scheduler.New() in
// all test/integration tests.
sched
:=
scheduler
.
NewFromConfig
(
schedulerConfig
)
scheduler
.
AddAllEventHandlers
(
sched
,
v1
.
DefaultSchedulerName
,
informerFactory
.
Core
()
.
V1
()
.
Nodes
(),
informerFactory
.
Core
()
.
V1
()
.
Pods
(),
informerFactory
.
Core
()
.
V1
()
.
PersistentVolumes
(),
informerFactory
.
Core
()
.
V1
()
.
PersistentVolumeClaims
(),
informerFactory
.
Core
()
.
V1
()
.
ReplicationControllers
(),
informerFactory
.
Apps
()
.
V1
()
.
ReplicaSets
(),
informerFactory
.
Apps
()
.
V1
()
.
StatefulSets
(),
informerFactory
.
Core
()
.
V1
()
.
Services
(),
informerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
(),
informerFactory
.
Storage
()
.
V1
()
.
StorageClasses
(),
)
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
:=
record
.
NewBroadcaster
()
schedulerConfig
.
Recorder
=
eventBroadcaster
.
NewRecorder
(
schedulerConfig
.
Recorder
=
eventBroadcaster
.
NewRecorder
(
...
@@ -132,8 +147,6 @@ func setupScheduler(
...
@@ -132,8 +147,6 @@ func setupScheduler(
Interface
:
cs
.
CoreV1
()
.
Events
(
""
),
Interface
:
cs
.
CoreV1
()
.
Events
(
""
),
})
})
sched
:=
scheduler
.
NewFromConfig
(
schedulerConfig
)
algorithmprovider
.
ApplyFeatureGates
()
algorithmprovider
.
ApplyFeatureGates
()
go
sched
.
Run
()
go
sched
.
Run
()
...
@@ -513,12 +526,12 @@ func TestOneNodeDaemonLaunchesPod(t *testing.T) {
...
@@ -513,12 +526,12 @@ func TestOneNodeDaemonLaunchesPod(t *testing.T) {
stopCh
:=
make
(
chan
struct
{})
stopCh
:=
make
(
chan
struct
{})
defer
close
(
stopCh
)
defer
close
(
stopCh
)
informers
.
Start
(
stopCh
)
go
dc
.
Run
(
5
,
stopCh
)
// Start Scheduler
// Start Scheduler
setupScheduler
(
t
,
clientset
,
informers
,
stopCh
)
setupScheduler
(
t
,
clientset
,
informers
,
stopCh
)
informers
.
Start
(
stopCh
)
go
dc
.
Run
(
5
,
stopCh
)
ds
:=
newDaemonSet
(
"foo"
,
ns
.
Name
)
ds
:=
newDaemonSet
(
"foo"
,
ns
.
Name
)
ds
.
Spec
.
UpdateStrategy
=
*
strategy
ds
.
Spec
.
UpdateStrategy
=
*
strategy
_
,
err
:=
dsClient
.
Create
(
ds
)
_
,
err
:=
dsClient
.
Create
(
ds
)
...
@@ -924,11 +937,11 @@ func TestTaintedNode(t *testing.T) {
...
@@ -924,11 +937,11 @@ func TestTaintedNode(t *testing.T) {
stopCh
:=
make
(
chan
struct
{})
stopCh
:=
make
(
chan
struct
{})
defer
close
(
stopCh
)
defer
close
(
stopCh
)
informers
.
Start
(
stopCh
)
go
dc
.
Run
(
5
,
stopCh
)
// Start Scheduler
// Start Scheduler
setupScheduler
(
t
,
clientset
,
informers
,
stopCh
)
setupScheduler
(
t
,
clientset
,
informers
,
stopCh
)
informers
.
Start
(
stopCh
)
go
dc
.
Run
(
5
,
stopCh
)
ds
:=
newDaemonSet
(
"foo"
,
ns
.
Name
)
ds
:=
newDaemonSet
(
"foo"
,
ns
.
Name
)
ds
.
Spec
.
UpdateStrategy
=
*
strategy
ds
.
Spec
.
UpdateStrategy
=
*
strategy
...
...
test/integration/scheduler/scheduler_test.go
View file @
e0a7d966
...
@@ -539,10 +539,24 @@ func TestMultiScheduler(t *testing.T) {
...
@@ -539,10 +539,24 @@ func TestMultiScheduler(t *testing.T) {
eventBroadcaster2
:=
record
.
NewBroadcaster
()
eventBroadcaster2
:=
record
.
NewBroadcaster
()
schedulerConfig2
.
Recorder
=
eventBroadcaster2
.
NewRecorder
(
legacyscheme
.
Scheme
,
v1
.
EventSource
{
Component
:
fooScheduler
})
schedulerConfig2
.
Recorder
=
eventBroadcaster2
.
NewRecorder
(
legacyscheme
.
Scheme
,
v1
.
EventSource
{
Component
:
fooScheduler
})
eventBroadcaster2
.
StartRecordingToSink
(
&
clientv1core
.
EventSinkImpl
{
Interface
:
clientSet2
.
CoreV1
()
.
Events
(
""
)})
eventBroadcaster2
.
StartRecordingToSink
(
&
clientv1core
.
EventSinkImpl
{
Interface
:
clientSet2
.
CoreV1
()
.
Events
(
""
)})
go
podInformer2
.
Informer
()
.
Run
(
stopCh
)
informerFactory2
.
Start
(
stopCh
)
sched2
:=
scheduler
.
NewFromConfig
(
schedulerConfig2
)
sched2
:=
scheduler
.
NewFromConfig
(
schedulerConfig2
)
scheduler
.
AddAllEventHandlers
(
sched2
,
fooScheduler
,
context
.
informerFactory
.
Core
()
.
V1
()
.
Nodes
(),
podInformer2
,
context
.
informerFactory
.
Core
()
.
V1
()
.
PersistentVolumes
(),
context
.
informerFactory
.
Core
()
.
V1
()
.
PersistentVolumeClaims
(),
context
.
informerFactory
.
Core
()
.
V1
()
.
ReplicationControllers
(),
context
.
informerFactory
.
Apps
()
.
V1
()
.
ReplicaSets
(),
context
.
informerFactory
.
Apps
()
.
V1
()
.
StatefulSets
(),
context
.
informerFactory
.
Core
()
.
V1
()
.
Services
(),
context
.
informerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
(),
context
.
informerFactory
.
Storage
()
.
V1
()
.
StorageClasses
(),
)
go
podInformer2
.
Informer
()
.
Run
(
stopCh
)
informerFactory2
.
Start
(
stopCh
)
sched2
.
Run
()
sched2
.
Run
()
// 6. **check point-2**:
// 6. **check point-2**:
...
...
test/integration/scheduler/util.go
View file @
e0a7d966
...
@@ -189,6 +189,22 @@ func initTestSchedulerWithOptions(
...
@@ -189,6 +189,22 @@ func initTestSchedulerWithOptions(
// set DisablePreemption option
// set DisablePreemption option
context
.
schedulerConfig
.
DisablePreemption
=
disablePreemption
context
.
schedulerConfig
.
DisablePreemption
=
disablePreemption
context
.
scheduler
=
scheduler
.
NewFromConfig
(
context
.
schedulerConfig
)
scheduler
.
AddAllEventHandlers
(
context
.
scheduler
,
v1
.
DefaultSchedulerName
,
context
.
informerFactory
.
Core
()
.
V1
()
.
Nodes
(),
podInformer
,
context
.
informerFactory
.
Core
()
.
V1
()
.
PersistentVolumes
(),
context
.
informerFactory
.
Core
()
.
V1
()
.
PersistentVolumeClaims
(),
context
.
informerFactory
.
Core
()
.
V1
()
.
ReplicationControllers
(),
context
.
informerFactory
.
Apps
()
.
V1
()
.
ReplicaSets
(),
context
.
informerFactory
.
Apps
()
.
V1
()
.
StatefulSets
(),
context
.
informerFactory
.
Core
()
.
V1
()
.
Services
(),
context
.
informerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
(),
context
.
informerFactory
.
Storage
()
.
V1
()
.
StorageClasses
(),
)
// set setPodInformer if provided.
// set setPodInformer if provided.
if
setPodInformer
{
if
setPodInformer
{
go
podInformer
.
Informer
()
.
Run
(
context
.
schedulerConfig
.
StopEverything
)
go
podInformer
.
Informer
()
.
Run
(
context
.
schedulerConfig
.
StopEverything
)
...
@@ -212,7 +228,6 @@ func initTestSchedulerWithOptions(
...
@@ -212,7 +228,6 @@ func initTestSchedulerWithOptions(
context
.
informerFactory
.
Start
(
context
.
schedulerConfig
.
StopEverything
)
context
.
informerFactory
.
Start
(
context
.
schedulerConfig
.
StopEverything
)
context
.
informerFactory
.
WaitForCacheSync
(
context
.
schedulerConfig
.
StopEverything
)
context
.
informerFactory
.
WaitForCacheSync
(
context
.
schedulerConfig
.
StopEverything
)
context
.
scheduler
=
scheduler
.
NewFromConfig
(
context
.
schedulerConfig
)
context
.
scheduler
.
Run
()
context
.
scheduler
.
Run
()
return
context
return
context
}
}
...
...
test/integration/util/util.go
View file @
e0a7d966
...
@@ -74,6 +74,20 @@ func StartScheduler(clientSet clientset.Interface) (factory.Configurator, Shutdo
...
@@ -74,6 +74,20 @@ func StartScheduler(clientSet clientset.Interface) (factory.Configurator, Shutdo
config
.
Recorder
=
evtBroadcaster
.
NewRecorder
(
legacyscheme
.
Scheme
,
v1
.
EventSource
{
Component
:
"scheduler"
})
config
.
Recorder
=
evtBroadcaster
.
NewRecorder
(
legacyscheme
.
Scheme
,
v1
.
EventSource
{
Component
:
"scheduler"
})
sched
:=
scheduler
.
NewFromConfig
(
config
)
sched
:=
scheduler
.
NewFromConfig
(
config
)
scheduler
.
AddAllEventHandlers
(
sched
,
v1
.
DefaultSchedulerName
,
informerFactory
.
Core
()
.
V1
()
.
Nodes
(),
informerFactory
.
Core
()
.
V1
()
.
Pods
(),
informerFactory
.
Core
()
.
V1
()
.
PersistentVolumes
(),
informerFactory
.
Core
()
.
V1
()
.
PersistentVolumeClaims
(),
informerFactory
.
Core
()
.
V1
()
.
ReplicationControllers
(),
informerFactory
.
Apps
()
.
V1
()
.
ReplicaSets
(),
informerFactory
.
Apps
()
.
V1
()
.
StatefulSets
(),
informerFactory
.
Core
()
.
V1
()
.
Services
(),
informerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
(),
informerFactory
.
Storage
()
.
V1
()
.
StorageClasses
(),
)
informerFactory
.
Start
(
stopCh
)
informerFactory
.
Start
(
stopCh
)
sched
.
Run
()
sched
.
Run
()
...
...
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