New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate to structured logging #98875
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ func (sched *Scheduler) onPvcUpdate(old, new interface{}) { | |
func (sched *Scheduler) onStorageClassAdd(obj interface{}) { | ||
sc, ok := obj.(*storagev1.StorageClass) | ||
if !ok { | ||
klog.Errorf("cannot convert to *storagev1.StorageClass: %v", obj) | ||
klog.ErrorS(nil, "cannot convert to *storagev1.StorageClass", "obj", obj) | ||
return | ||
} | ||
|
||
|
@@ -90,32 +90,32 @@ func (sched *Scheduler) onServiceDelete(obj interface{}) { | |
func (sched *Scheduler) addNodeToCache(obj interface{}) { | ||
node, ok := obj.(*v1.Node) | ||
if !ok { | ||
klog.Errorf("cannot convert to *v1.Node: %v", obj) | ||
klog.ErrorS(nil, "cannot convert to *v1.Node", "obj", obj) | ||
return | ||
} | ||
|
||
if err := sched.SchedulerCache.AddNode(node); err != nil { | ||
klog.Errorf("scheduler cache AddNode failed: %v", err) | ||
klog.ErrorS(err, "scheduler cache AddNode failed") | ||
} | ||
|
||
klog.V(3).Infof("add event for node %q", node.Name) | ||
klog.V(3).InfoS("add event for node", "node", klog.KObj(node)) | ||
sched.SchedulingQueue.MoveAllToActiveOrBackoffQueue(queue.NodeAdd) | ||
} | ||
|
||
func (sched *Scheduler) updateNodeInCache(oldObj, newObj interface{}) { | ||
oldNode, ok := oldObj.(*v1.Node) | ||
if !ok { | ||
klog.Errorf("cannot convert oldObj to *v1.Node: %v", oldObj) | ||
klog.ErrorS(nil, "cannot convert oldObj to *v1.Node", "oldObj", oldObj) | ||
return | ||
} | ||
newNode, ok := newObj.(*v1.Node) | ||
if !ok { | ||
klog.Errorf("cannot convert newObj to *v1.Node: %v", newObj) | ||
klog.ErrorS(nil, "cannot convert newObj to *v1.Node", "newObj", newObj) | ||
return | ||
} | ||
|
||
if err := sched.SchedulerCache.UpdateNode(oldNode, newNode); err != nil { | ||
klog.Errorf("scheduler cache UpdateNode failed: %v", err) | ||
klog.ErrorS(err, "scheduler cache UpdateNode failed") | ||
} | ||
|
||
// Only activate unschedulable pods if the node became more schedulable. | ||
|
@@ -139,21 +139,21 @@ func (sched *Scheduler) deleteNodeFromCache(obj interface{}) { | |
var ok bool | ||
node, ok = t.Obj.(*v1.Node) | ||
if !ok { | ||
klog.Errorf("cannot convert to *v1.Node: %v", t.Obj) | ||
klog.ErrorS(nil, "cannot convert to *v1.Node", "obj", t.Obj) | ||
return | ||
} | ||
default: | ||
klog.Errorf("cannot convert to *v1.Node: %v", t) | ||
klog.ErrorS(nil, "cannot convert to *v1.Node", "type", t) | ||
return | ||
} | ||
klog.V(3).Infof("delete event for node %q", node.Name) | ||
klog.V(3).InfoS("delete event for node", "node", klog.KObj(node)) | ||
// NOTE: Updates must be written to scheduler cache before invalidating | ||
// equivalence cache, because we could snapshot equivalence cache after the | ||
// invalidation and then snapshot the cache itself. If the cache is | ||
// snapshotted before updates are written, we would update equivalence | ||
// cache with stale information which is based on snapshot of old cache. | ||
if err := sched.SchedulerCache.RemoveNode(node); err != nil { | ||
klog.Errorf("scheduler cache RemoveNode failed: %v", err) | ||
klog.ErrorS(err, "scheduler cache RemoveNode failed") | ||
} | ||
} | ||
|
||
|
@@ -212,7 +212,7 @@ func (sched *Scheduler) deletePodFromSchedulingQueue(obj interface{}) { | |
if err != nil { | ||
// This shouldn't happen, because we only accept for scheduling the pods | ||
// which specify a scheduler name that matches one of the profiles. | ||
klog.Error(err) | ||
klog.ErrorS(err, "unable to get profile", "pod", klog.KObj(pod)) | ||
return | ||
} | ||
fwk.RejectWaitingPod(pod.UID) | ||
|
@@ -221,13 +221,13 @@ func (sched *Scheduler) deletePodFromSchedulingQueue(obj interface{}) { | |
func (sched *Scheduler) addPodToCache(obj interface{}) { | ||
pod, ok := obj.(*v1.Pod) | ||
if !ok { | ||
klog.Errorf("cannot convert to *v1.Pod: %v", obj) | ||
klog.ErrorS(nil, "cannot convert to *v1.Pod", "obj", obj) | ||
return | ||
} | ||
klog.V(3).InfoS("Add event for scheduled pod", "pod", klog.KObj(pod)) | ||
|
||
if err := sched.SchedulerCache.AddPod(pod); err != nil { | ||
klog.Errorf("scheduler cache AddPod failed: %v", err) | ||
klog.ErrorS(err, "scheduler cache AddPod failed", "pod", klog.KObj(pod)) | ||
} | ||
|
||
sched.SchedulingQueue.AssignedPodAdded(pod) | ||
|
@@ -236,12 +236,12 @@ func (sched *Scheduler) addPodToCache(obj interface{}) { | |
func (sched *Scheduler) updatePodInCache(oldObj, newObj interface{}) { | ||
oldPod, ok := oldObj.(*v1.Pod) | ||
if !ok { | ||
klog.Errorf("cannot convert oldObj to *v1.Pod: %v", oldObj) | ||
klog.ErrorS(nil, "cannot convert oldObj to *v1.Pod", "oldObj", oldObj) | ||
return | ||
} | ||
newPod, ok := newObj.(*v1.Pod) | ||
if !ok { | ||
klog.Errorf("cannot convert newObj to *v1.Pod: %v", newObj) | ||
klog.ErrorS(nil, "cannot convert newObj to *v1.Pod", "newObj", newObj) | ||
return | ||
} | ||
|
||
|
@@ -260,7 +260,7 @@ func (sched *Scheduler) updatePodInCache(oldObj, newObj interface{}) { | |
// snapshotted before updates are written, we would update equivalence | ||
// cache with stale information which is based on snapshot of old cache. | ||
if err := sched.SchedulerCache.UpdatePod(oldPod, newPod); err != nil { | ||
klog.Errorf("scheduler cache UpdatePod failed: %v", err) | ||
klog.ErrorS(err, "scheduler cache UpdatePod failed", "oldPod", klog.KObj(oldPod), "newPod", klog.KObj(newPod)) | ||
} | ||
|
||
sched.SchedulingQueue.AssignedPodUpdated(newPod) | ||
|
@@ -275,11 +275,11 @@ func (sched *Scheduler) deletePodFromCache(obj interface{}) { | |
var ok bool | ||
pod, ok = t.Obj.(*v1.Pod) | ||
if !ok { | ||
klog.Errorf("cannot convert to *v1.Pod: %v", t.Obj) | ||
klog.ErrorS(nil, "cannot convert to *v1.Pod", "obj", t.Obj) | ||
return | ||
} | ||
default: | ||
klog.Errorf("cannot convert to *v1.Pod: %v", t) | ||
klog.ErrorS(nil, "cannot convert to *v1.Pod", "type", t) | ||
return | ||
} | ||
klog.V(3).InfoS("Delete event for scheduled pod", "pod", klog.KObj(pod)) | ||
|
@@ -289,7 +289,7 @@ func (sched *Scheduler) deletePodFromCache(obj interface{}) { | |
// snapshotted before updates are written, we would update equivalence | ||
// cache with stale information which is based on snapshot of old cache. | ||
if err := sched.SchedulerCache.RemovePod(pod); err != nil { | ||
klog.Errorf("scheduler cache RemovePod failed: %v", err) | ||
klog.ErrorS(err, "scheduler cache RemovePod failed", "pod", klog.KObj(pod)) | ||
} | ||
|
||
sched.SchedulingQueue.MoveAllToActiveOrBackoffQueue(queue.AssignedPodDelete) | ||
|
@@ -355,7 +355,7 @@ func (sched *Scheduler) skipPodUpdate(pod *v1.Pod) bool { | |
if !reflect.DeepEqual(assumedPodCopy, podCopy) { | ||
return false | ||
} | ||
klog.V(3).Infof("Skipping pod %s/%s update", pod.Namespace, pod.Name) | ||
klog.V(3).InfoS("skipping pod update", "pod", klog.KObj(pod)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's give more information here: |
||
return true | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start messages with upper case