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
b4d3d24e
Commit
b4d3d24e
authored
Feb 07, 2017
by
Avesh Agarwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests.
parent
9b640838
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
96 additions
and
314 deletions
+96
-314
validation_test.go
pkg/api/validation/validation_test.go
+0
-0
daemoncontroller_test.go
pkg/controller/daemon/daemoncontroller_test.go
+11
-21
taint_controller_test.go
pkg/controller/node/taint_controller_test.go
+8
-45
taint_test.go
pkg/kubectl/cmd/taint_test.go
+14
-30
describe_test.go
pkg/kubectl/describe_test.go
+5
-7
admission_test.go
.../pkg/admission/defaulttolerationseconds/admission_test.go
+0
-0
predicates_test.go
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
+40
-150
metadata_test.go
plugin/pkg/scheduler/algorithm/priorities/metadata_test.go
+3
-13
taint_toleration_test.go
...g/scheduler/algorithm/priorities/taint_toleration_test.go
+5
-10
util.go
test/e2e/framework/util.go
+2
-4
scheduler_predicates.go
test/e2e/scheduler_predicates.go
+4
-11
taints_test.go
test/e2e/taints_test.go
+4
-23
No files found.
pkg/api/validation/validation_test.go
View file @
b4d3d24e
This diff is collapsed.
Click to expand it.
pkg/controller/daemon/daemoncontroller_test.go
View file @
b4d3d24e
...
...
@@ -45,13 +45,9 @@ var (
alwaysReady
=
func
()
bool
{
return
true
}
)
const
(
noSchedule
=
`
[{
"key": "dedicated",
"value": "user1",
"effect": "NoSchedule"
}]`
var
(
noScheduleTolerations
=
[]
v1
.
Toleration
{{
Key
:
"dedicated"
,
Value
:
"user1"
,
Effect
:
"NoSchedule"
}}
noScheduleTaints
=
[]
v1
.
Taint
{{
Key
:
"dedicated"
,
Value
:
"user1"
,
Effect
:
"NoSchedule"
}}
)
func
getKey
(
ds
*
extensions
.
DaemonSet
,
t
*
testing
.
T
)
string
{
...
...
@@ -722,7 +718,7 @@ func TestTaintedNodeDaemonDoesNotLaunchUntoleratePod(t *testing.T) {
manager
,
podControl
,
_
:=
newTestController
()
node
:=
newNode
(
"tainted"
,
nil
)
setNodeTaint
(
node
,
noSchedule
)
setNodeTaint
(
node
,
noSchedule
Taints
)
manager
.
nodeStore
.
Add
(
node
)
ds
:=
newDaemonSet
(
"untolerate"
)
...
...
@@ -736,11 +732,11 @@ func TestTaintedNodeDaemonLaunchesToleratePod(t *testing.T) {
manager
,
podControl
,
_
:=
newTestController
()
node
:=
newNode
(
"tainted"
,
nil
)
setNodeTaint
(
node
,
noSchedule
)
setNodeTaint
(
node
,
noSchedule
Taints
)
manager
.
nodeStore
.
Add
(
node
)
ds
:=
newDaemonSet
(
"tolerate"
)
setDaemonSetToleration
(
ds
,
noSchedule
)
setDaemonSetToleration
(
ds
,
noSchedule
Tolerations
)
manager
.
dsStore
.
Add
(
ds
)
syncAndValidateDaemonSets
(
t
,
manager
,
ds
,
podControl
,
1
,
0
)
...
...
@@ -754,24 +750,18 @@ func TestNodeDaemonLaunchesToleratePod(t *testing.T) {
manager
.
nodeStore
.
Add
(
node
)
ds
:=
newDaemonSet
(
"tolerate"
)
setDaemonSetToleration
(
ds
,
noSchedule
)
setDaemonSetToleration
(
ds
,
noSchedule
Tolerations
)
manager
.
dsStore
.
Add
(
ds
)
syncAndValidateDaemonSets
(
t
,
manager
,
ds
,
podControl
,
1
,
0
)
}
func
setNodeTaint
(
node
*
v1
.
Node
,
taint
string
)
{
if
node
.
ObjectMeta
.
Annotations
==
nil
{
node
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
node
.
ObjectMeta
.
Annotations
[
v1
.
TaintsAnnotationKey
]
=
taint
func
setNodeTaint
(
node
*
v1
.
Node
,
taints
[]
v1
.
Taint
)
{
node
.
Spec
.
Taints
=
taints
}
func
setDaemonSetToleration
(
ds
*
extensions
.
DaemonSet
,
toleration
string
)
{
if
ds
.
Spec
.
Template
.
ObjectMeta
.
Annotations
==
nil
{
ds
.
Spec
.
Template
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
ds
.
Spec
.
Template
.
ObjectMeta
.
Annotations
[
v1
.
TolerationsAnnotationKey
]
=
toleration
func
setDaemonSetToleration
(
ds
*
extensions
.
DaemonSet
,
tolerations
[]
v1
.
Toleration
)
{
ds
.
Spec
.
Template
.
Spec
.
Tolerations
=
tolerations
}
func
TestNodeShouldRunDaemonPod
(
t
*
testing
.
T
)
{
...
...
pkg/controller/node/taint_controller_test.go
View file @
b4d3d24e
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
node
import
(
"encoding/json"
"fmt"
"sort"
"testing"
...
...
@@ -47,24 +46,10 @@ func addToleration(pod *v1.Pod, index int, duration int64) *v1.Pod {
pod
.
Annotations
=
map
[
string
]
string
{}
}
if
duration
<
0
{
pod
.
Annotations
[
"scheduler.alpha.kubernetes.io/tolerations"
]
=
`
[
{
"key": "testTaint`
+
fmt
.
Sprintf
(
"%v"
,
index
)
+
`",
"value": "test`
+
fmt
.
Sprintf
(
"%v"
,
index
)
+
`",
"effect": "`
+
string
(
v1
.
TaintEffectNoExecute
)
+
`"
}
]`
pod
.
Spec
.
Tolerations
=
[]
v1
.
Toleration
{{
Key
:
"testTaint"
+
fmt
.
Sprintf
(
"%v"
,
index
),
Value
:
"test"
+
fmt
.
Sprintf
(
"%v"
,
index
),
Effect
:
v1
.
TaintEffectNoExecute
}}
}
else
{
pod
.
Annotations
[
"scheduler.alpha.kubernetes.io/tolerations"
]
=
`
[
{
"key": "testTaint`
+
fmt
.
Sprintf
(
"%v"
,
index
)
+
`",
"value": "test`
+
fmt
.
Sprintf
(
"%v"
,
index
)
+
`",
"effect": "`
+
string
(
v1
.
TaintEffectNoExecute
)
+
`",
"tolerationSeconds": `
+
fmt
.
Sprintf
(
"%v"
,
duration
)
+
`
}
]`
pod
.
Spec
.
Tolerations
=
[]
v1
.
Toleration
{{
Key
:
"testTaint"
+
fmt
.
Sprintf
(
"%v"
,
index
),
Value
:
"test"
+
fmt
.
Sprintf
(
"%v"
,
index
),
Effect
:
v1
.
TaintEffectNoExecute
,
TolerationSeconds
:
&
duration
}}
}
return
pod
}
...
...
@@ -74,15 +59,7 @@ func addTaintsToNode(node *v1.Node, key, value string, indices []int) *v1.Node {
for
_
,
index
:=
range
indices
{
taints
=
append
(
taints
,
createNoExecuteTaint
(
index
))
}
taintsData
,
err
:=
json
.
Marshal
(
taints
)
if
err
!=
nil
{
panic
(
err
)
}
if
node
.
Annotations
==
nil
{
node
.
Annotations
=
make
(
map
[
string
]
string
)
}
node
.
Annotations
[
v1
.
TaintsAnnotationKey
]
=
string
(
taintsData
)
node
.
Spec
.
Taints
=
taints
return
node
}
...
...
@@ -509,27 +486,13 @@ func TestUpdateNode(t *testing.T) {
ObjectMeta
:
metav1
.
ObjectMeta
{
Namespace
:
"default"
,
Name
:
"pod1"
,
Annotations
:
map
[
string
]
string
{
"scheduler.alpha.kubernetes.io/tolerations"
:
`
[
{
"key": "testTaint1",
"value": "test1",
"effect": "`
+
string
(
v1
.
TaintEffectNoExecute
)
+
`",
"tolerationSeconds": `
+
fmt
.
Sprintf
(
"%v"
,
1
)
+
`
},
{
"key": "testTaint2",
"value": "test2",
"effect": "`
+
string
(
v1
.
TaintEffectNoExecute
)
+
`",
"tolerationSeconds": `
+
fmt
.
Sprintf
(
"%v"
,
100
)
+
`
}
]
`
,
},
},
Spec
:
v1
.
PodSpec
{
NodeName
:
"node1"
,
Tolerations
:
[]
v1
.
Toleration
{
{
Key
:
"testTaint1"
,
Value
:
"test1"
,
Effect
:
v1
.
TaintEffectNoExecute
,
TolerationSeconds
:
&
[]
int64
{
1
}[
0
]},
{
Key
:
"testTaint2"
,
Value
:
"test2"
,
Effect
:
v1
.
TaintEffectNoExecute
,
TolerationSeconds
:
&
[]
int64
{
100
}[
0
]},
},
},
Status
:
v1
.
PodStatus
{
Conditions
:
[]
v1
.
PodCondition
{
...
...
pkg/kubectl/cmd/taint_test.go
View file @
b4d3d24e
...
...
@@ -18,7 +18,6 @@ package cmd
import
(
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"reflect"
...
...
@@ -35,46 +34,31 @@ import (
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
)
func
generateNodeAndTaintedNode
(
oldTaints
[]
v1
.
Taint
,
newTaints
[]
v1
.
Taint
)
(
*
api
.
Node
,
*
api
.
Node
)
{
var
taintedNode
*
api
.
Node
func
generateNodeAndTaintedNode
(
oldTaints
[]
v1
.
Taint
,
newTaints
[]
v1
.
Taint
)
(
*
v1
.
Node
,
*
v1
.
Node
)
{
var
taintedNode
*
v1
.
Node
oldTaintsData
,
_
:=
json
.
Marshal
(
oldTaints
)
// Create a node.
node
:=
&
api
.
Node
{
node
:=
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"node-name"
,
CreationTimestamp
:
metav1
.
Time
{
Time
:
time
.
Now
()},
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
string
(
oldTaintsData
),
},
},
Spec
:
api
.
NodeSpec
{
Spec
:
v1
.
NodeSpec
{
ExternalID
:
"node-name"
,
Taints
:
oldTaints
,
},
Status
:
api
.
NodeStatus
{},
Status
:
v1
.
NodeStatus
{},
}
clone
,
_
:=
api
.
Scheme
.
DeepCopy
(
node
)
newTaintsData
,
_
:=
json
.
Marshal
(
newTaints
)
// A copy of the same node, but tainted.
taintedNode
=
clone
.
(
*
api
.
Node
)
taintedNode
.
Annotations
=
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
string
(
newTaintsData
),
}
taintedNode
=
clone
.
(
*
v1
.
Node
)
taintedNode
.
Spec
.
Taints
=
newTaints
return
node
,
taintedNode
}
func
AnnotationsHaveEqualTaints
(
annotationA
map
[
string
]
string
,
annotationB
map
[
string
]
string
)
bool
{
taintsA
,
err
:=
v1
.
GetTaintsFromNodeAnnotations
(
annotationA
)
if
err
!=
nil
{
return
false
}
taintsB
,
err
:=
v1
.
GetTaintsFromNodeAnnotations
(
annotationB
)
if
err
!=
nil
{
return
false
}
func
equalTaints
(
taintsA
,
taintsB
[]
v1
.
Taint
)
bool
{
if
len
(
taintsA
)
!=
len
(
taintsB
)
{
return
false
}
...
...
@@ -254,7 +238,7 @@ func TestTaint(t *testing.T) {
for
_
,
test
:=
range
tests
{
oldNode
,
expectNewNode
:=
generateNodeAndTaintedNode
(
test
.
oldTaints
,
test
.
newTaints
)
new_node
:=
&
api
.
Node
{}
new_node
:=
&
v1
.
Node
{}
tainted
:=
false
f
,
tf
,
codec
,
ns
:=
cmdtesting
.
NewAPIFactory
()
...
...
@@ -288,8 +272,8 @@ func TestTaint(t *testing.T) {
if
err
:=
runtime
.
DecodeInto
(
codec
,
appliedPatch
,
new_node
);
err
!=
nil
{
t
.
Fatalf
(
"%s: unexpected error: %v"
,
test
.
description
,
err
)
}
if
!
AnnotationsHaveEqualTaints
(
expectNewNode
.
Annotations
,
new_node
.
Annotation
s
)
{
t
.
Fatalf
(
"%s: expected:
\n
%v
\n
saw:
\n
%v
\n
"
,
test
.
description
,
expectNewNode
.
Annotations
,
new_node
.
Annotation
s
)
if
!
equalTaints
(
expectNewNode
.
Spec
.
Taints
,
new_node
.
Spec
.
Taint
s
)
{
t
.
Fatalf
(
"%s: expected:
\n
%v
\n
saw:
\n
%v
\n
"
,
test
.
description
,
expectNewNode
.
Spec
.
Taints
,
new_node
.
Spec
.
Taint
s
)
}
return
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
new_node
)},
nil
case
m
.
isFor
(
"PUT"
,
"/nodes/node-name"
)
:
...
...
@@ -302,8 +286,8 @@ func TestTaint(t *testing.T) {
if
err
:=
runtime
.
DecodeInto
(
codec
,
data
,
new_node
);
err
!=
nil
{
t
.
Fatalf
(
"%s: unexpected error: %v"
,
test
.
description
,
err
)
}
if
!
AnnotationsHaveEqualTaints
(
expectNewNode
.
Annotations
,
new_node
.
Annotation
s
)
{
t
.
Fatalf
(
"%s: expected:
\n
%v
\n
saw:
\n
%v
\n
"
,
test
.
description
,
expectNewNode
.
Annotations
,
new_node
.
Annotation
s
)
if
!
equalTaints
(
expectNewNode
.
Spec
.
Taints
,
new_node
.
Spec
.
Taint
s
)
{
t
.
Fatalf
(
"%s: expected:
\n
%v
\n
saw:
\n
%v
\n
"
,
test
.
description
,
expectNewNode
.
Spec
.
Taints
,
new_node
.
Spec
.
Taint
s
)
}
return
&
http
.
Response
{
StatusCode
:
200
,
Header
:
defaultHeader
(),
Body
:
objBody
(
codec
,
new_node
)},
nil
default
:
...
...
pkg/kubectl/describe_test.go
View file @
b4d3d24e
...
...
@@ -18,7 +18,6 @@ package kubectl
import
(
"bytes"
"encoding/json"
"fmt"
"reflect"
"strings"
...
...
@@ -70,16 +69,15 @@ func TestDescribePod(t *testing.T) {
}
func
TestDescribePodTolerations
(
t
*
testing
.
T
)
{
podTolerations
:=
[]
v1
.
Toleration
{{
Key
:
"key1"
,
Value
:
"value1"
},
{
Key
:
"key2"
,
Value
:
"value2"
}}
pt
,
_
:=
json
.
Marshal
(
podTolerations
)
fake
:=
fake
.
NewSimpleClientset
(
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"bar"
,
Namespace
:
"foo"
,
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
string
(
pt
),
},
Spec
:
api
.
PodSpec
{
Tolerations
:
[]
api
.
Toleration
{
{
Key
:
"key1"
,
Value
:
"value1"
},
{
Key
:
"key2"
,
Value
:
"value2"
},
},
},
})
...
...
plugin/pkg/admission/defaulttolerationseconds/admission_test.go
View file @
b4d3d24e
This diff is collapsed.
Click to expand it.
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
View file @
b4d3d24e
...
...
@@ -2956,15 +2956,8 @@ func TestPodToleratesTaints(t *testing.T) {
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "dedicated",
"value": "user1",
"effect": "NoSchedule"
}]`
,
},
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{{
Key
:
"dedicated"
,
Value
:
"user1"
,
Effect
:
"NoSchedule"
}},
},
},
fits
:
false
,
...
...
@@ -2974,29 +2967,15 @@ func TestPodToleratesTaints(t *testing.T) {
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod1"
,
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
`
[{
"key": "dedicated",
"value": "user1",
"effect": "NoSchedule"
}]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Image
:
"pod1:V1"
}},
Containers
:
[]
v1
.
Container
{{
Image
:
"pod1:V1"
}},
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
"dedicated"
,
Value
:
"user1"
,
Effect
:
"NoSchedule"
}},
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "dedicated",
"value": "user1",
"effect": "NoSchedule"
}]`
,
},
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{{
Key
:
"dedicated"
,
Value
:
"user1"
,
Effect
:
"NoSchedule"
}},
},
},
fits
:
true
,
...
...
@@ -3006,30 +2985,15 @@ func TestPodToleratesTaints(t *testing.T) {
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod2"
,
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
`
[{
"key": "dedicated",
"operator": "Equal",
"value": "user2",
"effect": "NoSchedule"
}]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
"dedicated"
,
Operator
:
"Equal"
,
Value
:
"user2"
,
Effect
:
"NoSchedule"
}},
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "dedicated",
"value": "user1",
"effect": "NoSchedule"
}]`
,
},
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{{
Key
:
"dedicated"
,
Value
:
"user1"
,
Effect
:
"NoSchedule"
}},
},
},
fits
:
false
,
...
...
@@ -3039,29 +3003,15 @@ func TestPodToleratesTaints(t *testing.T) {
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod2"
,
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
`
[{
"key": "foo",
"operator": "Exists",
"effect": "NoSchedule"
}]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
"foo"
,
Operator
:
"Exists"
,
Effect
:
"NoSchedule"
}},
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "foo",
"value": "bar",
"effect": "NoSchedule"
}]`
,
},
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{{
Key
:
"foo"
,
Value
:
"bar"
,
Effect
:
"NoSchedule"
}},
},
},
fits
:
true
,
...
...
@@ -3071,37 +3021,20 @@ func TestPodToleratesTaints(t *testing.T) {
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod2"
,
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
`
[{
"key": "dedicated",
"operator": "Equal",
"value": "user2",
"effect": "NoSchedule"
}, {
"key": "foo",
"operator": "Exists",
"effect": "NoSchedule"
}]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Tolerations
:
[]
v1
.
Toleration
{
{
Key
:
"dedicated"
,
Operator
:
"Equal"
,
Value
:
"user2"
,
Effect
:
"NoSchedule"
},
{
Key
:
"foo"
,
Operator
:
"Exists"
,
Effect
:
"NoSchedule"
},
},
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "dedicated",
"value": "user2",
"effect": "NoSchedule"
}, {
"key": "foo",
"value": "bar",
"effect": "NoSchedule"
}]`
,
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{
{
Key
:
"dedicated"
,
Value
:
"user2"
,
Effect
:
"NoSchedule"
},
{
Key
:
"foo"
,
Value
:
"bar"
,
Effect
:
"NoSchedule"
},
},
},
},
...
...
@@ -3112,29 +3045,16 @@ func TestPodToleratesTaints(t *testing.T) {
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod2"
,
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
`
[{
"key": "foo",
"operator": "Equal",
"value": "bar",
"effect": "PreferNoSchedule"
}]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
"foo"
,
Operator
:
"Equal"
,
Value
:
"bar"
,
Effect
:
"PreferNoSchedule"
}},
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "foo",
"value": "bar",
"effect": "NoSchedule"
}]`
,
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{
{
Key
:
"foo"
,
Value
:
"bar"
,
Effect
:
"NoSchedule"
},
},
},
},
...
...
@@ -3146,28 +3066,16 @@ func TestPodToleratesTaints(t *testing.T) {
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod2"
,
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
`
[{
"key": "foo",
"operator": "Equal",
"value": "bar"
}]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
"foo"
,
Operator
:
"Equal"
,
Value
:
"bar"
}},
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "foo",
"value": "bar",
"effect": "NoSchedule"
}]`
,
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{
{
Key
:
"foo"
,
Value
:
"bar"
,
Effect
:
"NoSchedule"
},
},
},
},
...
...
@@ -3179,29 +3087,16 @@ func TestPodToleratesTaints(t *testing.T) {
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pod2"
,
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
`
[{
"key": "dedicated",
"operator": "Equal",
"value": "user2",
"effect": "NoSchedule"
}]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Containers
:
[]
v1
.
Container
{{
Image
:
"pod2:V1"
}},
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
"dedicated"
,
Operator
:
"Equal"
,
Value
:
"user2"
,
Effect
:
"NoSchedule"
}},
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "dedicated",
"value": "user1",
"effect": "PreferNoSchedule"
}]`
,
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{
{
Key
:
"dedicated"
,
Value
:
"user1"
,
Effect
:
"PreferNoSchedule"
},
},
},
},
...
...
@@ -3219,14 +3114,9 @@ func TestPodToleratesTaints(t *testing.T) {
},
},
node
:
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
`
[{
"key": "dedicated",
"value": "user1",
"effect": "PreferNoSchedule"
}]`
,
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{
{
Key
:
"dedicated"
,
Value
:
"user1"
,
Effect
:
"PreferNoSchedule"
},
},
},
},
...
...
plugin/pkg/scheduler/algorithm/priorities/metadata_test.go
View file @
b4d3d24e
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
priorities
import
(
"encoding/json"
"reflect"
"testing"
...
...
@@ -43,7 +42,6 @@ func TestPriorityMetadata(t *testing.T) {
Value
:
"bar"
,
Effect
:
v1
.
TaintEffectPreferNoSchedule
,
}}
tolerationData
,
_
:=
json
.
Marshal
(
tolerations
)
podAffinity
:=
&
v1
.
Affinity
{
PodAffinity
:
&
v1
.
PodAffinity
{
PreferredDuringSchedulingIgnoredDuringExecution
:
[]
v1
.
WeightedPodAffinityTerm
{
...
...
@@ -66,11 +64,6 @@ func TestPriorityMetadata(t *testing.T) {
},
}
podWithTolerationsAndAffinity
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
string
(
tolerationData
),
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
...
...
@@ -79,15 +72,11 @@ func TestPriorityMetadata(t *testing.T) {
ImagePullPolicy
:
"Always"
,
},
},
Affinity
:
podAffinity
,
Affinity
:
podAffinity
,
Tolerations
:
tolerations
,
},
}
podWithTolerationsAndRequests
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
string
(
tolerationData
),
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
...
...
@@ -102,6 +91,7 @@ func TestPriorityMetadata(t *testing.T) {
},
},
},
Tolerations
:
tolerations
,
},
}
tests
:=
[]
struct
{
...
...
plugin/pkg/scheduler/algorithm/priorities/taint_toleration_test.go
View file @
b4d3d24e
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
priorities
import
(
"encoding/json"
"reflect"
"testing"
...
...
@@ -28,24 +27,20 @@ import (
)
func
nodeWithTaints
(
nodeName
string
,
taints
[]
v1
.
Taint
)
*
v1
.
Node
{
taintsData
,
_
:=
json
.
Marshal
(
taints
)
return
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
nodeName
,
Annotations
:
map
[
string
]
string
{
v1
.
TaintsAnnotationKey
:
string
(
taintsData
),
}
,
},
Spec
:
v1
.
NodeSpec
{
Taints
:
taints
,
},
}
}
func
podWithTolerations
(
tolerations
[]
v1
.
Toleration
)
*
v1
.
Pod
{
tolerationData
,
_
:=
json
.
Marshal
(
tolerations
)
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
v1
.
TolerationsAnnotationKey
:
string
(
tolerationData
),
},
Spec
:
v1
.
PodSpec
{
Tolerations
:
tolerations
,
},
}
}
...
...
test/e2e/framework/util.go
View file @
b4d3d24e
...
...
@@ -2517,9 +2517,8 @@ func RemoveLabelOffNode(c clientset.Interface, nodeName string, labelKey string)
func
VerifyThatTaintIsGone
(
c
clientset
.
Interface
,
nodeName
string
,
taint
*
v1
.
Taint
)
{
By
(
"verifying the node doesn't have the taint "
+
taint
.
ToString
())
nodeUpdated
,
err
:=
c
.
Core
()
.
Nodes
()
.
Get
(
nodeName
,
metav1
.
GetOptions
{})
taintsGot
,
err
:=
v1
.
GetTaintsFromNodeAnnotations
(
nodeUpdated
.
Annotations
)
ExpectNoError
(
err
)
if
v1
.
TaintExists
(
taintsGot
,
taint
)
{
if
v1
.
TaintExists
(
nodeUpdated
.
Spec
.
Taints
,
taint
)
{
Failf
(
"Failed removing taint "
+
taint
.
ToString
()
+
" of the node "
+
nodeName
)
}
}
...
...
@@ -2529,8 +2528,7 @@ func ExpectNodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint)
node
,
err
:=
c
.
Core
()
.
Nodes
()
.
Get
(
nodeName
,
metav1
.
GetOptions
{})
ExpectNoError
(
err
)
nodeTaints
,
err
:=
v1
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
ExpectNoError
(
err
)
nodeTaints
:=
node
.
Spec
.
Taints
if
len
(
nodeTaints
)
==
0
||
!
v1
.
TaintExists
(
nodeTaints
,
taint
)
{
Failf
(
"Failed to find taint %s on node %s"
,
taint
.
ToString
(),
nodeName
)
...
...
test/e2e/scheduler_predicates.go
View file @
b4d3d24e
...
...
@@ -46,6 +46,7 @@ type pausePodConfig struct {
Affinity
*
v1
.
Affinity
Annotations
,
Labels
,
NodeSelector
map
[
string
]
string
Resources
*
v1
.
ResourceRequirements
Tolerations
[]
v1
.
Toleration
}
var
_
=
framework
.
KubeDescribe
(
"SchedulerPredicates [Serial]"
,
func
()
{
...
...
@@ -689,17 +690,8 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
By
(
"Trying to relaunch the pod, now with tolerations."
)
tolerationPodName
:=
"with-tolerations"
_
=
createPausePod
(
f
,
pausePodConfig
{
Name
:
tolerationPodName
,
Annotations
:
map
[
string
]
string
{
"scheduler.alpha.kubernetes.io/tolerations"
:
`
[
{
"key": "`
+
testTaint
.
Key
+
`",
"value": "`
+
testTaint
.
Value
+
`",
"effect": "`
+
string
(
testTaint
.
Effect
)
+
`"
}
]`
,
},
Name
:
tolerationPodName
,
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
testTaint
.
Key
,
Value
:
testTaint
.
Value
,
Effect
:
testTaint
.
Effect
}},
NodeSelector
:
map
[
string
]
string
{
labelKey
:
labelValue
},
})
...
...
@@ -772,6 +764,7 @@ func initPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
Image
:
framework
.
GetPauseImageName
(
f
.
ClientSet
),
},
},
Tolerations
:
conf
.
Tolerations
,
},
}
if
conf
.
Resources
!=
nil
{
...
...
test/e2e/taints_test.go
View file @
b4d3d24e
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
e2e
import
(
"fmt"
"time"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -75,16 +74,6 @@ func createPodForTaintsTest(hasToleration bool, tolerationSeconds int, podName,
Labels
:
map
[
string
]
string
{
"name"
:
podName
},
DeletionGracePeriodSeconds
:
&
grace
,
// default - tolerate forever
Annotations
:
map
[
string
]
string
{
"scheduler.alpha.kubernetes.io/tolerations"
:
`
[
{
"key": "kubernetes.io/e2e-evict-taint-key",
"value": "evictTaintVal",
"effect": "`
+
string
(
v1
.
TaintEffectNoExecute
)
+
`"
}
]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
...
...
@@ -93,27 +82,17 @@ func createPodForTaintsTest(hasToleration bool, tolerationSeconds int, podName,
Image
:
"kubernetes/pause"
,
},
},
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
"kubernetes.io/e2e-evict-taint-key"
,
Value
:
"evictTaintVal"
,
Effect
:
v1
.
TaintEffectNoExecute
}},
},
}
}
else
{
ts
:=
int64
(
tolerationSeconds
)
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
podName
,
Namespace
:
ns
,
Labels
:
map
[
string
]
string
{
"name"
:
podName
},
DeletionGracePeriodSeconds
:
&
grace
,
// default - tolerate forever
Annotations
:
map
[
string
]
string
{
"scheduler.alpha.kubernetes.io/tolerations"
:
`
[
{
"key": "kubernetes.io/e2e-evict-taint-key",
"value": "evictTaintVal",
"effect": "`
+
string
(
v1
.
TaintEffectNoExecute
)
+
`",
"tolerationSeconds": `
+
fmt
.
Sprintf
(
"%v"
,
tolerationSeconds
)
+
`
}
]`
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
...
...
@@ -122,6 +101,8 @@ func createPodForTaintsTest(hasToleration bool, tolerationSeconds int, podName,
Image
:
"kubernetes/pause"
,
},
},
// default - tolerate forever
Tolerations
:
[]
v1
.
Toleration
{{
Key
:
"kubernetes.io/e2e-evict-taint-key"
,
Value
:
"evictTaintVal"
,
Effect
:
v1
.
TaintEffectNoExecute
,
TolerationSeconds
:
&
ts
}},
},
}
}
...
...
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