From e626e45b4dd722848eb42a3de2a904b89ba18454 Mon Sep 17 00:00:00 2001 From: xujun Date: Mon, 20 Mar 2017 12:43:10 -0400 Subject: [PATCH] Remove unused argument of 'groupJobsByParent' function in cronjob controller. --- pkg/controller/cronjob/cronjob_controller.go | 2 +- pkg/controller/cronjob/utils.go | 2 +- pkg/controller/cronjob/utils_test.go | 31 ++++---------------- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/pkg/controller/cronjob/cronjob_controller.go b/pkg/controller/cronjob/cronjob_controller.go index ba61dfb9c28..6613814d55d 100644 --- a/pkg/controller/cronjob/cronjob_controller.go +++ b/pkg/controller/cronjob/cronjob_controller.go @@ -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 { diff --git a/pkg/controller/cronjob/utils.go b/pkg/controller/cronjob/utils.go index d8e3b724948..7762b265877 100644 --- a/pkg/controller/cronjob/utils.go +++ b/pkg/controller/cronjob/utils.go @@ -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) diff --git a/pkg/controller/cronjob/utils_test.go b/pkg/controller/cronjob/utils_test.go index 9f74b4de383..66ebffdd04e 100644 --- a/pkg/controller/cronjob/utils_test.go +++ b/pkg/controller/cronjob/utils_test.go @@ -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")