mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #90295 from tanjunchen/pkg/scheduler/framework/plugins/-20200420
pkg/scheduler/framework/plugins/:fix unconsistent comments and make log more clear
This commit is contained in:
commit
863ce9726e
@ -97,7 +97,7 @@ func (pl *DefaultPodTopologySpread) Score(ctx context.Context, state *framework.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NormalizeScore invoked after scoring all nodes.
|
// 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
|
// based on the number of existing matching pods on the node
|
||||||
// where zone information is included on the nodes, it favors nodes
|
// where zone information is included on the nodes, it favors nodes
|
||||||
// in zones with fewer existing matching pods.
|
// 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)
|
nodeInfo, err := pl.handle.SnapshotSharedLister().NodeInfos().Get(scores[i].Name)
|
||||||
if err != nil {
|
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())
|
zoneID := utilnode.GetZoneKey(nodeInfo.Node())
|
||||||
if zoneID == "" {
|
if zoneID == "" {
|
||||||
@ -147,7 +147,7 @@ func (pl *DefaultPodTopologySpread) NormalizeScore(ctx context.Context, state *f
|
|||||||
if haveZones {
|
if haveZones {
|
||||||
nodeInfo, err := pl.handle.SnapshotSharedLister().NodeInfos().Get(scores[i].Name)
|
nodeInfo, err := pl.handle.SnapshotSharedLister().NodeInfos().Get(scores[i].Name)
|
||||||
if err != nil {
|
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())
|
zoneID := utilnode.GetZoneKey(nodeInfo.Node())
|
||||||
|
@ -18,8 +18,6 @@ package prebind
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
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.
|
// 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 {
|
func (sr StatelessPreBindExample) PreBind(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) *framework.Status {
|
||||||
if pod == nil {
|
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" {
|
if pod.Namespace != "foo" {
|
||||||
return framework.NewStatus(framework.Unschedulable, "only pods from 'foo' namespace are allowed")
|
return framework.NewStatus(framework.Unschedulable, "only pods from 'foo' namespace are allowed")
|
||||||
|
Loading…
Reference in New Issue
Block a user