Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions pkg/controller/cronhorizontalpodautoscaler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,11 @@ func (r *ReconcileCronHorizontalPodAutoscaler) Reconcile(context context.Context
for _, cJob := range conditions {
skip := false
for _, job := range instance.Spec.Jobs {
if cJob.Name == job.Name {
// schedule has changed or RunOnce changed
if cJob.Schedule != job.Schedule || cJob.RunOnce != job.RunOnce || cJob.TargetSize != job.TargetSize {
// jobId exists and remove the job from cronManager
if cJob.JobId != "" {
err := r.CronManager.delete(cJob.JobId)
if err != nil {
log.Errorf("Failed to delete expired job %s in cronHPA %s namespace %s,because of %v", cJob.Name, instance.Name, instance.Namespace, err)
}
}
continue
}
// if nothing changed
if cJob.Name == job.Name && cJob.Schedule == job.Schedule && cJob.RunOnce == job.RunOnce && cJob.TargetSize == job.TargetSize {
skip = true
break
}
}

// need remove this condition because this is not job spec
if !skip {
if cJob.JobId != "" {
Expand All @@ -133,10 +121,7 @@ func (r *ReconcileCronHorizontalPodAutoscaler) Reconcile(context context.Context
log.Errorf("Failed to delete expired job %s in cronHPA %s namespace %s, because of %v", cJob.Name, instance.Name, instance.Namespace, err)
}
}
}

// if job nothing changed then append to left conditions
if skip {
} else {
leftConditions = append(leftConditions, cJob)
}
}
Expand Down