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
e626e45b
Commit
e626e45b
authored
Mar 20, 2017
by
xujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused argument of 'groupJobsByParent' function in cronjob controller.
parent
38055983
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
28 deletions
+7
-28
cronjob_controller.go
pkg/controller/cronjob/cronjob_controller.go
+1
-1
utils.go
pkg/controller/cronjob/utils.go
+1
-1
utils_test.go
pkg/controller/cronjob/utils_test.go
+5
-26
No files found.
pkg/controller/cronjob/cronjob_controller.go
View file @
e626e45b
...
...
@@ -117,7 +117,7 @@ func (jm *CronJobController) syncAll() {
js
:=
jl
.
Items
glog
.
V
(
4
)
.
Infof
(
"Found %d jobs"
,
len
(
js
))
jobsBySj
:=
groupJobsByParent
(
sjs
,
js
)
jobsBySj
:=
groupJobsByParent
(
js
)
glog
.
V
(
4
)
.
Infof
(
"Found %d groups"
,
len
(
jobsBySj
))
for
_
,
sj
:=
range
sjs
{
...
...
pkg/controller/cronjob/utils.go
View file @
e626e45b
...
...
@@ -86,7 +86,7 @@ func getParentUIDFromJob(j batchv1.Job) (types.UID, bool) {
// groupJobsByParent groups jobs into a map keyed by the job parent UID (e.g. scheduledJob).
// It has no receiver, to facilitate testing.
func
groupJobsByParent
(
sjs
[]
batchv2alpha1
.
CronJob
,
js
[]
batchv1
.
Job
)
map
[
types
.
UID
][]
batchv1
.
Job
{
func
groupJobsByParent
(
js
[]
batchv1
.
Job
)
map
[
types
.
UID
][]
batchv1
.
Job
{
jobsBySj
:=
make
(
map
[
types
.
UID
][]
batchv1
.
Job
)
for
_
,
job
:=
range
js
{
parentUID
,
found
:=
getParentUIDFromJob
(
job
)
...
...
pkg/controller/cronjob/utils_test.go
View file @
e626e45b
...
...
@@ -163,35 +163,19 @@ func TestGroupJobsByParent(t *testing.T) {
{
// Case 1: There are no jobs and scheduledJobs
sjs
:=
[]
batchv2alpha1
.
CronJob
{}
js
:=
[]
batchv1
.
Job
{}
jobsBySj
:=
groupJobsByParent
(
sjs
,
js
)
jobsBySj
:=
groupJobsByParent
(
js
)
if
len
(
jobsBySj
)
!=
0
{
t
.
Errorf
(
"Wrong number of items in map"
)
}
}
{
// Case 2: there is one controller with no job.
sjs
:=
[]
batchv2alpha1
.
CronJob
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"e"
,
Namespace
:
"x"
,
UID
:
uid1
}},
}
js
:=
[]
batchv1
.
Job
{}
jobsBySj
:=
groupJobsByParent
(
sjs
,
js
)
if
len
(
jobsBySj
)
!=
0
{
t
.
Errorf
(
"Wrong number of items in map"
)
}
}
{
// Case 3: there is one controller with one job it created.
sjs
:=
[]
batchv2alpha1
.
CronJob
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"e"
,
Namespace
:
"x"
,
UID
:
uid1
}},
}
// Case 2: there is one controller with one job it created.
js
:=
[]
batchv1
.
Job
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"a"
,
Namespace
:
"x"
,
Annotations
:
createdBy1
}},
}
jobsBySj
:=
groupJobsByParent
(
sjs
,
js
)
jobsBySj
:=
groupJobsByParent
(
js
)
if
len
(
jobsBySj
)
!=
1
{
t
.
Errorf
(
"Wrong number of items in map"
)
...
...
@@ -206,7 +190,7 @@ func TestGroupJobsByParent(t *testing.T) {
}
{
// Case
4
: Two namespaces, one has two jobs from one controller, other has 3 jobs from two controllers.
// Case
3
: Two namespaces, one has two jobs from one controller, other has 3 jobs from two controllers.
// There are also two jobs with no created-by annotation.
js
:=
[]
batchv1
.
Job
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"a"
,
Namespace
:
"x"
,
Annotations
:
createdBy1
}},
...
...
@@ -217,13 +201,8 @@ func TestGroupJobsByParent(t *testing.T) {
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"b"
,
Namespace
:
"y"
,
Annotations
:
createdBy3
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"d"
,
Namespace
:
"y"
,
Annotations
:
noCreatedBy
}},
}
sjs
:=
[]
batchv2alpha1
.
CronJob
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"e"
,
Namespace
:
"x"
,
UID
:
uid1
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"f"
,
Namespace
:
"x"
,
UID
:
uid2
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"g"
,
Namespace
:
"y"
,
UID
:
uid3
}},
}
jobsBySj
:=
groupJobsByParent
(
sjs
,
js
)
jobsBySj
:=
groupJobsByParent
(
js
)
if
len
(
jobsBySj
)
!=
3
{
t
.
Errorf
(
"Wrong number of items in map"
)
...
...
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