Skip to content

Commit bd26165

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #46681 from zhangxiaoyu-zidif/format-for-cronjob_controller
Automatic merge from submit-queue (batch tested with PRs 46681, 46786, 46264, 46680, 46805) Fix for-loop and err definition **What this PR does / why we need it**: we can use j directly, it's odd to use i then get j through i. we can put err definition into if{} , after all the para. was only used in if{}. **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 NONE ```
2 parents fb4f44d + 6918109 commit bd26165

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Diff for: pkg/controller/cronjob/cronjob_controller.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ func syncOne(sj *batchv2alpha1.CronJob, js []batchv1.Job, now time.Time, jc jobC
205205
nameForLog := fmt.Sprintf("%s/%s", sj.Namespace, sj.Name)
206206

207207
childrenJobs := make(map[types.UID]bool)
208-
for i := range js {
209-
j := js[i]
208+
for _, j := range js {
210209
childrenJobs[j.ObjectMeta.UID] = true
211210
found := inActiveList(*sj, j.ObjectMeta.UID)
212211
if !found && !IsJobFinished(&j) {
@@ -366,11 +365,11 @@ func deleteJob(sj *batchv2alpha1.CronJob, job *batchv1.Job, jc jobControlInterfa
366365
// TODO: this should be replaced with server side job deletion
367366
// currencontinuetly this mimics JobReaper from pkg/kubectl/stop.go
368367
nameForLog := fmt.Sprintf("%s/%s", sj.Namespace, sj.Name)
369-
var err error
370368

371369
// scale job down to 0
372370
if *job.Spec.Parallelism != 0 {
373371
zero := int32(0)
372+
var err error
374373
job.Spec.Parallelism = &zero
375374
job, err = jc.UpdateJob(job.Namespace, job)
376375
if err != nil {

0 commit comments

Comments
 (0)