Skip to content

Commit

Permalink
Merge pull request #46681 from zhangxiaoyu-zidif/format-for-cronjob_c…
Browse files Browse the repository at this point in the history
…ontroller

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
```
  • Loading branch information
Kubernetes Submit Queue authored Jun 4, 2017
2 parents fb4f44d + 6918109 commit bd26165
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/controller/cronjob/cronjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ func syncOne(sj *batchv2alpha1.CronJob, js []batchv1.Job, now time.Time, jc jobC
nameForLog := fmt.Sprintf("%s/%s", sj.Namespace, sj.Name)

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

// scale job down to 0
if *job.Spec.Parallelism != 0 {
zero := int32(0)
var err error
job.Spec.Parallelism = &zero
job, err = jc.UpdateJob(job.Namespace, job)
if err != nil {
Expand Down

0 comments on commit bd26165

Please sign in to comment.