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
10ecbb8a
Commit
10ecbb8a
authored
Apr 22, 2015
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pod filtering in replication controller
parent
8b04e7f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
replication_controller.go
pkg/controller/replication_controller.go
+4
-4
replication_controller_test.go
pkg/controller/replication_controller_test.go
+19
-0
No files found.
pkg/controller/replication_controller.go
View file @
10ecbb8a
...
@@ -190,10 +190,10 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
...
@@ -190,10 +190,10 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
// filterActivePods returns pods that have not terminated.
// filterActivePods returns pods that have not terminated.
func
filterActivePods
(
pods
[]
api
.
Pod
)
[]
*
api
.
Pod
{
func
filterActivePods
(
pods
[]
api
.
Pod
)
[]
*
api
.
Pod
{
var
result
[]
*
api
.
Pod
var
result
[]
*
api
.
Pod
for
_
,
value
:=
range
pods
{
for
i
:=
range
pods
{
if
api
.
PodSucceeded
!=
value
.
Status
.
Phase
&&
if
api
.
PodSucceeded
!=
pods
[
i
]
.
Status
.
Phase
&&
api
.
PodFailed
!=
value
.
Status
.
Phase
{
api
.
PodFailed
!=
pods
[
i
]
.
Status
.
Phase
{
result
=
append
(
result
,
&
value
)
result
=
append
(
result
,
&
pods
[
i
]
)
}
}
}
}
return
result
return
result
...
...
pkg/controller/replication_controller_test.go
View file @
10ecbb8a
...
@@ -379,6 +379,25 @@ func TestWatchControllers(t *testing.T) {
...
@@ -379,6 +379,25 @@ func TestWatchControllers(t *testing.T) {
}
}
}
}
func
TestActivePodFiltering
(
t
*
testing
.
T
)
{
podList
:=
newPodList
(
5
)
podList
.
Items
[
0
]
.
Status
.
Phase
=
api
.
PodSucceeded
podList
.
Items
[
1
]
.
Status
.
Phase
=
api
.
PodFailed
expectedNames
:=
util
.
NewStringSet
()
for
_
,
pod
:=
range
podList
.
Items
[
2
:
]
{
expectedNames
.
Insert
(
pod
.
Name
)
}
got
:=
filterActivePods
(
podList
.
Items
)
gotNames
:=
util
.
NewStringSet
()
for
_
,
pod
:=
range
got
{
gotNames
.
Insert
(
pod
.
Name
)
}
if
expectedNames
.
Difference
(
gotNames
)
.
Len
()
!=
0
||
gotNames
.
Difference
(
expectedNames
)
.
Len
()
!=
0
{
t
.
Errorf
(
"expected %v, got %v"
,
expectedNames
.
List
(),
gotNames
.
List
())
}
}
func
TestSortingActivePods
(
t
*
testing
.
T
)
{
func
TestSortingActivePods
(
t
*
testing
.
T
)
{
numPods
:=
5
numPods
:=
5
podList
:=
newPodList
(
numPods
)
podList
:=
newPodList
(
numPods
)
...
...
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