Migrate to structured logging (klog)
This commit is contained in:
parent
93ac8d5a21
commit
108637bb1c
31 changed files with 161 additions and 171 deletions
|
|
@ -75,7 +75,7 @@ func (t *Queue) EnqueueSkippableTask(obj interface{}) {
|
|||
// enqueue enqueues ns/name of the given api object in the task queue.
|
||||
func (t *Queue) enqueue(obj interface{}, skippable bool) {
|
||||
if t.IsShuttingDown() {
|
||||
klog.Errorf("queue has been shutdown, failed to enqueue: %v", obj)
|
||||
klog.ErrorS(nil, "queue has been shutdown, failed to enqueue", "key", obj)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -84,10 +84,10 @@ func (t *Queue) enqueue(obj interface{}, skippable bool) {
|
|||
// make sure the timestamp is bigger than lastSync
|
||||
ts = time.Now().Add(24 * time.Hour).UnixNano()
|
||||
}
|
||||
klog.V(3).Infof("queuing item %v", obj)
|
||||
klog.V(3).InfoS("queuing", "item", obj)
|
||||
key, err := t.fn(obj)
|
||||
if err != nil {
|
||||
klog.Errorf("%v", err)
|
||||
klog.ErrorS(err, "creating object key", "item", obj)
|
||||
return
|
||||
}
|
||||
t.queue.Add(Element{
|
||||
|
|
@ -119,15 +119,15 @@ func (t *Queue) worker() {
|
|||
|
||||
item := key.(Element)
|
||||
if t.lastSync > item.Timestamp {
|
||||
klog.V(3).Infof("skipping %v sync (%v > %v)", item.Key, t.lastSync, item.Timestamp)
|
||||
klog.V(3).InfoS("skipping sync", "key", item.Key, "last", t.lastSync, "now", item.Timestamp)
|
||||
t.queue.Forget(key)
|
||||
t.queue.Done(key)
|
||||
continue
|
||||
}
|
||||
|
||||
klog.V(3).Infof("syncing %v", item.Key)
|
||||
klog.V(3).InfoS("syncing", "key", item.Key)
|
||||
if err := t.sync(key); err != nil {
|
||||
klog.Warningf("requeuing %v, err %v", item.Key, err)
|
||||
klog.ErrorS(err, "requeuing", "key", item.Key)
|
||||
t.queue.AddRateLimited(Element{
|
||||
Key: item.Key,
|
||||
Timestamp: time.Now().UnixNano(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue