Skip to content

Commit f53e20f

Browse files
author
hexi.ghx
committed
fix logs & annotations
1 parent 2d85538 commit f53e20f

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

pkg/controller/cronexecutor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ func (ce *CronHPAExecutor) FindJob(job CronJob) (bool, FailedFindJobReason) {
4949
entries := ce.Engine.Entries()
5050
for _, e := range entries {
5151
if e.Job.ID() == job.ID() {
52-
// clean up out of date jobs when it reach maxOutOfDateTimeout
52+
// clean up out of date jobs when it reached maxOutOfDateTimeout
5353
if e.Next.Add(maxOutOfDateTimeout).After(time.Now()) {
5454
return true, ""
5555
}
56-
log.Warningf("The job %s is out of date and need to be clean up.", job.Name())
56+
log.Warningf("The job %s(job id %s) in cronhpa %s namespace %s is out of date.", job.Name(), job.ID(), job.CronHPAMeta().Name, job.CronHPAMeta().Namespace)
5757
return false, JobTimeOut
5858
}
5959
}

pkg/controller/cronhorizontalpodautoscaler_controller.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func (r *ReconcileCronHorizontalPodAutoscaler) Reconcile(request reconcile.Reque
7979
if errors.IsNotFound(err) {
8080
// Object not found, return. Created objects are automatically garbage collected.
8181
// For additional cleanup logic use finalizers.
82+
log.Infof("GC start for: cronHPA %s in %s namespace is not found", request.Name, request.Namespace)
8283
go r.CronManager.GC()
8384
return reconcile.Result{}, nil
8485
}
@@ -118,10 +119,12 @@ func (r *ReconcileCronHorizontalPodAutoscaler) Reconcile(request reconcile.Reque
118119
}
119120
continue
120121
}
122+
// if nothing changed
121123
skip = true
122124
}
123125
}
124126

127+
// need remove this condition because this is not job spec
125128
if !skip {
126129
if cJob.JobId != "" {
127130
err := r.CronManager.delete(cJob.JobId)
@@ -131,7 +134,7 @@ func (r *ReconcileCronHorizontalPodAutoscaler) Reconcile(request reconcile.Reque
131134
}
132135
}
133136

134-
// need remove this condition because this is not job spec
137+
// if job nothing changed then append to left conditions
135138
if skip {
136139
leftConditions = append(leftConditions, cJob)
137140
}
@@ -190,11 +193,11 @@ func (r *ReconcileCronHorizontalPodAutoscaler) Reconcile(request reconcile.Reque
190193
noNeedUpdateStatus = false
191194
instance.Status.Conditions = updateConditions(instance.Status.Conditions, jobCondition)
192195
}
193-
// conditions doesn't changed and no need to update.
196+
// conditions are not changed and no need to update.
194197
if !noNeedUpdateStatus || len(leftConditions) != len(conditions) {
195198
err := r.Update(context.Background(), instance)
196199
if err != nil {
197-
log.Errorf("Failed to update cron hpa %s status,because of %v", instance.Name, err)
200+
log.Errorf("Failed to update cron hpa %s in namespace %s status, because of %v", instance.Name, instance.Namespace, err)
198201
}
199202
}
200203

pkg/controller/cronjob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (ch *CronJobHPA) ScalePlainRef() (msg string, err error) {
239239
scale, err = ch.scaler.Scales(ch.TargetRef.RefNamespace).Get(context.Background(), targetGR, ch.TargetRef.RefName, v1.GetOptions{})
240240
if err == nil {
241241
found = true
242-
log.Infof("%s %s in namespace %s has been scaled successfully. job: %s replicas: %d", ch.TargetRef.RefKind, ch.TargetRef.RefName, ch.TargetRef.RefNamespace, ch.Name(), ch.DesiredSize)
242+
log.Infof("%s %s in namespace %s has been scaled successfully. job: %s replicas: %d id: %s", ch.TargetRef.RefKind, ch.TargetRef.RefName, ch.TargetRef.RefNamespace, ch.Name(), ch.DesiredSize, ch.ID())
243243
break
244244
}
245245
}

pkg/controller/cronmanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (cm *CronManager) GC() {
258258
}
259259
return true
260260
}
261-
261+
262262
log.Warningf("Failed to find job %s of cronHPA %s in %s in cron engine and resubmit the job.", job.Name(), hpa.Name, hpa.Namespace)
263263
cm.cronExecutor.AddJob(job)
264264
}

0 commit comments

Comments
 (0)