mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Fix typo: Use uniform format of structured klog
Signed-off-by: JunYang <yang.jun22@zte.com.cn>
This commit is contained in:
parent
a55bd63172
commit
78323910db
@ -122,8 +122,8 @@ func (jm *ControllerV2) Run(workers int, stopCh <-chan struct{}) {
|
|||||||
defer utilruntime.HandleCrash()
|
defer utilruntime.HandleCrash()
|
||||||
defer jm.queue.ShutDown()
|
defer jm.queue.ShutDown()
|
||||||
|
|
||||||
klog.Infof("Starting cronjob controller v2")
|
klog.InfoS("Starting cronjob controller v2")
|
||||||
defer klog.Infof("Shutting down cronjob controller v2")
|
defer klog.InfoS("Shutting down cronjob controller v2")
|
||||||
|
|
||||||
if !cache.WaitForNamedCacheSync("cronjob", stopCh, jm.jobListerSynced, jm.cronJobListerSynced) {
|
if !cache.WaitForNamedCacheSync("cronjob", stopCh, jm.jobListerSynced, jm.cronJobListerSynced) {
|
||||||
return
|
return
|
||||||
@ -170,7 +170,7 @@ func (jm *ControllerV2) sync(cronJobKey string) (*time.Duration, error) {
|
|||||||
switch {
|
switch {
|
||||||
case errors.IsNotFound(err):
|
case errors.IsNotFound(err):
|
||||||
// may be cronjob is deleted, don't need to requeue this key
|
// may be cronjob is deleted, don't need to requeue this key
|
||||||
klog.V(4).InfoS("cronjob not found, may be it is deleted", "cronjob", klog.KRef(ns, name), "err", err)
|
klog.V(4).InfoS("CronJob not found, may be it is deleted", "cronjob", klog.KRef(ns, name), "err", err)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case err != nil:
|
case err != nil:
|
||||||
// for other transient apiserver error requeue with exponential backoff
|
// for other transient apiserver error requeue with exponential backoff
|
||||||
@ -184,18 +184,18 @@ func (jm *ControllerV2) sync(cronJobKey string) (*time.Duration, error) {
|
|||||||
|
|
||||||
cronJobCopy, requeueAfter, err := jm.syncCronJob(cronJob, jobsToBeReconciled)
|
cronJobCopy, requeueAfter, err := jm.syncCronJob(cronJob, jobsToBeReconciled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(2).InfoS("error reconciling cronjob", "cronjob", klog.KRef(cronJob.GetNamespace(), cronJob.GetName()), "err", err)
|
klog.V(2).InfoS("Error reconciling cronjob", "cronjob", klog.KRef(cronJob.GetNamespace(), cronJob.GetName()), "err", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = jm.cleanupFinishedJobs(cronJobCopy, jobsToBeReconciled)
|
err = jm.cleanupFinishedJobs(cronJobCopy, jobsToBeReconciled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(2).InfoS("error cleaning up jobs", "cronjob", klog.KRef(cronJob.GetNamespace(), cronJob.GetName()), "resourceVersion", cronJob.GetResourceVersion(), "err", err)
|
klog.V(2).InfoS("Error cleaning up jobs", "cronjob", klog.KRef(cronJob.GetNamespace(), cronJob.GetName()), "resourceVersion", cronJob.GetResourceVersion(), "err", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if requeueAfter != nil {
|
if requeueAfter != nil {
|
||||||
klog.V(4).InfoS("re-queuing cronjob", "cronjob", klog.KRef(cronJob.GetNamespace(), cronJob.GetName()), "requeueAfter", requeueAfter)
|
klog.V(4).InfoS("Re-queuing cronjob", "cronjob", klog.KRef(cronJob.GetNamespace(), cronJob.GetName()), "requeueAfter", requeueAfter)
|
||||||
return requeueAfter, nil
|
return requeueAfter, nil
|
||||||
}
|
}
|
||||||
// this marks the key done, currently only happens when the cronjob is suspended or spec has invalid schedule format
|
// this marks the key done, currently only happens when the cronjob is suspended or spec has invalid schedule format
|
||||||
@ -372,7 +372,7 @@ func (jm *ControllerV2) updateCronJob(old interface{}, curr interface{}) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// this is likely a user error in defining the spec value
|
// this is likely a user error in defining the spec value
|
||||||
// we should log the error and not reconcile this cronjob until an update to spec
|
// we should log the error and not reconcile this cronjob until an update to spec
|
||||||
klog.V(2).InfoS("unparseable schedule for cronjob", "cronjob", klog.KRef(newCJ.GetNamespace(), newCJ.GetName()), "schedule", newCJ.Spec.Schedule, "err", err)
|
klog.V(2).InfoS("Unparseable schedule for cronjob", "cronjob", klog.KRef(newCJ.GetNamespace(), newCJ.GetName()), "schedule", newCJ.Spec.Schedule, "err", err)
|
||||||
jm.recorder.Eventf(newCJ, corev1.EventTypeWarning, "UnParseableCronJobSchedule", "unparseable schedule for cronjob: %s", newCJ.Spec.Schedule)
|
jm.recorder.Eventf(newCJ, corev1.EventTypeWarning, "UnParseableCronJobSchedule", "unparseable schedule for cronjob: %s", newCJ.Spec.Schedule)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -473,7 +473,7 @@ func (jm *ControllerV2) syncCronJob(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// this is likely a user error in defining the spec value
|
// this is likely a user error in defining the spec value
|
||||||
// we should log the error and not reconcile this cronjob until an update to spec
|
// we should log the error and not reconcile this cronjob until an update to spec
|
||||||
klog.V(2).InfoS("unparseable schedule", "cronjob", klog.KRef(cj.GetNamespace(), cj.GetName()), "schedule", cj.Spec.Schedule, "err", err)
|
klog.V(2).InfoS("Unparseable schedule", "cronjob", klog.KRef(cj.GetNamespace(), cj.GetName()), "schedule", cj.Spec.Schedule, "err", err)
|
||||||
jm.recorder.Eventf(cj, corev1.EventTypeWarning, "UnparseableSchedule", "unparseable schedule: %s : %s", cj.Spec.Schedule, err)
|
jm.recorder.Eventf(cj, corev1.EventTypeWarning, "UnparseableSchedule", "unparseable schedule: %s : %s", cj.Spec.Schedule, err)
|
||||||
return cj, nil, nil
|
return cj, nil, nil
|
||||||
}
|
}
|
||||||
@ -667,12 +667,11 @@ func (jm *ControllerV2) removeOldestJobs(cj *batchv1.CronJob, js []*batchv1.Job,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nameForLog := fmt.Sprintf("%s/%s", cj.Namespace, cj.Name)
|
klog.V(4).InfoS("Cleaning up jobs from CronJob list", "deletejobnum", numToDelete, "jobnum", len(js), "cronjob", klog.KRef(cj.GetNamespace(), cj.GetName()))
|
||||||
klog.V(4).Infof("Cleaning up %d/%d jobs from %s", numToDelete, len(js), nameForLog)
|
|
||||||
|
|
||||||
sort.Sort(byJobStartTimeStar(js))
|
sort.Sort(byJobStartTimeStar(js))
|
||||||
for i := 0; i < numToDelete; i++ {
|
for i := 0; i < numToDelete; i++ {
|
||||||
klog.V(4).Infof("Removing job %s from %s", js[i].Name, nameForLog)
|
klog.V(4).InfoS("Removing job from CronJob list", "job", js[i].Name, "cronjob", klog.KRef(cj.GetNamespace(), cj.GetName()))
|
||||||
deleteJob(cj, js[i], jm.jobControl, jm.recorder)
|
deleteJob(cj, js[i], jm.jobControl, jm.recorder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user