Migrate scheduler files interpodaffinity/filtering.go,podtopologyspread/filtering.go, volume_zone.go to structured logging

This commit is contained in:
Mengjiao Liu 2021-10-27 17:31:04 +08:00
parent 011aef1222
commit 2783ddc227
3 changed files with 7 additions and 7 deletions

View File

@ -161,7 +161,7 @@ func (pl *InterPodAffinity) getExistingAntiAffinityCounts(pod *v1.Pod, nsLabels
nodeInfo := nodes[i] nodeInfo := nodes[i]
node := nodeInfo.Node() node := nodeInfo.Node()
if node == nil { if node == nil {
klog.Error("node not found") klog.ErrorS(nil, "Node not found")
return return
} }
topoMap := make(topologyToMatchedTermCount) topoMap := make(topologyToMatchedTermCount)
@ -200,7 +200,7 @@ func (pl *InterPodAffinity) getIncomingAffinityAntiAffinityCounts(podInfo *frame
nodeInfo := allNodes[i] nodeInfo := allNodes[i]
node := nodeInfo.Node() node := nodeInfo.Node()
if node == nil { if node == nil {
klog.Error("node not found") klog.ErrorS(nil, "Node not found")
return return
} }
affinity := make(topologyToMatchedTermCount) affinity := make(topologyToMatchedTermCount)

View File

@ -226,7 +226,7 @@ func (pl *PodTopologySpread) calPreFilterState(pod *v1.Pod) (*preFilterState, er
for _, n := range allNodes { for _, n := range allNodes {
node := n.Node() node := n.Node()
if node == nil { if node == nil {
klog.Error("node not found") klog.ErrorS(nil, "Node not found")
continue continue
} }
// In accordance to design, if NodeAffinity or NodeSelector is defined, // In accordance to design, if NodeAffinity or NodeSelector is defined,
@ -296,7 +296,7 @@ func (pl *PodTopologySpread) Filter(ctx context.Context, cycleState *framework.C
tpKey := c.TopologyKey tpKey := c.TopologyKey
tpVal, ok := node.Labels[c.TopologyKey] tpVal, ok := node.Labels[c.TopologyKey]
if !ok { if !ok {
klog.V(5).Infof("node '%s' doesn't have required label '%s'", node.Name, tpKey) klog.V(5).InfoS("Node doesn't have required label", "node", klog.KObj(node), "label", tpKey)
return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonNodeLabelNotMatch) return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonNodeLabelNotMatch)
} }
@ -309,7 +309,7 @@ func (pl *PodTopologySpread) Filter(ctx context.Context, cycleState *framework.C
paths, ok := s.TpKeyToCriticalPaths[tpKey] paths, ok := s.TpKeyToCriticalPaths[tpKey]
if !ok { if !ok {
// error which should not happen // error which should not happen
klog.Errorf("internal error: get paths from key %q of %#v", tpKey, s.TpKeyToCriticalPaths) klog.ErrorS(nil, "Internal error occurred while retrieving paths from topology key", "topologyKey", tpKey, "paths", s.TpKeyToCriticalPaths)
continue continue
} }
// judging criteria: // judging criteria:
@ -321,7 +321,7 @@ func (pl *PodTopologySpread) Filter(ctx context.Context, cycleState *framework.C
} }
skew := matchNum + selfMatchNum - minMatchNum skew := matchNum + selfMatchNum - minMatchNum
if skew > c.MaxSkew { if skew > c.MaxSkew {
klog.V(5).Infof("node '%s' failed spreadConstraint[%s]: MatchNum(%d) + selfMatchNum(%d) - minMatchNum(%d) > maxSkew(%d)", node.Name, tpKey, matchNum, selfMatchNum, minMatchNum, c.MaxSkew) klog.V(5).InfoS("Node failed spreadConstraint: matchNum + selfMatchNum - minMatchNum > maxSkew", "node", klog.KObj(node), "topologyKey", tpKey, "matchNum", matchNum, "selfMatchNum", selfMatchNum, "minMatchNum", minMatchNum, "maxSkew", c.MaxSkew)
return framework.NewStatus(framework.Unschedulable, ErrReasonConstraintsNotMatch) return framework.NewStatus(framework.Unschedulable, ErrReasonConstraintsNotMatch)
} }
} }

View File

@ -157,7 +157,7 @@ func (pl *VolumeZone) Filter(ctx context.Context, _ *framework.CycleState, pod *
} }
if !volumeVSet.Has(nodeV) { if !volumeVSet.Has(nodeV) {
klog.V(10).Infof("Won't schedule pod %q onto node %q due to volume %q (mismatch on %q)", pod.Name, node.Name, pvName, k) klog.V(10).InfoS("Won't schedule pod onto node due to volume (mismatch on label key)", "pod", klog.KObj(pod), "node", klog.KObj(node), "PV", klog.KRef("", pvName), "PVLabelKey", k)
return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict) return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict)
} }
} }