Migrate pkg/scheduler logs to structured logging

in pkg/scheduler/eventhandlers.go
  * add event for unscheduled pod
  * delete event for unscheduled pod
  * add event for scheduled pod
  * delete event for scheduled pod

in pkg/scheduler/framework/plugins/defaultbinder/default_binder.go
  * Attempting to bind pod to node

in pkg/scheduler/scheduler.go
  * Updating pod condition
  * Attempting to schedule pod
  * Skip schedule deleting pod
This commit is contained in:
Alex Dudko 2020-12-16 08:24:25 -08:00
parent 4164818517
commit c03b4c7850
3 changed files with 8 additions and 8 deletions

View File

@ -169,7 +169,7 @@ func (sched *Scheduler) onCSINodeUpdate(oldObj, newObj interface{}) {
func (sched *Scheduler) addPodToSchedulingQueue(obj interface{}) {
pod := obj.(*v1.Pod)
klog.V(3).Infof("add event for unscheduled pod %s/%s", pod.Namespace, pod.Name)
klog.V(3).InfoS("Add event for unscheduled pod", "pod", klog.KObj(pod))
if err := sched.SchedulingQueue.Add(pod); err != nil {
utilruntime.HandleError(fmt.Errorf("unable to queue %T: %v", obj, err))
}
@ -206,7 +206,7 @@ func (sched *Scheduler) deletePodFromSchedulingQueue(obj interface{}) {
utilruntime.HandleError(fmt.Errorf("unable to handle object in %T: %T", sched, obj))
return
}
klog.V(3).Infof("delete event for unscheduled pod %s/%s", pod.Namespace, pod.Name)
klog.V(3).InfoS("Delete event for unscheduled pod", "pod", klog.KObj(pod))
if err := sched.SchedulingQueue.Delete(pod); err != nil {
utilruntime.HandleError(fmt.Errorf("unable to dequeue %T: %v", obj, err))
}
@ -226,7 +226,7 @@ func (sched *Scheduler) addPodToCache(obj interface{}) {
klog.Errorf("cannot convert to *v1.Pod: %v", obj)
return
}
klog.V(3).Infof("add event for scheduled pod %s/%s ", pod.Namespace, pod.Name)
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)
@ -284,7 +284,7 @@ func (sched *Scheduler) deletePodFromCache(obj interface{}) {
klog.Errorf("cannot convert to *v1.Pod: %v", t)
return
}
klog.V(3).Infof("delete event for scheduled pod %s/%s ", pod.Namespace, pod.Name)
klog.V(3).InfoS("Delete event for scheduled pod", "pod", klog.KObj(pod))
// 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

View File

@ -48,7 +48,7 @@ func (b DefaultBinder) Name() string {
// Bind binds pods to nodes using the k8s client.
func (b DefaultBinder) Bind(ctx context.Context, state *framework.CycleState, p *v1.Pod, nodeName string) *framework.Status {
klog.V(3).Infof("Attempting to bind %v/%v to %v", p.Namespace, p.Name, nodeName)
klog.V(3).InfoS("Attempting to bind pod to node", "pod", klog.KObj(p), "node", nodeName)
binding := &v1.Binding{
ObjectMeta: metav1.ObjectMeta{Namespace: p.Namespace, Name: p.Name, UID: p.UID},
Target: v1.ObjectReference{Kind: "Node", Name: nodeName},

View File

@ -340,7 +340,7 @@ func (sched *Scheduler) recordSchedulingFailure(fwk framework.Framework, podInfo
}
func updatePod(client clientset.Interface, pod *v1.Pod, condition *v1.PodCondition, nominatedNode string) error {
klog.V(3).Infof("Updating pod condition for %s/%s to (%s==%s, Reason=%s)", pod.Namespace, pod.Name, condition.Type, condition.Status, condition.Reason)
klog.V(3).InfoS("Updating pod condition", "pod", klog.KObj(pod), "conditionType", condition.Type, "conditionStatus", condition.Status, "conditionReason", condition.Reason)
podCopy := pod.DeepCopy()
// NominatedNodeName is updated only if we are trying to set it, and the value is
// different from the existing one.
@ -442,7 +442,7 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
return
}
klog.V(3).Infof("Attempting to schedule pod: %v/%v", pod.Namespace, pod.Name)
klog.V(3).InfoS("Attempting to schedule pod", "pod", klog.KObj(pod))
// Synchronously attempt to find a fit for the pod.
start := time.Now()
@ -621,7 +621,7 @@ func (sched *Scheduler) skipPodSchedule(fwk framework.Framework, pod *v1.Pod) bo
// Case 1: pod is being deleted.
if pod.DeletionTimestamp != nil {
fwk.EventRecorder().Eventf(pod, nil, v1.EventTypeWarning, "FailedScheduling", "Scheduling", "skip schedule deleting pod: %v/%v", pod.Namespace, pod.Name)
klog.V(3).Infof("Skip schedule deleting pod: %v/%v", pod.Namespace, pod.Name)
klog.V(3).InfoS("Skip schedule deleting pod", "pod", klog.KObj(pod))
return true
}