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