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
d0e04427
Commit
d0e04427
authored
Mar 12, 2017
by
Klaus Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed incorrect result of getMinTolerationTime.
parent
3f660a97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
11 deletions
+49
-11
taint_controller.go
pkg/controller/node/taint_controller.go
+5
-11
taint_controller_test.go
pkg/controller/node/taint_controller_test.go
+44
-0
No files found.
pkg/controller/node/taint_controller.go
View file @
d0e04427
...
...
@@ -59,7 +59,7 @@ type podUpdateItem struct {
newTolerations
[]
v1
.
Toleration
}
// NoExecuteTaint
m
anager listens to Taint/Toleration changes and is resposible for removing Pods
// NoExecuteTaint
M
anager listens to Taint/Toleration changes and is resposible for removing Pods
// from Nodes tainted with NoExecute Taints.
type
NoExecuteTaintManager
struct
{
client
clientset
.
Interface
...
...
@@ -126,30 +126,24 @@ func getPodsAssignedToNode(c clientset.Interface, nodeName string) ([]v1.Pod, er
return
pods
.
Items
,
nil
}
//
R
eturns minimal toleration time from the given slice, or -1 if it's infinite.
//
getMinTolerationTime r
eturns minimal toleration time from the given slice, or -1 if it's infinite.
func
getMinTolerationTime
(
tolerations
[]
v1
.
Toleration
)
time
.
Duration
{
minTolerationTime
:=
int64
(
-
1
)
if
len
(
tolerations
)
==
0
{
return
0
}
if
tolerations
[
0
]
.
TolerationSeconds
!=
nil
{
tolerationSeconds
:=
*
(
tolerations
[
0
]
.
TolerationSeconds
)
if
tolerationSeconds
<=
0
{
return
0
}
else
{
minTolerationTime
=
tolerationSeconds
}
}
for
i
:=
range
tolerations
{
if
tolerations
[
i
]
.
TolerationSeconds
!=
nil
{
tolerationSeconds
:=
*
(
tolerations
[
i
]
.
TolerationSeconds
)
if
tolerationSeconds
<=
0
{
return
0
}
else
if
tolerationSeconds
<
minTolerationTime
{
}
else
if
tolerationSeconds
<
minTolerationTime
||
minTolerationTime
==
-
1
{
minTolerationTime
=
tolerationSeconds
}
}
}
return
time
.
Duration
(
minTolerationTime
)
*
time
.
Second
}
...
...
pkg/controller/node/taint_controller_test.go
View file @
d0e04427
...
...
@@ -549,3 +549,47 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
close
(
stopCh
)
}
}
func
TestGetMinTolerationTime
(
t
*
testing
.
T
)
{
one
:=
int64
(
1
)
oneSec
:=
1
*
time
.
Second
tests
:=
[]
struct
{
tolerations
[]
v1
.
Toleration
expected
time
.
Duration
}{
{
tolerations
:
[]
v1
.
Toleration
{},
expected
:
0
,
},
{
tolerations
:
[]
v1
.
Toleration
{
{
TolerationSeconds
:
&
one
,
},
{
TolerationSeconds
:
nil
,
},
},
expected
:
oneSec
,
},
{
tolerations
:
[]
v1
.
Toleration
{
{
TolerationSeconds
:
nil
,
},
{
TolerationSeconds
:
&
one
,
},
},
expected
:
oneSec
,
},
}
for
_
,
test
:=
range
tests
{
got
:=
getMinTolerationTime
(
test
.
tolerations
)
if
got
!=
test
.
expected
{
t
.
Errorf
(
"Incorrect min toleration time: got %v, expected %v"
,
got
,
test
.
expected
)
}
}
}
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