From 0e38ba0ef6ae34873a6281d31b7cb93fba76a07f Mon Sep 17 00:00:00 2001 From: tanjunchen Date: Fri, 24 Apr 2020 11:17:11 +0800 Subject: [PATCH] pkg/scheduler/framework/:fix unconsistent comments and make log more clear --- .../defaultpodtopologyspread/default_pod_topology_spread.go | 6 +++--- pkg/scheduler/framework/plugins/examples/prebind/prebind.go | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go b/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go index 1475cfa6082..d93264745db 100644 --- a/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go +++ b/pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go @@ -97,7 +97,7 @@ func (pl *DefaultPodTopologySpread) Score(ctx context.Context, state *framework. } // NormalizeScore invoked after scoring all nodes. -// For this plugin, it calculates the source of each node +// For this plugin, it calculates the score of each node // based on the number of existing matching pods on the node // where zone information is included on the nodes, it favors nodes // in zones with fewer existing matching pods. @@ -116,7 +116,7 @@ func (pl *DefaultPodTopologySpread) NormalizeScore(ctx context.Context, state *f } nodeInfo, err := pl.handle.SnapshotSharedLister().NodeInfos().Get(scores[i].Name) if err != nil { - return framework.NewStatus(framework.Error, err.Error()) + return framework.NewStatus(framework.Error, fmt.Sprintf("getting node %q from Snapshot: %v", scores[i].Name, err)) } zoneID := utilnode.GetZoneKey(nodeInfo.Node()) if zoneID == "" { @@ -147,7 +147,7 @@ func (pl *DefaultPodTopologySpread) NormalizeScore(ctx context.Context, state *f if haveZones { nodeInfo, err := pl.handle.SnapshotSharedLister().NodeInfos().Get(scores[i].Name) if err != nil { - return framework.NewStatus(framework.Error, err.Error()) + return framework.NewStatus(framework.Error, fmt.Sprintf("getting node %q from Snapshot: %v", scores[i].Name, err)) } zoneID := utilnode.GetZoneKey(nodeInfo.Node()) diff --git a/pkg/scheduler/framework/plugins/examples/prebind/prebind.go b/pkg/scheduler/framework/plugins/examples/prebind/prebind.go index 12ba02485d4..66f24c12d5b 100644 --- a/pkg/scheduler/framework/plugins/examples/prebind/prebind.go +++ b/pkg/scheduler/framework/plugins/examples/prebind/prebind.go @@ -18,8 +18,6 @@ package prebind import ( "context" - "fmt" - v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" @@ -42,7 +40,7 @@ func (sr StatelessPreBindExample) Name() string { // PreBind is the functions invoked by the framework at "prebind" extension point. func (sr StatelessPreBindExample) PreBind(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) *framework.Status { if pod == nil { - return framework.NewStatus(framework.Error, fmt.Sprintf("pod cannot be nil")) + return framework.NewStatus(framework.Error, "pod cannot be nil") } if pod.Namespace != "foo" { return framework.NewStatus(framework.Unschedulable, "only pods from 'foo' namespace are allowed")