mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #43384 from junxu/remove-unused-argument-in-cronjobcontoller
Automatic merge from submit-queue (batch tested with PRs 43378, 43216, 43384, 43083, 43428) Remove unused argument of 'groupJobsByParent' in cronjob controller **What this PR does / why we need it**: **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note ```
This commit is contained in:
commit
2209503a0f
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user